CCmdTarget::OnCmdMsg

경로 및 명령 메시지를 발송 하 고 처리 명령 사용자 인터페이스 개체 업데이트 프레임 워크에서 호출 됩니다.

virtual BOOL OnCmdMsg(
   UINT nID,
   int nCode,
   void* pExtra,
   AFX_CMDHANDLERINFO* pHandlerInfo 
);

매개 변수

  • nID
    명령 ID를 포함합니다.

  • nCode
    알림 명령 코드를 식별합니다.참조 비고 값에 대 한 자세한 내용은 nCode.

  • pExtra
    값에 따라 사용 nCode.참조 비고 에 대 한 자세한 내용은 pExtra.

  • pHandlerInfo
    그렇지 않으면 NULL, OnCmdMsgpTargetpmf 의 멤버는 pHandlerInfo 명령을 전달 하는 대신 구조.일반적으로이 매개 변수를 해야 NULL.

반환 값

메시지를 처리 하는 경우에 0이 아닌. 그렇지 않으면 0입니다.

설명

이 명령은 아키텍처 프레임 워크의 기본 구현 루틴입니다.

실행 시 OnCmdMsg 명령을 다른 개체를 전달 하거나 루트 클래스를 호출 하 여 처리 하는 명령을 CCmdTarget::OnCmdMsg, 어떤 실제 메시지 맵 조회 하지.전체 설명에 대 한 기본 명령 라우팅을 참조 하십시오. 메시지를 처리 하 고 매핑 항목.

프레임 워크의 확장 하려면이 멤버 함수를 재정의 하려고 가끔 표준 명령 라우팅.참조 기술 참고 21 명령 라우팅 아키텍처의 고급 정보에 대 한.

재정의할 경우 OnCmdMsg, 적절 한 값을 제공 해야 nCode, 명령 알림 코드 및 pExtra, 종속 값에는 nCode.다음 표에서 해당 값을 나열합니다.

nCode 값

pExtra 값

CN_COMMAND

CCmdUI*

CN_EVENT

AFX_EVENT *

CN_UPDATE_COMMAND_UI

CCmdUI *

CN_OLECOMMAND

COleCmdUI*

CN_OLE_UNREGISTER

NULL

예제

// This example illustrates extending the framework's standard command 
// route from the view to objects managed by the view.  This example
// is from an object-oriented drawing application, similar to the
// DRAWCLI sample application, which draws and edits "shapes".
BOOL CMyView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
   // Extend the framework's command route from the view to
   // the application-specific CMyShape that is currently selected
   // in the view. m_pActiveShape is NULL if no shape object
   // is currently selected in the view.
   if ((m_pActiveShape != NULL)
      && m_pActiveShape->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
      return TRUE;

   // If the object(s) in the extended command route don't handle
   // the command, then let the base class OnCmdMsg handle it.
   return CView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
// The command handler for ID_SHAPE_COLOR (menu command to change
// the color of the currently selected shape) was added to the message
// map of CMyShape (note, not CMyView) using the Properties window.  
// The menu item will be automatically enabled or disabled, depending 
// on whether a CMyShape is currently selected in the view, that is, 
// depending on whether CMyView::m_pActiveView is NULL.  It is not 
// necessary to implement an ON_UPDATE_COMMAND_UI handler to enable 
// or disable the menu item.  
BEGIN_MESSAGE_MAP(CMyShape, CCmdTarget)
   ON_COMMAND(ID_SHAPE_COLOR, &CMyShape::OnShapeColor)
END_MESSAGE_MAP()

요구 사항

헤더: afxwin.h

참고 항목

참조

CCmdTarget 클래스

계층 구조 차트

CCmdUI 클래스

COleCmdUI 클래스