Re: Handle Of Modal Window

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"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


.



Relevant Pages

  • Re: Question about automating program actions in VB.NET
    ... SetWindowText on it. ... constant string you could likely use FindWindowEx to locate its handle. ... Try using Spy++ on the window in question to determine the class name of the ... VB6 app it will more likely be something like ThunderRT6TextBox. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Component Handles
    ... FindWindowEx function. ... If it is a VB6 Form and if you want a specific textbox (and if you know ... all window names match. ... which I thought wasn't even compiled into the app in the first place. ...
    (microsoft.public.vb.general.discussion)
  • Re: How to show popup when modal window is displayed
    ... Show a new form with all the data from the hidden form copied onto it. ... window while a modal window is displayed? ... The display of this information must, ... non-modal even when a modal window is displayed. ...
    (microsoft.public.vb.general.discussion)
  • Re: WM_QUERYCENTERWND and detecting creation of modal window.
    ... the parent window is receivinig WM_QUERYCENTERWND when new ... >modal window is started under that parent. ... > message loop blocking by "not very good" written plugins, ...
    (microsoft.public.vc.mfc)
  • Re: notification windows a la Outlook
    ... If you want everything to be created on the main thread, pass the modal window as a parameter into the Show method of your notification window. ... I want to be able to create and display the notes from the ...
    (microsoft.public.dotnet.framework.windowsforms)