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

📄 bcgpoutlookbarpane.cpp

📁 远程网络监视程序的源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
			m_btnDown.GetClientRect (rect);
			m_btnDown.MapWindowPoints (this, rect);

			if (rect.PtInRect (ptCursor))
			{
				m_btnDown.SendMessage (pMsg->message, pMsg->wParam, pMsg->wParam);
				if (pMsg->message == WM_LBUTTONDOWN)
				{
					SetTimer (idScrollDn, uiScrollDelay, NULL);

					if(m_bPageScrollMode)
					{
						ScrollPageDown ();

					}else
					{
						ScrollDown ();
					}
				}
			}

			m_btnUp.GetClientRect (rect);
			m_btnUp.MapWindowPoints (this, rect);

			if (rect.PtInRect (ptCursor))
			{
				m_btnUp.SendMessage (pMsg->message, pMsg->wParam, pMsg->wParam);

				if (pMsg->message == WM_LBUTTONDOWN)
				{
					SetTimer (idScrollUp, uiScrollDelay, NULL);

					if(m_bPageScrollMode)
					{
						ScrollPageUp ();

					}else
					{
						ScrollUp ();
					}
				}
			}
		}
		break;
	}

	return CBCGPToolBar::PreTranslateMessage(pMsg);
}
//**************************************************************************************
void CBCGPOutlookBarPane::OnTimer(UINT nIDEvent) 
{
	switch (nIDEvent)
	{
	case idScrollUp:
		if (m_btnUp.IsPressed ())
		{
			if(m_bPageScrollMode)
			{
				ScrollPageUp ();

			}else
			{
				ScrollUp ();
			}
		}
		return;

	case idScrollDn:
		if (m_btnDown.IsPressed ())
		{
			if(m_bPageScrollMode)
			{
				ScrollPageDown ();

			}else
			{
				ScrollDown ();
			}
		}
		return;
	}

	CBCGPToolBar::OnTimer(nIDEvent);
}
//**************************************************************************************
void CBCGPOutlookBarPane::OnLButtonUp(UINT nFlags, CPoint point) 
{
	HWND hWnd = GetSafeHwnd ();
	CBCGPToolBar::OnLButtonUp(nFlags, point);

	if (::IsWindow (hWnd))
	{
		OnMouseLeave (0, 0);
	}
}
//*********************************************************************************
void CBCGPOutlookBarPane::RemoveAllButtons()
{
	CBCGPToolBar::RemoveAllButtons();

	m_iFirstVisibleButton = 0; 
	m_iScrollOffset = 0; 

	AdjustLocations();

	if (m_hWnd != NULL)
	{
		UpdateWindow();
		Invalidate();
	}
}
//*************************************************************************************
void CBCGPOutlookBarPane::ClearAll ()
{
	m_Images.Clear ();
}
//*************************************************************************************
void CBCGPOutlookBarPane::OnEraseWorkArea (CDC* pDC, CRect rectWorkArea)
{
	ASSERT_VALID (pDC);

	if (m_bmpBack.GetCount() == 0)
	{
		pDC->FillSolidRect (rectWorkArea, m_clrBackColor);
	}
	else
	{
		ASSERT (m_bmpBack.GetCount () == 1);

		CBCGPDrawState ds;
		m_bmpBack.PrepareDrawImage (ds);
		CSize sizeBack = m_bmpBack.GetImageSize ();

		for (int x = rectWorkArea.left; x < rectWorkArea.right; x += sizeBack.cx)
		{
			for (int y = rectWorkArea.top; y < rectWorkArea.bottom; y += sizeBack.cy)
			{
				m_bmpBack.Draw (pDC, x, y, 0);
			}
		}

		m_bmpBack.EndDrawImage (ds);
	}
}
//*************************************************************************************
BCGP_CS_STATUS CBCGPOutlookBarPane::IsChangeState (int nOffset, 
												   CBCGPBaseControlBar** ppTargetBar) const
{
	ASSERT_VALID (this);
	ASSERT (ppTargetBar != NULL);

	CPoint	ptMousePos;
	GetCursorPos (&ptMousePos);

	*ppTargetBar = NULL;

	// check whether the mouse is around a dock bar
	CBCGPOutlookBar* pOutlookBar = DYNAMIC_DOWNCAST (CBCGPOutlookBar,
			ControlBarFromPoint (ptMousePos, 0, FALSE, RUNTIME_CLASS (CBCGPOutlookBar))); 

	if (pOutlookBar != NULL)
	{
		*ppTargetBar = pOutlookBar;
		return CS_DOCK_IMMEDIATELY;
	}
	return CS_NOTHING;
}
//*************************************************************************************
BOOL CBCGPOutlookBarPane::Dock (CBCGPBaseControlBar* pDockBar, LPCRECT lpRect, 
								BCGP_DOCK_METHOD dockMethod)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pDockBar);

	CBCGPMiniFrameWnd* pParentMiniFrame = GetParentMiniFrame ();

	CString strText;
	GetWindowText (strText);

	CBCGPOutlookBar* pOutlookBar = NULL;

	if (dockMethod == DM_DBL_CLICK)
	{
		pOutlookBar = DYNAMIC_DOWNCAST (CBCGPOutlookBar, 
										CWnd::FromHandlePermanent (m_hRecentOutlookWnd));
	}
	else if (dockMethod == DM_MOUSE)
	{
		pOutlookBar = DYNAMIC_DOWNCAST (CBCGPOutlookBar, pDockBar);
	}

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

	ASSERT_VALID (pOutlookBar);
	if (pParentMiniFrame != NULL)
	{
		pParentMiniFrame->RemoveControlBar (this);
	}
	
	pOutlookBar->AddTab (this);

	CBCGPBaseTabWnd* pTabWnd = pOutlookBar->GetUnderlinedWindow ();
	ASSERT_VALID (pTabWnd);

	int nAddedTab = pTabWnd->GetTabsNum () - 1;
	pTabWnd->SetTabLabel (nAddedTab, strText);
	pTabWnd->SetActiveTab (nAddedTab); 

	return TRUE;
}
//*************************************************************************************
BOOL CBCGPOutlookBarPane::OnBeforeFloat (CRect& rectFloat, BCGP_DOCK_METHOD dockMethod)
{
	if (dockMethod == DM_MOUSE)
	{
		CPoint ptMouse;
		GetCursorPos (&ptMouse);

		CWnd* pParent = GetParent ();

		// make it float only when the mouse is out of parent bounds
		CRect rect;
		pParent->GetWindowRect (rect);
		BOOL bFloat = !rect.PtInRect (ptMouse);
		if (bFloat)
		{
			if (pParent->IsKindOf (RUNTIME_CLASS (CBCGPOutlookBar)))
			{
				m_hRecentOutlookWnd = pParent->GetSafeHwnd ();
			}
			else
			{
				m_hRecentOutlookWnd = pParent->GetParent ()->GetSafeHwnd ();
			}
		}
		return bFloat;
	}

	return TRUE;
}
//*************************************************************************************
void CBCGPOutlookBarPane::OnSetFocus(CWnd* pOldWnd) 
{
	// bypass the standard toolbar's set focus, because it sets the focus back
	// to old focused wnd
	CBCGPControlBar::OnSetFocus(pOldWnd);
}
//*************************************************************************************
void CBCGPOutlookBarPane::OnNcDestroy() 
{
	CBCGPToolBar::OnNcDestroy();
}
//****************************************************************************************
void CBCGPOutlookBarPane::SetDefaultState ()
{
	CopyButtonsList (m_Buttons, m_OrigButtons);
}
//****************************************************************************************
BOOL CBCGPOutlookBarPane::RestoreOriginalstate ()
{
	if (m_OrigButtons.IsEmpty ())
	{
		return FALSE;
	}

	CopyButtonsList (m_OrigButtons, m_Buttons);

	AdjustLayout ();

	RedrawWindow ();
	return TRUE;
}
//************************************************************************************
BOOL CBCGPOutlookBarPane::SmartUpdate (const CObList& lstPrevButtons)
{
	if (lstPrevButtons.IsEmpty ())
	{
		return FALSE;
	}

	m_bResourceWasChanged = FALSE;	// Outlook bar has its own resources

	BOOL bIsModified = FALSE;

	//-----------------------------------
	// Compare current and prev. buttons:
	//------------------------------------
	if (lstPrevButtons.GetCount () != m_OrigButtons.GetCount ())
	{
		bIsModified = TRUE;
	}
	else
	{
		POSITION posCurr, posPrev;
		for (posCurr = m_OrigButtons.GetHeadPosition (),
			posPrev = lstPrevButtons.GetHeadPosition (); posCurr != NULL;)
		{
			ASSERT (posPrev != NULL);

			CBCGPToolbarButton* pButtonCurr = 
				DYNAMIC_DOWNCAST (CBCGPToolbarButton, m_OrigButtons.GetNext (posCurr));
			ASSERT_VALID (pButtonCurr);

			CBCGPToolbarButton* pButtonPrev = 
				DYNAMIC_DOWNCAST (CBCGPToolbarButton, lstPrevButtons.GetNext (posPrev));
			ASSERT_VALID (pButtonPrev);

			if (!pButtonCurr->CompareWith (*pButtonPrev))
			{
				bIsModified = TRUE;
				break;
			}
		}
	}

	if (bIsModified)
	{
		RestoreOriginalstate ();
	}

	return bIsModified;
}
//************************************************************************************
void CBCGPOutlookBarPane::CopyButtonsList (const CObList& lstSrc, CObList& lstDst)
{
	while (!lstDst.IsEmpty ())
	{
		delete lstDst.RemoveHead ();
	}

	for (POSITION pos = lstSrc.GetHeadPosition (); pos != NULL;)
	{
		CBCGPToolbarButton* pButtonSrc = (CBCGPToolbarButton*) lstSrc.GetNext (pos);
		ASSERT_VALID (pButtonSrc);

		CRuntimeClass* pClass = pButtonSrc->GetRuntimeClass ();
		ASSERT (pClass != NULL);

		CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) pClass->CreateObject ();
		ASSERT_VALID(pButton);

		pButton->CopyFrom (*pButtonSrc);
		pButton->OnChangeParentWnd (this);

		lstDst.AddTail (pButton);
	}
}
//*************************************************************************************
void CBCGPOutlookBarPane::ScrollPageUp ()
{
	if (m_iScrollOffset <= 0 ||
		m_iFirstVisibleButton <= 0)
	{
		m_iScrollOffset = 0;
		m_iFirstVisibleButton = 0;

		KillTimer (idScrollUp);
		return;
	}

	CBCGPToolbarButton* pFirstVisibleButton = GetButton (m_iFirstVisibleButton);
	if (pFirstVisibleButton == NULL)
	{
		KillTimer (idScrollDn);
		return;
	}

	CRect rcArea;
	GetClientRect(rcArea);
	int nVisibleCount = 0;
	
	nVisibleCount = (rcArea.Height())/(pFirstVisibleButton->Rect ().Height () + m_nExtraSpace);

	for(int i=0; i<nVisibleCount; i++)
	{
		 ScrollUp();
	}
	

}
//*************************************************************************************
void CBCGPOutlookBarPane::ScrollPageDown ()
{
	if (!m_bScrollDown ||
		m_iFirstVisibleButton + 1 >= GetCount ())
	{
		KillTimer (idScrollDn);
		return;
	}

	CBCGPToolbarButton* pFirstVisibleButton = GetButton (m_iFirstVisibleButton);
	if (pFirstVisibleButton == NULL)
	{
		KillTimer (idScrollDn);
		return;
	}

	CRect rcArea;
	GetClientRect(rcArea);
	int nVisibleCount = 0;

	
	nVisibleCount = (rcArea.Height())/(pFirstVisibleButton->Rect ().Height () + m_nExtraSpace);

	 for(int i=0; i<nVisibleCount; i++)
	 {
		 ScrollDown();
	 }

}

⌨️ 快捷键说明

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