📄 ngcmdtargetlist.cpp
字号:
////////////////////////////////////////////////////////////////
// CCmdTargetList Copyright 1999 by Anna-Jayne Metcalfe (code@annasplace.me.uk)
//
// CmdTargetList.cpp : implementation file
//
#include "stdafx.h"
#include "NGCmdTargetList.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNGCmdTargetList class
CNGCmdTargetList::CNGCmdTargetList(void)
{
}
CNGCmdTargetList::~CNGCmdTargetList(void)
{
}
/******************************************************************************
* Add a command target
*
******************************************************************************/
BOOL CNGCmdTargetList::Add(CCmdTarget* pTarget)
{
ASSERT_VALID(pTarget);
BOOL bResult = FALSE;
if (NULL != pTarget)
{
ASSERT_KINDOF(CCmdTarget, pTarget);
if (pTarget->IsKindOf(RUNTIME_CLASS(CCmdTarget)))
{
POSITION pos = m_listCmdTargets.Find(pTarget);
if (NULL == pos)
{
m_listCmdTargets.AddTail(pTarget);
bResult = TRUE;
}
}
}
return bResult;
}
/******************************************************************************
* Remove a command target
*
******************************************************************************/
BOOL CNGCmdTargetList::Remove(CCmdTarget* pTarget)
{
ASSERT_VALID(pTarget);
BOOL bResult = FALSE;
if (NULL != pTarget)
{
ASSERT_KINDOF(CCmdTarget, pTarget);
if (pTarget->IsKindOf(RUNTIME_CLASS(CCmdTarget)))
{
POSITION pos = m_listCmdTargets.Find(pTarget);
if (NULL != pos)
{
m_listCmdTargets.RemoveAt(pos);
bResult = TRUE;
}
}
}
return bResult;
}
/******************************************************************************
* Remove ALL command targets
*
******************************************************************************/
BOOL CNGCmdTargetList::RemoveAll(void)
{
BOOL bResult = !m_listCmdTargets.IsEmpty();
m_listCmdTargets.RemoveAll();
return bResult;
}
/******************************************************************************
* Handle all messages
*
******************************************************************************/
BOOL CNGCmdTargetList::OnCmdMsg(UINT uID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// See if any of our registered targets wants to handle it
POSITION pos = m_listCmdTargets.GetHeadPosition();
while (NULL != pos)
{
CCmdTarget* pTarget = m_listCmdTargets.GetNext(pos);
if ( (NULL != pTarget) && (pTarget->OnCmdMsg(uID, nCode, pExtra, pHandlerInfo)) )
{
return TRUE; // Stop routing once message has been handled
}
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -