|  |
12-16-2005, 06:03 AM
|
#1 (permalink)
|
Junior Techie Join Date: Jun 2005 Posts: 94
| Showing a message box in a child process. I created a child process in a Windows program with the following code:
PROCESS_INFORMATION info;
memset (&info, 0 , sizeof (info));
STARTUPINFO start;
memset (&start, 0 , sizeof (start));
start.lpReserved = NULL;
start.lpDesktop = "E:\desktop";
start.lpTitle = NULL;
start.dwX = 0;
start.dwY = 0;
start.dwXSize = 0;
start.dwYSize = 0;
start.dwXCountChars = 0;
start.dwYCountChars = 0;
start.dwFillAttribute = 0;
start.dwFlags = 0;
start.wShowWindow = 0;
start.cbReserved2 = 0;
start.lpReserved2 = NULL;
start.hStdInput = NULL;
start.hStdOutput = NULL;
start.hStdError = NULL;
start.cb = sizeof (start);
CreateProcess (NULL, Child_exe, NULL, NULL, FALSE, 0, NULL, NULL, &start, &info);
The child process then calls the message box function several times. When it does I hear the characteristic sound of a message box, Task Manager displays it in the open windows tab, but the box is nowhere to be seen on the screen. I tried fiddling around with the various x and y and wShowWindow members in the STRARTUPINFO struct, but nothing seems to help. |
| |
12-16-2005, 12:57 PM
|
#2 (permalink)
|
Ultra Techie Join Date: Jul 2005 Posts: 530
| What HWND are you passing to MessageBox()?
__________________ Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache) |
| |
12-17-2005, 05:08 PM
|
#3 (permalink)
|
Junior Techie Join Date: Jun 2005 Posts: 94
| NULL. When calling MessageBox from a top-level process (or DLL in its address space) this is not a problem. |
| |
12-17-2005, 10:14 PM
|
#4 (permalink)
|
Ultra Techie Join Date: Jul 2005 Posts: 530
| Well, NULL is the right HWND, dunno why it isn't working.
Maybe try passing down a HWND pointer from the parent process somehow?
Alternatively, you can Enum the Windows, find your parent Process, and use that HWND.
__________________ Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache) |
| |
12-19-2005, 06:14 AM
|
#5 (permalink)
|
Junior Techie Join Date: Jun 2005 Posts: 94
| The entire process tree is not a GUI, so there are no HWNDs; the only windows I show are error messages for which I use MessageBox () |
| |
12-19-2005, 03:59 PM
|
#6 (permalink)
|
Ultra Techie Join Date: Jul 2005 Posts: 530
| Well you can always still call EnumWindows and find any window and try using that. You can even grab the HWND of explorer itself, if I remember correctly.
__________________ Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache) |
| |
12-19-2005, 06:22 PM
|
#7 (permalink)
|
Junior Techie Join Date: Jun 2005 Posts: 94
| Still the same result. Here's the code I used.
In WinMain ():
HWND hWnd;
EnumWindows (GetNonChildWindow, (LPARAM) &hWnd);
and passed hWnd as the HWND to MessageBox ()
and getNonChildWindow ():
BOOL CALLBACK GetNonChildWindow (HWND hwnd, LPARAM lparam){
if (GetWindowLong (hwnd, GWL_STYLE) & WS_CHILD){
lparam = (LPARAM) &hwnd;
return false;
}
return true;
} |
| |  | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |