⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bcgpframeimpl.cpp

📁 远程网络监视程序的源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		{
			CBCGPToolbarMenuButton* pParentButton = pMenu->GetParentButton ();
			if (pParentButton == NULL)
			{
				break;
			}
		
			pTopLevelBar = 
				DYNAMIC_DOWNCAST (CBCGPBaseControlBar, pParentButton->GetParentWnd ());
		}

		if (pTopLevelBar != NULL && 
			!pTopLevelBar->IsKindOf (RUNTIME_CLASS (CBCGPPopupMenuBar)))
		{
			ASSERT_VALID (pTopLevelBar);

			if (pTopLevelBar->IsDocked () &&
				::GetFocus () != pTopLevelBar->GetSafeHwnd () &&
				CBCGPPopupMenu::GetForceMenuFocus ())
			{
				pTopLevelBar->SetFocus ();
			}
		}
	}

	return TRUE;
}
//****************************************************************************************
void CBCGPFrameImpl::SetupToolbarMenu (CMenu& menu, 
									  const UINT uiViewUserToolbarCmdFirst,
									  const UINT uiViewUserToolbarCmdLast)
{
	//---------------------------------------------------------------
	// Replace toolbar dummy items to the user-defined toolbar names:
	//---------------------------------------------------------------
	for (int i = 0; i < (int) menu.GetMenuItemCount ();)
	{
		UINT uiCmd = menu.GetMenuItemID (i);

		if (uiCmd >= uiViewUserToolbarCmdFirst && 
			uiCmd <= uiViewUserToolbarCmdLast)
		{
			//-------------------------------------------------------------------
			// "User toolbar" item. First check that toolbar number 'x' is exist:
			//-------------------------------------------------------------------
			CBCGPToolBar* pToolBar = GetUserBarByIndex (uiCmd - uiViewUserToolbarCmdFirst);
			if (pToolBar != NULL)
			{
				ASSERT_VALID (pToolBar);

				//-----------------------------------------------------------
				// Modify the current menu item text to the toolbar title and
				// move next:
				//-----------------------------------------------------------
				CString strToolbarName;
				pToolBar->GetWindowText (strToolbarName);

				menu.ModifyMenu (i ++, MF_BYPOSITION | MF_STRING, uiCmd, strToolbarName);
			}
			else
			{
				menu.DeleteMenu (i, MF_BYPOSITION);
			}
		}
		else	// Not "user toolbar" item, move next
		{
			i ++;
		}
	}
}
//********************************************************************************
BOOL CBCGPFrameImpl::OnMenuChar (UINT nChar)
{
	ASSERT_VALID (m_pFrame);

	BOOL bInPrintPreview = 
		m_pDockManager != NULL && m_pDockManager->IsPrintPreviewValid ();

	if (!bInPrintPreview)
	{
		if (m_pMenuBar != NULL &&
			(m_pMenuBar->GetStyle () & WS_VISIBLE) &&
			m_pMenuBar->TranslateChar (nChar))
		{
			return TRUE;
		}
	}

	for (POSITION posTlb = gAllToolbars.GetHeadPosition (); posTlb != NULL;)
	{
		CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (posTlb);
		ASSERT (pToolBar != NULL);

		if (bInPrintPreview && !pToolBar->IsKindOf (RUNTIME_CLASS (CBCGPPrintPreviewToolBar)))
		{
			continue;
		}

		if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL &&
			pToolBar != m_pMenuBar &&
			(pToolBar->GetStyle () & WS_VISIBLE) &&
			pToolBar->GetTopLevelFrame () == m_pFrame &&
			pToolBar->TranslateChar (nChar))
		{
			return TRUE;
		}
	}

	return FALSE;
}
//************************************************************************************
void CBCGPFrameImpl::SaveDockState (LPCTSTR lpszSectionName)
{
	if (m_pDockManager != NULL)
	{
		m_pDockManager->SaveState (lpszSectionName, m_nIDDefaultResource);
	}
}
//************************************************************************************
void CBCGPFrameImpl::LoadDockState (LPCTSTR lpszSectionName)
{
	if (m_pDockManager != NULL && m_bLoadDockState)
	{
		m_pDockManager->LoadState (lpszSectionName, m_nIDDefaultResource);
	}
}

