What should be return value for WM_CONTEXTMENU?

Apr 22, 2023 at 12:23pm
I'm handling a WM_CONTEXTMENU to show a pop up menu.

According to docs there is no return value.
Return value
No return value.

https://learn.microsoft.com/en-us/windows/win32/menurc/wm-contextmenu

Instead the docs say this:
If a window does not display a shortcut menu it should pass this message to the DefWindowProc function

Therefor since I'm showing a pop up menu I should not call DefWindowProc, which means I should return a value from handler.
But that's an issue because the docs say there is no return value.

example:
1
2
3
4
5
6
7
8
9
10
case WM_CONTEXTMENU:
     // Show pop up menu
     OnContextMenu(WPARAM wParam, LPARAM lParam);
     return // what?

     // We handled WM_CONTEXTMENU therefore DefWindowProc must not be called
     // But there is no return value

default:
     DefWindowProc (msg, wParam, lParam);

Well I guess we could just return anything, but what is the correct way to handle this event?
Last edited on Apr 22, 2023 at 12:26pm
Apr 22, 2023 at 12:40pm
I think you can simply return 0 😏

BTW: If you call DefWindowProc(), you should return its return value.
Last edited on Apr 22, 2023 at 12:41pm
Apr 22, 2023 at 12:46pm
Yes it seems return value is not important but I'm unable to find some examples to see how others are handling this message.

I know, return DefWindowProc(), thanks for reminder.
Topic archived. No new replies allowed.