When do you use ON_COMMAND and when do we use ON_MESSAGE. What are the differences between them.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
ON_COMMAND
is specifically used to handle a command message (i.e.WM_COMMAND
) like the click of a button/menu item/toolbar button.ON_MESSAGE
is more generic and can be used for any windows message. It is usually used for less frequently handled messages for which specific message map macros have not been provided. You can useON_MESSAGE
to handleON_COMMAND
messages as well but you will have to extract message information (i.e. command ID) yourself.Example:
See here:
In the message map:
The handler:
Disclaimer: Owing to MFC's message pump mechanism, you may have to do a bit more than what's shown above. The best man to ask: Jeff Prosise