description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: ICommandSource Interface |
ICommandSource Interface |
03/27/2019 |
|
|
a4b1f698-c09f-4ba8-9b13-0e74a0a4967e |
Manages commands sent from a command source object to a user control.
interface class ICommandSource
Name | Description |
---|---|
ICommandSource::AddCommandHandler | Adds a command handler to a command source object. |
ICommandSource::AddCommandRangeHandler | Adds a group of command handlers to a command source object. |
ICommandSource::AddCommandRangeUIHandler | Adds a group of user interface command message handlers to a command source object. |
ICommandSource::AddCommandUIHandler | Adds a user interface command message handler to a command source object. |
ICommandSource::PostCommand | Posts a message without waiting for it to be processed. |
ICommandSource::RemoveCommandHandler | Removes a command handler from a command source object. |
ICommandSource::RemoveCommandRangeHandler | Removes a group of command handlers from a command source object. |
ICommandSource::RemoveCommandRangeUIHandler | Removes a group of user interface command message handlers from a command source object. |
ICommandSource::RemoveCommandUIHandler | Removes a user interface command message handler from a command source object. |
ICommandSource::SendCommand | Sends a message and waits for it to be processed before returning. |
When you host a user control in an MFC View, CWinFormsView Class routes commands and update command UI messages to the user control to allow it to handle MFC commands (for example, frame menu items and toolbar buttons). By implementing ICommandTarget Interface, you give the user control a reference to the ICommandSource
object.
See How to: Add Command Routing to the Windows Forms Control for an example of how to use ICommandTarget
.
For more information on using Windows Forms, see Using a Windows Form User Control in MFC.
Header: afxwinforms.h (defined in assembly atlmfc\lib\mfcmifc80.dll)
Adds a command handler to a command source object.
void AddCommandHandler(
unsigned int cmdID,
CommandHandler^ cmdHandler);
cmdID
The command ID.
cmdHandler
A handle to the command handler method.
This method adds the command handler cmdHandler to the command source object and maps the handler to cmdID. See How to: Add Command Routing to the Windows Forms Control for an example of how to use AddCommandHandler.
Adds a group of command handlers to a command source object.
void AddCommandRangeHandler(
unsigned int cmdIDMin,
unsigned int cmdIDMax,
CommandHandler^ cmdHandler);
cmdIDMin
The beginning index of the command ID range.
cmdIDMax
The ending index of the command ID range.
cmdHandler
A handle to the message handler method to which the commands are mapped.
This method maps a contiguous range of command IDs to a single message handler and adds it to the command source object. This is used for handling a group of related buttons with one method.
Adds a group of user interface command message handlers to a command source object.
void AddCommandRangeUIHandler(
unsigned int cmdIDMin,
unsigned int cmdIDMax,
CommandUIHandler^ cmdUIHandler);
cmdIDMin
The beginning index of the command ID range.
cmdIDMax
The ending index of the command ID range.
cmdHandler
A handle to the message handler method to which the commands are mapped.
This method maps a contiguous range of command IDs to a single user interface command message handler and adds it to the command source object. This is used for handling a group of related buttons with one method.
Adds a user interface command message handler to a command source object.
void AddCommandUIHandler(
unsigned int cmdID,
CommandUIHandler^ cmdUIHandler);
cmdID
The command ID.
cmdUIHandler
A handle to the user interface command message handler method.
This method adds the user interface command message handler cmdHandler to the command source object and maps the handler to cmdID.
Posts a message without waiting for it to be processed.
void PostCommand(unsigned int command);
command
The command ID of the message to be posted.
This method asynchronously posts the message mapped to the ID specified by command. It calls CWnd::PostMessage to place the message in the window's message queue and then returns without waiting for the corresponding window to process the message.
Removes a command handler from a command source object.
void RemoveCommandHandler(unsigned int cmdID);
cmdID
The command ID.
This method removes the command handler mapped to cmdID from the command source object.
Removes a group of command handlers from a command source object.
void RemoveCommandRangeUIHandler(
unsigned int cmdIDMin,
unsigned int cmdIDMax);
cmdIDMin
The beginning index of the command ID range.
cmdIDMax
The ending index of the command ID range.
This method removes a group of message handlers, mapped to the command IDs specified by cmdIDMin and cmdIDMax, from the command source object.
Removes a group of user interface command message handlers from a command source object.
void RemoveCommandRangeUIHandler(
unsigned int cmdIDMin,
unsigned int cmdIDMax);
cmdIDMin
The beginning index of the command ID range.
cmdIDMax
The ending index of the command ID range.
This method removes a group of user interface command message handlers, mapped to the command IDs specified by cmdIDMin and cmdIDMax, from the command source object.
Removes a user interface command message handler from a command source object.
void RemoveCommandUIHandler(unsigned int cmdID);
cmdID
The command ID.
This method removes the user interface command message handler mapped to cmdID from the command source object.
Sends a message and waits for it to be processed before returning.
void SendCommand(unsigned int command);
command
The command ID of the message to be sent.
This method synchronously sends the message mapped to the ID specified by command. It calls CWnd::SendMessage to place the message in the window's message queue and waits until that window procedure has processed the message before returning.
How to: Add Command Routing to the Windows Forms Control
ICommandTarget Interface