Wm_mdigetactive??

This is a discussion on Wm_mdigetactive?? within the Windows Programming forums, part of the Platform Specific Boards category; Hi: I have a problem like this: In MDI, there are several Child windows, they are opened when frame window ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    173

    Wm_mdigetactive??

    Hi:

    I have a problem like this:

    In MDI, there are several Child windows, they are opened when frame window created...

    Code:
    ....WinProc() //frame window proc...
    char szBuf[20]; // to hold activated child window name.
    HWND hwndChild;
    
    
    in message handler, 
    switch (mMsg)
    {
    .......
    
    default:
    
    // get the active child window handle
    hwndChild = (HWND)SendMessage (hwndClient,     MDIGETACTIVE, 0, 0);
    
    //get the active child window title name
    GetW indowText(hwndChild,szBuf,20);
    
    //display the title name
    MessageBox(0,szBuf,"window title",MB_OK);
    it pops up the message only when I click the submenu item, but it always give the previous active child window title name... I don't how to solve that...

    And how can I get the active child window name only by clicking the child window, not from submenu item??
    Thanks





    I want to get the active Child window's title name when I simply click one child window,
    Don't laugh at me,I am just a SuperNewbie.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    Your code is probably running before the child window becomes active. That's why you're getting the "previous" active child.

    Try running your code after DefWindowProc().

    gg

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    132
    You could also try to place your code above the switch(Msg) line thus you always get the active window, however, this leads to other problems incase you receive a WM_SETFOCUS or WM_KILLFOCUS message in which case your "active window" code would be wrong.

    Why not just inside of a WM_KILLFOCUS message, wParam holds the handle to the window receiving the focus. Thus just set it as so...

    Code:
    case WM_KILLFOCUS:
            hActiveWnd = (HWND)wParam;
            // other code here
            return(DefMDIWndProc(hwnd, Msg, wParam, lParam);
            break;
    that way you always get the active window, and you don't have to reset a variable (even when not needed) everytime a message comes in?

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21