Results 1 to 4 of 4

Thread: Getting a window handle without findwindow or getwindow

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    39
    How would i do something like that?

    I've run into some problems trying to get the window handle of the "Enter Password" dialog box for Outlook when it starts up, as in it wont fricking work.

    its one of those windows that's not a child of "microsoft outlook" but "microsoft outlook" is the parent of the window. (to see what i mean go in SpyXX and find some window at the top level that has a parent.

    i tried FindWindow(vbNullString, "Enter Password"), which didn't work, and then

    hwnd = FindWindow(vbNullstring, "Microsoft Outlook"
    tmphwnd = getWindow(getdesktopwindow(), GW_CHILD)
    do while true
    if getparent(tmphwnd)=hwnd
    MSGBOX "SUCCESS"
    tmphwnd = Getwindow(tmphwnd, GW_HWNDNEXT)
    Loop

    so that gets the handle of outlook, then gets the handle of the desktop, then find first child window. Checks to see if the parent of that child window is the handle of Microsoft Outlook, and if not, goes on to the next child window. rinse and repeat.

    The problem is, it never finds it. When i run this with notepad, or the calculator, and then have the About box open with them (the about box is a dialog box also, and isn't really a child window, but its parent is the calculator. It shows up on the same level as the calculator in SpyXX) it works fine. But it wont work with outlook, and its driving me crazy.

    anyone run into any similiar problems, have any suggestions, or know how to do this without getwindow/findwindow?

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898
    Not Much help, But look on Microsofts web site. There is an API called somthing like GetChildWindow that may do what you want. It does not appear in the standard VB API Viewer.

    It may be worth going to the http://www.themandelbrotset.co.uk Ether that or its a .com. and download the stuff they have for the API since I think that may have the above api in it.

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Have you tried using the following function:

    HWND FindWindowEx(
    HWND hwndParent, // handle to parent window
    HWND hwndChildAfter, // handle to a child window
    LPCTSTR lpszClass, // pointer to class name
    LPCTSTR lpszWindow // pointer to window name
    );


    FindwindowEx if you pass the handle of the outlook window as hwndparent it will start looking at that level, and recurse all child windows, i guess if you pass "Edit" as lpszClass and VbNullString as the windowname then you may find it.

    hope this helps
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Heres a sample, once you have found the handle to the main outlook window, pass it to this function to get the handle of the first edit control "under" the parent window:

    Code:
    'paste into a module
    Option Explicit
    Public Const API_TRUE As Long = 1&
    Public Const API_FALSE As Long = 0&
    Public Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
    
    Public Declare Function FindWindowEx& Lib "user32" Alias "FindWindowExA" (ByVal hWndParent&, _
                                  ByVal hWndChildAfter&, ByVal lpClassName$, ByVal lpWindowName$)
    
    Public Function ChildWindow(m_hwnd As Long) As Long
    Dim hButton1&
    hButton1 = FindWindowEx(m_hwnd, API_FALSE, "Edit", vbNullString)
    If hButton1 Then
        ChildWindow = hButton1
    Else
        ChildWindow = -1
    End If
    End Function
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

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