CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    27

    Question Finding Dialog Box Handle

    I have used Findwindow & findwindowEX to get dialog box handle. But it's returning always 0 value.

    I saw in Spy++ thar this dialog box is not under Parent window child tree but it's above the parent window, means on Main Desktop Process window child tree list. Even I used only FindWindow to find dialog box, but I have got 0 value in return. This dialog box has only class name, no windows name.

    Also I have checked that in spy++ that this dialog box showing parent window name & it's handle. But it's not in child tree of his parent window.

    Anybody know how to get such dialog box handles which have parent window but not residing in it as per showed in Spy++.
    Last edited by nilu_2005; July 30th, 2010 at 05:49 AM.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Finding Dialog Box Handle

    The form (dialog box) has it's parent window set to the desktop. Usually most apps set the parent to the application to avoid the form going behind the application.

    If you use FindWindow, you need to specify the Title and Class name of the form. This works okay if you can control your environment and know the title of the form and it's class name.

    Another approach is to use EnumWindows and filter out any Windows that aren't part of the application. You do this by retrieving the app process id and then pinvoke to the GetWindowThreadProcessId api within the enum callback to filter out windows that are not from your app.

  3. #3
    Join Date
    Mar 2010
    Posts
    27

    Re: Finding Dialog Box Handle

    I thought that I was going to use EnumWindows.But then I realize that the problem will arise on such method because specific dialog box who has parent window but not reside in his own parent window children tree. Even if I use EnumWindows, I need to specify filter technique like class name & window name check to get correct dialog box window. But this dialog box has only class name & not have windows title. Also the class name is same for other applications dialog box. So I can't send "null" value in Window Title of Findwindow.

    Only option remains that I need to check each window as you mentioned above, This will give me more than 1 dialog box window with same class name. After this I need to find which dialog box has parent that I am looking for. Which in turn return correct dialog box.

    It should have been easy if this window was in children tree. but In my case it's not . I will post working code here for such dialog boxes. Thanks for your reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured