Click here to Skip to main content
Click here to Skip to main content

A note about using control notification messages in MFC classes

, 1 Jul 2002
Rate this:
Please Sign up or sign in to vote.
How your control can eat its parent's messages.
<!-- Add the rest of your HTML here -->


Suppose we have a combobox-based control created in the usual manner (see or many others similar CodeProject articles). This control is used in a dialog and is notified about the control's activities using the common notify-message mapping


All is fine until the moment the control requires notification as well. Without any problems we can map the new functionality and all works well:


From the user's view selecting a new combo item changes the actual value but after clicking OK the new values were not used. What's going on?

The problem is with recognizing the changes made. Because we are using ON_CONTROL_REFLECT the dialog's OnSelchangeCombo is not being called.

Of course it is not system bug but documented behaviour - see MSDN TN062: Message Reflection for Windows Controls - and a solution is easy: Instead of using ON_NOTIFY_REFLECT() use ON_NOTIFY_REFLECT_EX() or provide a more general handler. For example:

BOOL CMyComboBox::OnChildNotify(UINT message, WPARAM wParam, 
                                LPARAM lParam, LRESULT* pLResult) 
    if(message == WM_COMMAND)
        int wNotifyCode = HIWORD(wParam);
        int wID = LOWORD(wParam); 
        HWND hwndCtl = (HWND) lParam;

        case CBN_SELCHANGE:
            //original OnSelchange code call 
    return CComboBox::OnChildNotify(message, wParam, lParam, pLResult);

Hopefully reading this will help you avoid similar cases.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Tibor Blazko
Software Developer (Senior)
Slovakia Slovakia
No Biography provided

Comments and Discussions

GeneralUse ON_CONTROL_REFLECT_EX instead PinmemberDiWa1-Jul-02 22:34 
GeneralRe: Use ON_CONTROL_REFLECT_EX instead PinmemberDieter Hammer7-Jul-04 2:16 
Sorry may be my English isn't perfect and I don't understand TNs, TN062 says "TRUE" makes the parent handle the message. But fact is: DiWa is right, "FALSE" is the way to keep a dialog running, when replacing a standard-control by a derived one.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 2 Jul 2002
Article Copyright 2002 by Tibor Blazko
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid