CreateProcess() - 如何创建级联对话框 [英] CreateProcess() - How to create cascading dialogs

查看:69
本文介绍了CreateProcess() - 如何创建级联对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何创建级联对话程序的问题。下面的代码用于创建同一对话框的多个版本,仅使用处理的命令行。我想做的是让它们级联,根据MSVC ++ V6文档,设置 STARTUPINFO 位字段 STARTF_USEPOSITION 应该使新对话框位于 dwX &位置。 DWY 。无论使用何种位域组合,新对话框始终位于原始对话框所在的位置 - 位于屏幕中央。



任何建议都将受到赞赏。



谢谢,



-jon

  //  流程初始化 
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(& si, sizeof (si));
si.cb = sizeof (si);
si.wShowWindow = SW_SHOWNORMAL;
si.dwFlags = STARTF_USEPOSITION | STARTF_USESHOWWINDOW;

for (i = 0 ,dwX = 0 ,dwY = 0 ; i< lFileMax; i ++){
sprintf(buf, %s,sFileArray.GetAt(i));
_splitpath(buf,drive,dir,fname,ext);
display( processing->%s,fname);
// 检查操作
if (iRadioBatchCombine == 1 ){
sprintf(cmdLine, COMBINE%s,buf);
}
else if (iRadioBatchNetInput == 1 ){
sprintf(cmdLine, NET_INPUT%s,buf);
}
else if (iRadioBatchPNNPost == 1 ){
sprintf(cmdLine, PNN_Post%s,buf);
}
// 产生新程序
si.dwX = DWX;
si.dwY = dwY;
if (CreateProcess(exeFile,cmdLine,NULL,NULL,FALSE,
CREATE_SUSPENDED | IDLE_PRIORITY_CLASS,NULL,__TEXT( \\),& si,& pi)){

SetThreadPriority( pi.hThread,THREAD_PRIORITY_NORMAL);

// 提高我们的优先级,以便我们尽快终止。
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_NORMAL);
SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS);

// 允许批处理文件运行并清理我们的句柄。
CloseHandle(pi.hProcess);
ResumeThread(pi.hThread);
// 我们希望立即终止,以便我们可以删除
CloseHandle(pi.hThread);
}
睡眠( 100 );
dwX + = 50 ,dwY + = 50 ;
}

解决方案

生成的EXE可以忽略您的窗口放置设置。检查生成的程序的WM_CREATE处理程序,以查看在创建框架或对话框窗口时它是否总是像CenterWindow()那样。


生成的对话框程序使用选项卡式对话框类,并且我正在通过代码来查看覆盖的位置。感谢指向要查看的位置。


在显示对话框之前,在任何主应用程序或对话框方法中都找不到SI结构。作为一种解决方法,SI dwFlags,dwX& dwY被附加到命令行。在主应用程序中的条目中,它们被提取并分配给全局变量。然后在显示对话框之前设置SetWindowPos,如下所示:



 void CNLPredictDlg :: OnShowWindow(BOOL bShow,UINT nStatus)
{
CDialog :: OnShowWindow(bShow,nStatus);

// TODO:在这里添加你的消息处理程序代码
RECT Rect;
GetWindowRect(& Rect);

if((CNLPredictApp :: dwFlags!= -1)&&(CNLPredictApp :: dwFlags& STARTF_USEPOSITION)){
//更改大小
SetWindowPos( NULL,CNLPredictApp :: dwX,CNLPredictApp :: dwY,
Rect.right - Rect.left,Rect.bottom - Rect.top,SWP_SHOWWINDOW);
}

}





现在可以正确级联多个对话框应用程序。


A question on how to create cascading dialog programs. The code below is being used to create multiple versions of the same dialog, only with a command line that is processed. What I would like to do is have them cascade, and according to the MSVC++ V6 documentation, setting the STARTUPINFO bit field STARTF_USEPOSITION should cause the new dialog to be positioned at the location dwX & dwY. No matter what combinations of bit fields used, the new dialog is always positioned where the original one is located - in the center of the screen.

Any suggestions would be appreciated.

Thanks,

-jon

// process initialization
STARTUPINFO	si;
PROCESS_INFORMATION pi;
ZeroMemory (&si, sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = SW_SHOWNORMAL;
si.dwFlags = STARTF_USEPOSITION | STARTF_USESHOWWINDOW;

for ( i = 0, dwX=0, dwY=0; i < lFileMax; i++ ) {
	sprintf(buf,"%s",sFileArray.GetAt(i));
	_splitpath (buf, drive, dir, fname, ext);
	display("processing->%s", fname ) ;
	// check for operation
	if ( iRadioBatchCombine == 1 ) {
		sprintf(cmdLine,"COMBINE %s", buf );
	}
	else if ( iRadioBatchNetInput == 1 ) {
		sprintf(cmdLine,"NET_INPUT %s", buf );
	}
	else if ( iRadioBatchPNNPost == 1 ) {
		sprintf(cmdLine,"PNN_Post %s", buf );
	}
	// spawn new program
	si.dwX = dwX;
	si.dwY = dwY;
	if (CreateProcess(exeFile, cmdLine, NULL, NULL, FALSE,
		CREATE_SUSPENDED | IDLE_PRIORITY_CLASS, NULL, __TEXT("\\"), &si, &pi)) {

		SetThreadPriority(pi.hThread, THREAD_PRIORITY_NORMAL);

		// Raise our priority so that we terminate as quickly as possible.
		SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
				SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);

		// Allow the batch file to run and clean-up our handles.
		CloseHandle(pi.hProcess);
		ResumeThread(pi.hThread);
		// We want to terminate right away now so that we can be deleted
		CloseHandle(pi.hThread);
	}
	Sleep(100);
	dwX+=50, dwY+=50;		
}

解决方案

The spawned EXE can ignore your window placement settings. Check the WM_CREATE handler of the spawned program to see if it always does something like CenterWindow() when the frame or dialog window is created.


The spawned dialog program uses a tabbed dialog class, and am working though the code to see where the override is located. Thanks for the pointer on where to look.


The SI structure was never found in any of the main app or dialog methods prior to displaying the dialog. As a workaround, the SI dwFlags, dwX & dwY were appended to the command line.Upon entry in the main app, they were extracted and assigned to global variables. The SetWindowPos was then set prior to displaying the dialog as follows:

void CNLPredictDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	// TODO: Add your message handler code here
	RECT Rect;
	GetWindowRect(&Rect);

	if ( ( CNLPredictApp::dwFlags != -1 ) && ( CNLPredictApp::dwFlags & STARTF_USEPOSITION ) ) {
		// Change the size
		SetWindowPos(NULL, CNLPredictApp::dwX, CNLPredictApp::dwY, 
			Rect.right - Rect.left, Rect.bottom - Rect.top, SWP_SHOWWINDOW);
	}

}



Multiple spawns of dialog applications are now cascaded properly.


这篇关于CreateProcess() - 如何创建级联对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