Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » NM_CLICK sent twice in CExtControlBar and CFrameWnd. Collapse All
Subject Author Date
Eric Houvenaghel Dec 8, 2006 - 11:09 AM

Hello, I created a new single document view application using the Prof UIS AppWizzard.
The application contains a CTreeCtrl inside a CExtControlBar inside the CFrameWnd.
In the tree control I have the following:

ON_NOTIFY_REFLECT_EX(NM_CLICK, OnClick)

My problem is that both the CExtControlBar and the CFrameWnd are sending the NM_CLICK notification.
I am therefore receiving two mouse click messages instead of one in my tree control.
The only fix I’ve been able to find is blocking the NM_CLICK notification in CFrameWnd.
Like this:

LRESULT MainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {

    if(message == WM_NOTIFY) {

        LPNMHDR pnmh = (LPNMHDR)lParam;
        if(pnmh->code == NM_CLICK) {

            return 0;
        }
    }

    return CExtNCW< CFrameWnd >::WindowProc(message, wParam, lParam);
}

I don’t really like this fix.
Do you know if there’s a better way to stop the message from being sent twice?
Thank you.

Technical Support Dec 10, 2006 - 12:11 PM

There are no classes in Prof-UIS which send the WM_NOTIFY message including NM_CLICK sent implicitly via WM_NOTIFY. So we need more details about the UI design implemented in your project. We should know the exact window hierarchy in your application to come to any conclusion about message routes.

Generally speaking, if you are facing any complexity in handling similar messages from several controls, then you can implement your own classes and handle standard Windows messages in them instead. You could use a CTreeCtrl-derived class, handle the WM_LBUTTONDOWN/WM_RBUTTONDOWN standard Windows messages in it, perform tree item hit testing and analyze which actions should be executed.

If you have a CTreeCtrl window inside a CExtControlBar window, then all the NM_*** notifications will be sent to the CExtControlBar window. I.e. only the control bar will receive the WM_NOTIFY messages from the tree control and never from the frame window. Typically, there must always be some some middle window(s) between common controls and the main frame window. The main frame window should never receive the WM_NOTIFY messages. The only exception is the SDI application where a child view class is based on a common control like a tree view or a list view. In this case you could code a child view window based on the generic CWnd window or dialog and create a tree control inside it.