//************************************************************************************
void CBCGPFrameImpl::SetDockState(const CDockState& state)
{
	ASSERT_VALID (m_pFrame);
	ASSERT_VALID (m_pDockManager);

	if (m_pDockManager != NULL)
	{
		m_pDockManager->SetDockState ();
	}
}
//**************************************************************************************
BOOL CBCGPFrameImpl::IsHelpKey (LPMSG lpMsg)
{
	return lpMsg->message == WM_KEYDOWN &&
		   lpMsg->wParam == VK_F1 &&
		   !(HIWORD(lpMsg->lParam) & KF_REPEAT) &&
		   GetKeyState(VK_SHIFT) >= 0 &&
		   GetKeyState(VK_CONTROL) >= 0 &&
		   GetKeyState(VK_MENU) >= 0;
}
//***************************************************************************************
void CBCGPFrameImpl::DeactivateMenu ()
{
	if (!CBCGPToolBar::IsCustomizeMode () &&
		CBCGPPopupMenu::m_pActivePopupMenu != NULL)
	{
		if (m_pMenuBar != NULL)
		{
			m_pMenuBar->Deactivate ();
		}
	}
}
//***************************************************************************************
BOOL CBCGPFrameImpl::LoadLargeIconsState ()
{
	if (g_pWorkspace != NULL)
	{
		return CBCGPToolBar::LoadLargeIconsState (g_pWorkspace->GetRegSectionPath ());
	}
	else
	{
		return FALSE;
	}
}
//*********************************************************************************
void CBCGPFrameImpl::ShowQuickCustomizePane(CBCGPPopupMenu* pMenuPopup)
{
	//---------------------------
	// Get Actual toolbar pointer
	//---------------------------
	CBCGPToolBar* pWndParentToolbar = NULL;

	CBCGPPopupMenu* pPopupLevel2 = pMenuPopup->GetParentPopupMenu();
	if (pPopupLevel2 == NULL)
	{
		return;
	}
	
	CBCGPPopupMenu* pPopupLevel1 = pPopupLevel2->GetParentPopupMenu();
	if (pPopupLevel1 == NULL)
	{
		return;
	}

	CCustomizeButton* pCustom = (CCustomizeButton*)pPopupLevel1->GetParentButton();
	if (pCustom == NULL)
	{
		//May be MiniFrameWnd
		CWnd* pFrame = pPopupLevel1->GetOwner();
		if (pFrame == NULL)
		{
			return;
		}

		if (pFrame->IsKindOf(RUNTIME_CLASS(CBCGPMiniFrameWnd)))
		{
			CBCGPMiniFrameWnd* pMinFrm = (CBCGPMiniFrameWnd*)pFrame;

			pWndParentToolbar = (CBCGPToolBar*)pMinFrm->GetControlBar();

		}else
		{
			 return;
		}
	}
	else
	{
		if (!pCustom->IsKindOf(RUNTIME_CLASS(CCustomizeButton)))
		{
			return;
		}

		CBCGPToolBar* pCurrentToolBar = pCustom->GetParentToolbar ();

		CBCGPToolbarMenuButton* btnDummy = pMenuPopup->GetMenuItem (0);
		int nID = _ttoi (btnDummy->m_strText);

		const CObList& gAllToolbars = CBCGPToolBar::GetAllToolbars ();
	
		CBCGPToolBar* pRealToolBar = NULL;
		for (POSITION pos = gAllToolbars.GetHeadPosition (); pos != NULL;)
		{
			pRealToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (pos);
			ASSERT (pRealToolBar != NULL);
			if (nID == pRealToolBar->GetDlgCtrlID ())
			{
				break;
			}
			
			pRealToolBar = NULL;
		}

		if (pRealToolBar == NULL)
		{
			pWndParentToolbar = pCurrentToolBar;
		}
		else
		{
			pWndParentToolbar = pRealToolBar;
		}
	}

	pMenuPopup->RemoveAllItems ();

	CBCGPToolbarCustomize* pStdCust = new CBCGPToolbarCustomize(
											m_pFrame,
											TRUE,
											BCGCUSTOMIZE_MENUAMPERS);

	CBCGPCustomizeMenuButton::SetParentToolbar(pWndParentToolbar);

	//--------------------------
	// Populate pop-up menu
	//-------------------------
	UINT uiRealCount = 0;
	CBCGPCustomizeMenuButton::m_mapPresentIDs.RemoveAll();

	UINT uiCount = pWndParentToolbar->GetCount();
	for (UINT i=0; i< uiCount; i++)
	{
		CBCGPToolbarButton* pBtn = pWndParentToolbar->GetButton(i);

		if (pBtn->IsKindOf(RUNTIME_CLASS(CCustomizeButton)) || (pBtn->m_nStyle & TBBS_SEPARATOR))
		{
			continue;
		}

		CBCGPCustomizeMenuButton::m_mapPresentIDs.SetAt(pBtn->m_nID, 0);

		//---------------------------
		//Find Command Text if empty
		//---------------------------
		CString strText = pBtn->m_strText;
		if (pBtn->m_strText.IsEmpty())
		{
			strText = pStdCust->GetCommandName(pBtn->m_nID);
		}

		UINT uiID = pBtn->m_nID;
		if ((pBtn->m_nID == 0) || (pBtn->m_nID == -1))
		{
			uiID = BCGPCUSTOMIZE_INTERNAL_ID;
		}

		if (pBtn->IsKindOf(RUNTIME_CLASS(CBCGPToolbarMenuButton)))
		{
			uiID = BCGPCUSTOMIZE_INTERNAL_ID;
		}

		CBCGPCustomizeMenuButton button(uiID, NULL, pBtn->GetImage(), strText, pBtn->m_bUserButton);
		button.SetItemIndex(i);
		pMenuPopup->InsertItem(button);

		uiRealCount++;
	}

	delete pStdCust;

	pMenuPopup->SetQuickCustomizeType(CBCGPPopupMenu::QUICK_CUSTOMIZE_PANE);

	//------------------------------------------
	//Give User ability to customize pane
	//-----------------------------------------
	OnShowCustomizePane(pMenuPopup, pWndParentToolbar->GetResourceID());

	if (uiRealCount > 0)
	{
		pMenuPopup->InsertSeparator();
	}

	//--------------------------
	// Add Reset Toolbar Button
	//--------------------------
	CString strCommand;

	{
		CBCGPLocalResource locaRes;
		strCommand.LoadString (IDS_BCGBARRES_RESET_TOOLBAR);
	}

	CBCGPCustomizeMenuButton btnReset (BCGPCUSTOMIZE_INTERNAL_ID, NULL, -1, strCommand, FALSE);
	btnReset.SetItemIndex(ID_BCGBARRES_TOOLBAR_RESET_PROMT);

	pMenuPopup->InsertItem(btnReset);
}
//********************************************************************************
BOOL CBCGPFrameImpl::OnShowCustomizePane(CBCGPPopupMenu* pMenuPane, UINT uiToolbarID)
{
	BOOL bResult = FALSE;

	CBCGPMDIFrameWnd* pMainFrame =
				DYNAMIC_DOWNCAST (CBCGPMDIFrameWnd, m_pFrame);

	if (pMainFrame != NULL)
	{
		bResult = pMainFrame->OnShowCustomizePane(pMenuPane, uiToolbarID);
	}
	else	// Maybe, SDI frame...
	{
		CBCGPFrameWnd* pFrame = DYNAMIC_DOWNCAST (CBCGPFrameWnd, m_pFrame);
		if (pFrame != NULL)
		{
			bResult = pFrame->OnShowCustomizePane(pMenuPane, uiToolbarID);

		}else	// Maybe, OLE frame
		{
			CBCGPOleIPFrameWnd* pOleFrame = 
					DYNAMIC_DOWNCAST (CBCGPOleIPFrameWnd, m_pFrame);
			if (pOleFrame != NULL)
			{
				bResult = pOleFrame->OnShowCustomizePane(pMenuPane, uiToolbarID);
			}
			else
			{
				CBCGPOleDocIPFrameWnd* pOleDocFrame = 
					DYNAMIC_DOWNCAST (CBCGPOleDocIPFrameWnd, m_pFrame);
				if (pOleDocFrame != NULL)
				{
					bResult = pOleDocFrame->OnShowCustomizePane(pMenuPane, uiToolbarID);
				}
			}
		}
	}

	return bResult;
}
//********************************************************************************
void CBCGPFrameImpl::AddDefaultButtonsToCustomizePane(
						CBCGPPopupMenu* pMenuPane, UINT uiToolbarID)
{
	CBCGPToolBar* pWndParentToolbar = CBCGPCustomizeMenuButton::GetParentToolbar();
	
	if (pWndParentToolbar == NULL)
	{
		return;
	}
	
	CBCGPToolbarCustomize* pStdCust = new CBCGPToolbarCustomize(m_pFrame, TRUE, 
		BCGCUSTOMIZE_MENUAMPERS);
	
	const CObList& lstOrigButtons = pWndParentToolbar->GetOrigResetButtons(); 

	int i = 0;
	int nTmp = 0;
	for (POSITION posCurr = lstOrigButtons.GetHeadPosition (); posCurr != NULL; i++)
	{
		CBCGPToolbarButton* pButtonCurr = (CBCGPToolbarButton*)lstOrigButtons.GetNext (posCurr);

		UINT uiID = pButtonCurr->m_nID;

		if ((pButtonCurr == NULL) || 
			(pButtonCurr->m_nStyle & TBBS_SEPARATOR) ||
			(pButtonCurr->IsKindOf(RUNTIME_CLASS(CCustomizeButton))) ||
			 CBCGPCustomizeMenuButton::m_mapPresentIDs.Lookup(uiID, nTmp))
		{
				continue;
		}

		if ((pButtonCurr->m_nID == 0) || (pButtonCurr->m_nID == -1))
		{
			uiID = BCGPCUSTOMIZE_INTERNAL_ID;
		}

		if (pButtonCurr->IsKindOf(RUNTIME_CLASS(CBCGPToolbarMenuButton)))
		{
			uiID = BCGPCUSTOMIZE_INTERNAL_ID;
		}

		CBCGPCustomizeMenuButton button(uiID, NULL, pButtonCurr->GetImage(), 
			pStdCust->GetCommandName(pButtonCurr->m_nID), pButtonCurr->m_bUserButton); 

		button.SetItemIndex(i, FALSE);

		int nIndex = pMenuPane->InsertItem(button, i);
		if (nIndex == -1)
		{
			pMenuPane->InsertItem(button);
		}
	}

	delete pStdCust;
}
//********************************************************************************
BOOL CBCGPFrameImpl::IsCustomizePane(const CBCGPPopupMenu* pMenuPopup) const
{
	CBCGPPopupMenu* pPopupLevel2 = pMenuPopup->GetParentPopupMenu();

	if (pPopupLevel2 == NULL)
	{
		return FALSE;
	}
		
	CBCGPPopupMenu* pPopupLevel1 = pPopupLevel2->GetParentPopupMenu();

	if (pPopupLevel1 == NULL)
	{
		return FALSE;
	}

	if (pPopupLevel1->GetQuickCustomizeType() == CBCGPPopupMenu::QUICK_CUSTOMIZE_ADDREMOVE)
	{
		return TRUE;
	}

	return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -