1. If in my window ther is a ListBox, must I define a ListBox WNDPROC to handle WM_CONTEXTMENU on it? It's not possibile to handle it from my Dialog WNDPROC?
2. I've tested your code in a empty project and it works. But in my existing code I must substitute break with return 1 (also with return 0 it doesn't work) to really hide contextmenu. I'm pretty sure that there isn't another DefWindowProc...
Generally, in a window procedure, DefWindowProc must be called in case of messages not handled by the application to let the system do the default processing.
But, if the window is a DIALOG, its procedure is a little bit different. Typically, the dialog box procedure should return TRUE if it processed the message, and FALSE if it did not. If FALSE is returned, the dialog manager performs the default processing and it's not needed a call to DefWindowProc.
Just a little bit to clarify point #1.
A child control (e.g. a listbox) notifies its parent via WM_CONTEXTMENU. However, if the click is in one of its scrollbars, that doesn't happen.
If we want to get rid of that context menu, we have to subclass the control.
That means, we have to change the control's default procedure with an application-defined one, like in the following example:
Just a little bit to clarify point #1.
A child control (e.g. a listbox) notifies its parent via WM_CONTEXTMENU. However, if the click is in one of its scrollbars, that doesn't happen.
Yes, I've notice this using Spy++ so I had to write a custom ListBox WNDPROC as you have suggest.
Bookmarks