CreateProcess and input focus
Andrea Matta -- andma@mbox.vol.it Tuesday, July 30, 1996 Environment: Visual C++ 4.1/Windows 95 Hi, I'm working on a dialog based application that runs many other apps (both = DOS and Win32 ones) with calls to CreateProcess(). My problem is that everytime I call CreateProcess() the input focus goes t= o the spawned application. How can I prevent this? -- Andrea Matta am@POBoxes.com http://www.poboxes.com/POBoxes/?am
Jason R. Simpson -- doecreek@tir.com Saturday, August 03, 1996 [Mini-digest: 6 responses] You could call BringWindowToTop() in your in your dialog which would set the focus back to your application. ---------- From: Andrea MattaTo: mfc-l@netcom.com Subject: CreateProcess and input focus Date: Tuesday, July 30, 1996 5:00 AM Environment: Visual C++ 4.1/Windows 95 Hi, I'm working on a dialog based application that runs many other apps (both DOS and Win32 ones) with calls to CreateProcess(). My problem is that everytime I call CreateProcess() the input focus goes to the spawned application. How can I prevent this? -- Andrea Matta am@POBoxes.com http://www.poboxes.com/POBoxes/?am -----From: "Mike Blaszczak" According to the CreateProcess() documentation, you'll need to pass a pointer to a STARTUPINFO structure. That structure has a member named wShowWindow. The value you stick in wShowWindow is passed to the new application and, by convention, is used in a call to the ShowWindow() API when the started application creates its first window. Perhaps you should set wShowWindow to something like SW_SHOWNA or SW_SHOWNOACTIVATE. Either of these should work for DOS boxen, no problem. Some applications don't listen to this value. For those, you might have to start the application and then get focus set back to yourself: maybe you could set a flag and then check it in a response to WM_KILLFOCUS in your main window. Or, maybe you'll just have to live with it. .B ekiM http://www.nwlink.com/~mikeblas "Dig!" -- Jimi Hendrix -----From: David.Lowndes@bj.co.uk Andrea, You need to specify a suitable flag (such as SW_SHOWNOACTIVATE) for the wShowWindow parameter in the STARTUPINFO structure you pass to CreateProcess(). You also need to set the STARTF_USESHOWWINDOW flag in the dwFlags parameter. Dave Lowndes -----From: "Lee, Benny" I don't believe you can prevent this. In fact, I believe this is the way it is suppose to work. You can do something like the following: CWnd* pWnd = CWnd::GetFocus(); CreateProcess(...) pWnd->SetFocus(); Benny -----From: Pete Chestna A couple things off of the top of my head: 1. Set focus back to yourself after the CreateProcess() 2. Install a message hook and block the WM_SetFocus calls to the created process. This one will block the focus switch whereas #1 will not. Pete --- "To you -- is it movement or is it action? Peter J. Chestna It is contact or just reaction? HighGround Systems And you -- revolution or just resistance? PChestna@highground.com Is it living, or just existence?" - RUSH (508) 263-5588 x.125 -----From: "PJ Durai" I think this can be done using the 9'th paramter LPSTARTUPINFO STARTUPINFO si; PROCESS_INFORMATION pi; memset (&si, 0, sizeof (STARTUPINFO)); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWNOACTIVATE; CreateProcess (....); This should keep the input focus on the main application. Good luck pj.
Peter Jones -- peter.jones@autodesk.com Wednesday, August 07, 1996 Note that in 32-bits BringWindowToTop will not always result in your application becomming the active and foreground application. To ensure that you should call SetForegroundWindow instead. Pj. Peter Jones Autodesk ______________________________ Reply Separator _________________________________ Subject: Re: CreateProcess and input focus Author: mfc-l@netcom.com at SMTPCC3 Date: 8/6/96 1:27 PM [Mini-digest: 6 responses] You could call BringWindowToTop() in your in your dialog which would set the focus back to your application. ---------- From: Andrea MattaTo: mfc-l@netcom.com Subject: CreateProcess and input focus Date: Tuesday, July 30, 1996 5:00 AM Environment: Visual C++ 4.1/Windows 95 Hi, I'm working on a dialog based application that runs many other apps (both DOS and Win32 ones) with calls to CreateProcess(). My problem is that everytime I call CreateProcess() the input focus goes to the spawned application. How can I prevent this? -- Andrea Matta am@POBoxes.com http://www.poboxes.com/POBoxes/?am -----From: "Mike Blaszczak" According to the CreateProcess() documentation, you'll need to pass a pointer to a STARTUPINFO structure. That structure has a member named wShowWindow. The value you stick in wShowWindow is passed to the new application and, by convention, is used in a call to the ShowWindow() API when the started application creates its first window. Perhaps you should set wShowWindow to something like SW_SHOWNA or SW_SHOWNOACTIVATE. Either of these should work for DOS boxen, no problem. Some applications don't listen to this value. For those, you might have to start the application and then get focus set back to yourself: maybe you could set a flag and then check it in a response to WM_KILLFOCUS in your main window. Or, maybe you'll just have to live with it. .B ekiM http://www.nwlink.com/~mikeblas "Dig!" -- Jimi Hendrix -----From: David.Lowndes@bj.co.uk Andrea, You need to specify a suitable flag (such as SW_SHOWNOACTIVATE) for the wShowWindow parameter in the STARTUPINFO structure you pass to CreateProcess(). You also need to set the STARTF_USESHOWWINDOW flag in the dwFlags parameter. Dave Lowndes -----From: "Lee, Benny" I don't believe you can prevent this. In fact, I believe this is the way it is suppose to work. You can do something like the following: CWnd* pWnd = CWnd::GetFocus(); CreateProcess(...) pWnd->SetFocus(); Benny -----From: Pete Chestna A couple things off of the top of my head: 1. Set focus back to yourself after the CreateProcess() 2. Install a message hook and block the WM_SetFocus calls to the created process. This one will block the focus switch whereas #1 will not. Pete --- "To you -- is it movement or is it action? Peter J. Chestna It is contact or just reaction? HighGround Systems And you -- revolution or just resistance? PChestna@highground.com Is it living, or just existence?" - RUSH (508) 263-5588 x.125 -----From: "PJ Durai" I think this can be done using the 9'th paramter LPSTARTUPINFO STARTUPINFO si; PROCESS_INFORMATION pi; memset (&si, 0, sizeof (STARTUPINFO)); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWNOACTIVATE; CreateProcess (....); This should keep the input focus on the main application. Good luck pj.
| Вернуться в корень Архива |