Results 1 to 7 of 7

Thread: Does That MDI form have the focus??

  1. #1
    Guest
    I need to get the handle of an MDI form (child window) that has the focus. When I use the GetForeGroundWindow API, all it does is return the parent window's handle.

    How do I get the handle of the active child window?

    Thanks,
    Jordan

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    If it's a form of your own app, then you can use this code:
    Code:
    Handle = MDIForm1.ActiveForm.hWnd
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Guest
    Sorry, I meant to say that its for another app.
    I haven't found anything yet as to how to get the active child window in an external app.

    Any Ideas?

  4. #4
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    These APIs may be of use to you:

    Declare Function GetParent Lib "user32" Alias "GetParent" (ByVal hwnd As Long) As Long
    parameters:
    · hWnd
    Identifies the window whose parent window handle is to be retrieved.


    Declare Function IsChild Lib "user32" Alias "IsChild" (ByVal hWndParent As Long, ByVal hwnd As Long) As Long
    parameters:
    · hWndParent
    Identifies the parent window.

    · hWnd
    Identifies the window to be tested.

    Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long
    no parameters


    Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

    parameters:
    · hWndParent
    Identifies the parent window whose child windows are to be enumerated.

    · lpEnumFunc
    Points to an application-defined callback function. For more information about the callback function, see the EnumChildProc callback function.

    · lParam
    Specifies a 32-bit, application-defined value to be passed to the callback function.

    See this link for more information on the EnumChildProc callback function.

    [Edited by dsy5 on 10-07-2000 at 05:43 PM]
    Donald Sy - VB (ab)user

  5. #5
    Guest
    Thanks, but I tried GetActiveWindow and it still returns the handle of the Parent window when I need the handle of the active child window. :-\

    Actually, if it helps any, all I really need to know is if the external child window doesn't have the focus. Still haven't been able to figure this one out.

  6. #6
    Guest

    Cool WOOHOO!!

    Nevermind.. I got it

    It turns out that you need to globally subclass the form and watch for WM_MDIACTIVATE message. If the wParam = the handle of your MDI window, then its being deactivated. If the lParam = the handle of your MDI window, then its being activated.

    Thanks for the help though

    -Jordan

  7. #7
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    Could you post a small snippet of the routine to subclass; it could be useful to others(me, too!)
    Donald Sy - VB (ab)user

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