ON_COMMAND_RANGE
ON_COMMAND_RANGE can be used to map a contiguous range of command IDs to a single message handler function.
Syntax
ON_COMMAND_RANGE (id1, id2, memberFxn)
Parameters
- id1 - Command ID at the beginning of a contiguous range of command IDs.
- id2 - Command ID at the end of a contiguous range of command IDs.
- memberFxn - The name of the message-handler function to which the commands are mapped.
ON_CONTROL_RANGE
ON_CONTROL_RANGE macro to map a contiguous range of control IDs to a single message handler function for a specified Windows notification message,
Syntax
ON_CONTROL_RANGE(wNotifyCode, id1, id2, memberFxn )
Parameters
- wNotifyCode - The notification code to which your handler is responding.
- id1 - Command ID at the beginning of a contiguous range of control IDs.
- id2 - Command ID at the end of a contiguous range of control IDs.
- memberFxn - The name of the message-handler function to which the controls are mapped.
Remarks
The range of IDs starts with id1 and ends with id2. The handler is called for the specified notification coming from any of the mapped controls. There is no automatic support for message map ranges, so you must place the macro yourself.
Demo Application
Here is a demo app to show the utility of ON_COMMAND_RANGE(). We are showing a menu based app used for drawing verious shapes. We have taken a range of menu IDs to map to asingle drawing function. We decode the drawing function using the argument ID passed to the command function. We are displaying which id is called with the help of message box.
Output
About our authors: Team EQA
Further readings
Where is WinMain() function in MFC application ?
MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.
What is the utility of CWinApp class?
This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...
Basic steps in Win32 GUI Application with source code.
Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.
What is a Window CallBack procedure and what is its utility?
DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.
What are LPARAM and WPARAM in window proc function?
LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.
What are the basic steps of a typical MFC based application?
We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...