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

📄 bcgpslider.cpp

📁 远程网络监视程序的源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		return;
	}

	HDWP hdwp = BeginDeferWindowPos (50);
	if (m_pContainerManager != NULL)
	{
		m_pContainerManager->OnSliderMove (this, 0, nOffset, hdwp);
	}
	EndDeferWindowPos (hdwp);
	
	// it moves the slider
	AdjustDockingLayout ();
	

	GetParent ()->ScreenToClient (rectSlider);
	// move the slider by ourself
	SetWindowPos (NULL, rectSlider.left, rectSlider.top, 
					rectSlider.Width (), rectSlider.Height (), SWP_NOZORDER  | SWP_NOACTIVATE);

	
}
//--------------------------------------------------------------------------//
void CBCGPSlider::AddControlBar  (CBCGPDockingControlBar* pBar)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pBar);
	ASSERT_KINDOF (CBCGPDockingControlBar, pBar);

	m_pContainerManager->AddControlBar (pBar);
	CheckVisibility ();
}
//--------------------------------------------------------------------------//
CBCGPDockingControlBar*  CBCGPSlider::AddRecentControlBar (CBCGPDockingControlBar* pBar)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pBar);
	ASSERT_KINDOF (CBCGPDockingControlBar, pBar);

	CBCGPDockingControlBar* pAddedBar = NULL;
	CBCGPBarContainer* pRecentContainer = pBar->m_recentDockInfo.GetRecentContainer (TRUE);
	CBCGPBarContainer* pRecentTabContainer = pBar->m_recentDockInfo.GetRecentTabContainer (TRUE);
	if (pRecentContainer != NULL)
	{
		pAddedBar = m_pContainerManager->AddControlBarToRecentContainer (pBar, pRecentContainer);
		CheckVisibility ();
	}
	else if (pRecentTabContainer != NULL)
	{
		pAddedBar = m_pContainerManager->AddControlBarToRecentContainer (pBar, pRecentTabContainer);
		CheckVisibility ();
	}
	else
	{
		ASSERT (FALSE);
	}
	return pAddedBar;
}
//--------------------------------------------------------------------------//
BOOL CBCGPSlider::InsertControlBar	(CBCGPDockingControlBar* pBarToInsert, 
									 CBCGPDockingControlBar* pTargetBar, 
									 DWORD dwAlignment, 
									 LPCRECT lpRect)
{
	ASSERT_VALID (this);
	ASSERT_KINDOF (CBCGPDockingControlBar, pBarToInsert);
	ASSERT_KINDOF (CBCGPDockingControlBar, pTargetBar);

	BOOL bResult = FALSE;
	if (m_pContainerManager != NULL)
	{
		bResult = m_pContainerManager->InsertControlBar (pBarToInsert, pTargetBar, 
														dwAlignment, lpRect);
		CheckVisibility ();
	}
	return bResult;
}
//--------------------------------------------------------------------------//
const CBCGPBaseControlBar* CBCGPSlider::GetFirstBar () const
{
	ASSERT_VALID (this);
	if (m_pContainerManager != NULL)
	{
		return m_pContainerManager->GetFirstBar ();
	}
	return NULL;
}
//--------------------------------------------------------------------------//
void CBCGPSlider::RemoveControlBar (CBCGPDockingControlBar* pBar)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pBar);
	ASSERT_KINDOF (CBCGPDockingControlBar, pBar);

	if (m_pContainerManager != NULL)
	{
		// remove the bar from container
		m_pContainerManager->RemoveControlBarFromContainer (pBar);
		// remove the bar from docksite (do not destroy!!!)
		CBCGPBaseControlBar::RemoveControlBarFromDockManager (pBar, FALSE, FALSE, m_bAutoHideMode);
		if (m_pContainerManager->IsEmpty () && 
			m_pContainerManager->GetTotalRefCount () == 0 &&
			pBar->m_recentDockInfo.GetRecentDefaultSlider () != this)
		{
			// it was the last control bar in the container - 
			// remove and DESTROY  the slider as well
			CBCGPBaseControlBar::RemoveControlBarFromDockManager (this, TRUE, FALSE, m_bAutoHideMode);
		}
		else
		{
			if (!CheckVisibility ())
			{
				ShowWindow (SW_HIDE);
			}
		}
	}
}
//--------------------------------------------------------------------------//
BOOL CBCGPSlider::ReplaceControlBar	(CBCGPDockingControlBar* pBarToReplace, 
									 CBCGPDockingControlBar* pBarToReplaceWith)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pBarToReplace);
	ASSERT_VALID (pBarToReplaceWith);
	ASSERT_KINDOF (CBCGPDockingControlBar, pBarToReplaceWith);

	if (m_pContainerManager == NULL)
	{
		ASSERT (FALSE);
		return FALSE;
	}

	pBarToReplaceWith->SetDefaultSlider (m_hWnd);
	
	BOOL bResult = m_pContainerManager->ReplaceControlBar (pBarToReplace, pBarToReplaceWith);
	CheckVisibility ();
	return bResult;
}
//--------------------------------------------------------------------------//
BOOL CBCGPSlider::OnEraseBkgnd(CDC* /*pDC*/) 
{
	return TRUE;
}
//*******************************************************************************
CSize CBCGPSlider::CalcFixedLayout(BOOL /*bStretch*/, BOOL bHorz)
{
	ASSERT_VALID (this);
	CRect rectWnd;
	GetWindowRect (&rectWnd);
	CSize size = rectWnd.Size ();

	CRect rectContainer;
	if (m_pContainerManager != NULL)
	{
		m_pContainerManager->GetWindowRect (rectContainer);
		size += rectContainer.Size ();
	}
	return size;
}
//*******************************************************************************
void CBCGPSlider::RepositionBars	(CRect& rectNew, HDWP& hdwp)
{
	CRect rectWnd;
	GetWindowRect (&rectWnd);

	CRect rectContainer = rectNew; 
	CRect rectNewSlider = rectNew;
	
	DWORD dwAlignment = GetCurrentAlignment ();

	switch (dwAlignment)
	{
	case CBRS_ALIGN_LEFT:
		rectNewSlider.left = rectNew.right - m_nWidth;
		rectContainer.right = rectNewSlider.left;
		rectContainer.top = rectNewSlider.top;
		rectContainer.bottom = rectNewSlider.bottom;
		break;
	case CBRS_ALIGN_RIGHT:
		rectNewSlider.right = rectNew.left + m_nWidth;
		rectContainer.left = rectNewSlider.right;
		rectContainer.top = rectNewSlider.top;
		rectContainer.bottom = rectNewSlider.bottom;
		break;
	case CBRS_ALIGN_TOP:
		rectNewSlider.top = rectNew.bottom - m_nWidth;
		rectContainer.bottom = rectNewSlider.top;
		rectContainer.left = rectNewSlider.left;
		rectContainer.right = rectNewSlider.right;
		break;
	case CBRS_ALIGN_BOTTOM:
		rectNewSlider.bottom = rectNew.top + m_nWidth;
		rectContainer.top = rectNewSlider.bottom;
		rectContainer.left = rectNewSlider.left;
		rectContainer.right = rectNewSlider.right;
		break;
	}

	CWnd* pParentWnd = GetParent ();
	ASSERT_VALID (pParentWnd);

	pParentWnd->ScreenToClient (rectNew);
	pParentWnd->ScreenToClient (rectNewSlider);
	pParentWnd->ScreenToClient (rectContainer);
	hdwp = MoveWindow (rectNewSlider, TRUE, hdwp);

	if (m_pContainerManager != NULL)
	{
		m_pContainerManager->ResizeBarContainers (rectContainer, hdwp);
	}
}
//*******************************************************************************
void CBCGPSlider::OnDestroy() 
{

	CBCGPBaseControlBar::OnDestroy();
}
//*******************************************************************************
void CBCGPSlider::OnNcDestroy() 
{
	if (m_pContainerManager != NULL)
	{
		m_pContainerManager->RemoveSlider (this);
	}

	if (m_pContainerManager != NULL && m_bDefaultSlider)
	{
		delete m_pContainerManager;
		m_pContainerManager = NULL;
	}

	CBCGPBaseControlBar::OnNcDestroy();
	delete this;		
}
//*******************************************************************************
void CBCGPSlider::ShowWindow (int nCmdShow)
{
	CWnd::ShowWindow (nCmdShow);
}
//*******************************************************************************
int CBCGPSlider::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CBCGPBaseControlBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (globalData.m_hcurStretch == NULL)
	{
		globalData.m_hcurStretch = AfxGetApp ()->LoadCursor (AFX_IDC_HSPLITBAR);
	}

	if (globalData.m_hcurStretchVert == NULL)
	{
		globalData.m_hcurStretchVert = AfxGetApp ()->LoadCursor (AFX_IDC_VSPLITBAR);
	}
	
	return 0;
}
//*******************************************************************************
void CBCGPSlider::StoreRecentDockInfo (CBCGPDockingControlBar* pBar)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pBar);

	if (m_pContainerManager != NULL)
	{
		m_pContainerManager->StoreRecentDockInfo (pBar);
	}
}
//*******************************************************************************
void CBCGPSlider::StoreRecentTabRelatedInfo (CBCGPDockingControlBar* pDockingBar, 
												CBCGPDockingControlBar* pTabbedBar)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pDockingBar);
	ASSERT_VALID (pTabbedBar);

	if (m_pContainerManager != NULL)
	{
		BOOL bLeftBar = FALSE;
		CBCGPBarContainer* pTabbedContainer = 
			m_pContainerManager->FindContainer (pTabbedBar, bLeftBar);
		if (pTabbedContainer != NULL)
		{
			pDockingBar->
				m_recentDockInfo.StoreDockInfo (pTabbedContainer, pTabbedBar);
		}
		else
		{
			ASSERT (FALSE);
		}
	}
}
//*******************************************************************************
CBCGPBarContainer* CBCGPSlider::FindContainer (CBCGPDockingControlBar* pBar, 
											   BOOL& bLeftBar)
{
	ASSERT_VALID (this);

	return m_pContainerManager->FindContainer (pBar, bLeftBar);
}
//*******************************************************************************
BOOL CBCGPSlider::AddContainer (CBCGPBarContainerManager& barContainerManager, 
								BOOL bOuterEdge)	
{
	BOOL bResult = FALSE;
	if (m_pContainerManager != NULL)
	{
		bResult = m_pContainerManager->AddContainerManager (barContainerManager, bOuterEdge);
		CheckVisibility ();
	}
	return bResult;
}
//*******************************************************************************
BOOL CBCGPSlider::AddContainer	(CBCGPDockingControlBar* pTargetBar, 
								 CBCGPBarContainerManager& barContainerManager, 
								 DWORD dwAlignment)
{
	BOOL bResult = FALSE;
	if (m_pContainerManager != NULL)
	{
		bResult = m_pContainerManager->AddContainerManager (pTargetBar, dwAlignment, 
																 barContainerManager,
																 TRUE);
		CheckVisibility ();
	}
	return bResult;
}
//*******************************************************************************
void CBCGPSlider::OnShowControlBar (CBCGPDockingControlBar* pBar, BOOL bShow)
{
	if (m_pContainerManager != NULL && !IsAutoHideMode	())
	{
		BOOL bNewVisibleState = m_pContainerManager->OnShowControlBar (pBar, bShow);
		if (!bShow)
		{
			// actual only for hide, because when bShow is TRUE slider must be always
			// visible
			ShowWindow (bNewVisibleState ? SW_SHOW : SW_HIDE);
			BOOL bLeftBar = FALSE;
			CBCGPBarContainer* pContainer = m_pContainerManager->FindContainer (pBar, bLeftBar);
			if (pContainer != NULL)
			{
				pContainer->OnShowControlBar (pBar, bShow);
			}
		}
		else
		{
			ShowWindow (SW_SHOW);
		}
	}
}
//*******************************************************************************
BOOL CBCGPSlider::CheckVisibility ()
{
	if (m_bDefaultSlider && !IsAutoHideMode	() && m_pContainerManager != NULL)
	{
		BOOL bIsRootContainerVisible = m_pContainerManager->IsRootContainerVisible ();
		ShowWindow (bIsRootContainerVisible ? SW_SHOW : SW_HIDE);
		return bIsRootContainerVisible;
	}

	return FALSE;
}
//*******************************************************************************
BOOL CBCGPSlider::DoesContainFloatingBar ()
{
	if (m_pContainerManager != NULL)
	{
		return m_pContainerManager->DoesContainFloatingBar ();
	}
	return FALSE;
}
//*******************************************************************************
BOOL CBCGPSlider::DoesAllowDynInsertBefore () const
{
	if (m_pContainerManager != NULL)
	{
		return m_pContainerManager->DoesAllowDynInsertBefore ();
	}
	return TRUE;
}
//*******************************************************************************
void CBCGPSlider::CalcExpectedDockedRect (CWnd* pWndToDock, CPoint ptMouse, 
										  CRect& rectResult, BOOL& bDrawTab, 
										  CBCGPDockingControlBar** ppTargetBar)
{
	CBCGPGlobalUtils globalUtils;
	if (m_pContainerManager != NULL)
	{
		globalUtils.CalcExpectedDockedRect (*m_pContainerManager, pWndToDock, 
											ptMouse, rectResult, bDrawTab, ppTargetBar);
	}
}
//*******************************************************************************
void CBCGPSlider::NotifyAboutRelease ()
{
	if (m_pContainerManager->IsEmpty () && 
		m_pContainerManager->GetTotalRefCount () == 0)
	{
		// it was the last control bar in the container - 
		// remove and DESTROY  the slider as well
		CBCGPBaseControlBar::RemoveControlBarFromDockManager (this, TRUE, FALSE, m_bAutoHideMode);
	}	
}
//*******************************************************************************
void CBCGPSlider::GetControlBars (CObList& lstBars) 
{
	if (m_pContainerManager != NULL)
	{
		m_pContainerManager->AddControlBarsToList(&lstBars, NULL);
	}
}
//*******************************************************************************
void CBCGPSlider::GetSliders (CObList& lstSliders)
{
	if (m_pContainerManager != NULL)
	{
		m_pContainerManager->AddControlBarsToList(NULL, &lstSliders);
	}
}

⌨️ 快捷键说明

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