Thread: WM_NOTIFY And My Control

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273

    WM_NOTIFY And My Control

    Hello,

    I'm just trying to work out how to send a parent window of my control a message to notify it that the selection in my window has changed. Reading up on the WM_NOTIFY message, it appears to be designed for telling parents about things (the common controls use it), but given that it seems that the following style of handler has been widely advocated:-
    Code:
    case WM_NOTIFY:
    {
        // handle based on notification code
        switch (((LPNMHDR)lParam)->code)
        {
            // ...
        }
    
        break;
    }
    And also that there is no way to ensure that your control's notification codes are unique constants, how can I get round this? Should I advocate a different style in the documentation for the control, like...:-
    Code:
    case WM_NOTIFY:
    {
        LPNMHDR lpNmHdr = (LPNMHDR)lParam;
        TCHAR szClassName[MAX_PATH];
    
        // handle based on class of notifying window first
        GetClassName(lpNmHdr->hwndFrom, szClassName, MAX_PATH);
        if (!lstrcmp(szClassName, "SysListView32"))
        {
            switch (lpNmHdr->code)
            {
                // ...
            }
    
        }
    
        break;
    }

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    WM_COMMAND and WM_PARENTNOTIFY are other messages used by child windows to communicate with parents.

    To ensure a unique, application defined message, define it based on WM_USER or WM_APP.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed