Re: Handle Of Modal Window
- From: "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 3 Nov 2007 06:22:38 -0700
"amarguben" <amarguben@xxxxxxxxx> wrote in message
news:1194069554.416094.40290@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Dave and Joe,
Thanks for the reply.
Yes the window is a Win32 window and i used spy++ to find its class
name and stuff. i used FindWindowEx like bellow to find the handle to
the modal window.
CWnd* parentWind,*childWind1,*childWind2;
parentWind = CWnd::FindWind("Class Name of parent window","Caption of
the parent window");
parentWind->SendMessage(WM_COMMAND,MAKEWPARAM(13000,0),0);// to open
the first modal window
HWND handle1 = parentWind.Detach();// to get HWND from CWnd*
if(childWind1 =
CWnd::FindWindowEx(handle1,NULL,"#32770","Configuration Wizard"))//to
find the parent window{
HWND handle2 = wind1->Detach();
childWind2 = CWnd::FindWindowEx(handle2,NULL,"Button","Next");
childWind2->SendMessage(BM_CLICK,0,0);
}
The above code successfully opens the modal window. but fails to find
the handle to the openned modal window and send BM_CLICK message to go
to the next modal window.
Looks like FindWindowEx() fails because you are not giving the app time to
display the window after sending the WM_COMMAND. BTW, I would post the
WM_COMMAND instead of send it because you don't need the return value of
SendMessage() and if the app is hung, it won't hang your app.
So the solution is to wait for the new window to display. Do that by
calling WaitForInputIdle(). It requires an hProcess. You can get this by
calling GetWindowThreadProcessId() to get the process id, then doing an
OpenProcess() to get a handle from the id.
-- David
.
- References:
- Handle Of Modal Window
- From: amarguben
- Re: Handle Of Modal Window
- From: David Lowndes
- Re: Handle Of Modal Window
- From: amarguben
- Handle Of Modal Window
- Prev by Date: Re: how can i create virtual drive
- Next by Date: TreeCtrl problem
- Previous by thread: Re: Handle Of Modal Window
- Next by thread: Re: Handle Of Modal Window
- Index(es):
Relevant Pages
|