description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||
---|---|---|---|---|---|---|---|---|---|
Learn more about: ICommandTarget Interface |
ICommandTarget Interface |
11/04/2016 |
|
|
dd9927f6-3479-4e7c-8ef9-13206cf901f3 |
Provides a user control with an interface to receive commands from a command source object.
interface class ICommandTarget
Name | Description |
---|---|
ICommandTarget::Initialize | Initializes the command target object. |
When you host a user control in an MFC View, CWinFormsView 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
, 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)
Initializes the command target object.
void Initialize(ICommandSource^ cmdSource);
cmdSource
A handle to the command source object.
When you host a user control in an MFC View, CWinFormsView routes commands and update command UI messages to the user control to allow it to handle MFC commands.
This method initializes the command target object and associates it with the specified command source object cmdSource. It should be called in the user control class implementation. At initialization, you should register command handlers with the command source object by calling ICommandSource::AddCommandHandler in the Initialize implementation. See How to: Add Command Routing to the Windows Forms Control for an example of how to use Initialize to do this.
How to: Add Command Routing to the Windows Forms Control
ICommandSource Interface