ICommandTarget Interface

Provides a user control with an interface to receive commands from a command source object.

Syntax

interface class ICommandTarget

Members

Public Methods

Name Description
ICommandTarget::Initialize Initializes the command target object.

Remarks

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.

Requirements

Header: afxwinforms.h (defined in assembly atlmfc\lib\mfcmifc80.dll)

ICommandTarget::Initialize

Initializes the command target object.

void Initialize(ICommandSource^ cmdSource);

Parameters

cmdSource
A handle to the command source object.

Remarks

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.

See also

How to: Add Command Routing to the Windows Forms Control
ICommandSource Interface