Skip to content

Latest commit

 

History

History
84 lines (66 loc) · 2.99 KB

File metadata and controls

84 lines (66 loc) · 2.99 KB
title ICommandTarget Interface | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-windows
ms.tgt_pltfrm
ms.topic reference
f1_keywords
ICommandTarget
AFXWINFORMS/ICommandTarget
AFXWINFORMS/ICommandTarget::Initialize
dev_langs
C++
helpviewer_keywords
ICommandTarget interface
ms.assetid dd9927f6-3479-4e7c-8ef9-13206cf901f3
caps.latest.revision 27
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

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