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

📄 bcgpcontrolbarimpl.cpp

📁 远程网络监视程序的源码
💻 CPP
字号:
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a part of the BCGControlBar Library
// Copyright (C) 1998-2000 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions 
// of the accompanying license agreement.
 //*******************************************************************************

// BCGControlBarImpl.cpp: implementation of the CBCGPControlBarImpl class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "BCGPControlBarImpl.h"
#include "BCGPToolBar.h"
#include "BCGPVisualManager.h"
#include "BCGGlobals.h"
#include "BCGPControlBar.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

CFrameWnd* g_pTopLevelFrame = NULL;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CBCGPControlBarImpl::CBCGPControlBarImpl(CBCGPControlBar* pBar) :
	m_pBar (pBar)
{
	ASSERT_VALID (m_pBar);
}
//*****************************************************************************************
CBCGPControlBarImpl::~CBCGPControlBarImpl()
{
}
//****************************************************************************************
void CBCGPControlBarImpl::DrawNcArea ()
{
	CWindowDC dc(m_pBar);

	CRect rectClient;
	m_pBar->GetClientRect(rectClient);

	CRect rectWindow;
	m_pBar->GetWindowRect(rectWindow);

	m_pBar->ScreenToClient(rectWindow);
	rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
	dc.ExcludeClipRect (rectClient);

	{
		MSG* pMsg = &AfxGetThreadState()->m_lastSentMsg;

		ASSERT (pMsg->hwnd == m_pBar->m_hWnd);
		ASSERT (pMsg->message == WM_NCPAINT);

		CRgn* pRgn = NULL;
		if (pMsg->wParam != 1 && 
			(pRgn = CRgn::FromHandle ((HRGN) pMsg->wParam)) != NULL)
		{
			CRect rect;
			m_pBar->GetWindowRect (rect);
			pRgn->OffsetRgn (- rect.TopLeft ());
			dc.SelectClipRgn (pRgn, RGN_AND);
		}
	}

	// draw borders in non-client area
	rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
	CBCGPVisualManager::GetInstance ()->OnDrawBarBorder (&dc, m_pBar, rectWindow);

	// erase parts not drawn
	dc.IntersectClipRect(rectWindow);
	CBCGPVisualManager::GetInstance ()->OnFillBarBackground  (&dc, m_pBar, rectWindow,
		CRect (0, 0, 0, 0), TRUE /* NC area */);

	// draw gripper in non-client area
	if ((m_pBar->GetBarStyle () & (CBRS_GRIPPER|CBRS_FLOATING)) != CBRS_GRIPPER)
	{
		dc.SelectClipRgn (NULL);
		return;
	}

	CRect rectGripper;
	GetGripperRect (rectGripper);

	BOOL bHorz = (m_pBar->GetBarStyle () & CBRS_ORIENT_HORZ) ? TRUE : FALSE;

	CBCGPVisualManager::GetInstance ()->OnDrawBarGripper (
		&dc, rectGripper, bHorz, m_pBar);
	dc.SelectClipRgn (NULL);
}
//**********************************************************************************************
void CBCGPControlBarImpl::CalcNcSize (NCCALCSIZE_PARAMS FAR* lpncsp)
{
	ASSERT_VALID(m_pBar);

	CRect rect; rect.SetRectEmpty();
	BOOL bHorz = m_pBar->IsHorizontal ();

	m_pBar->CalcInsideRect(rect, bHorz);

	// adjust non-client area for border space
	lpncsp->rgrc[0].left += rect.left;
	lpncsp->rgrc[0].top += rect.top;

	lpncsp->rgrc[0].right += rect.right;
	lpncsp->rgrc[0].bottom += rect.bottom;
}
//*************************************************************************************
BOOL CBCGPControlBarImpl::GetBackgroundFromParent (CDC* pDC)
{
	return globalData.DrawParentBackground (m_pBar, pDC);
}
//*************************************************************************************
void CBCGPControlBarImpl::GetGripperRect (CRect& rectGripper, BOOL bClientCoord)
{
	ASSERT_VALID (m_pBar);

	BOOL bHorz = (m_pBar->GetBarStyle () & CBRS_ORIENT_HORZ) ? TRUE : FALSE;

	m_pBar->GetWindowRect (&rectGripper);

	CRect rcClient;
	m_pBar->GetClientRect(&rcClient);
	m_pBar->ClientToScreen(&rcClient);

	if(bHorz) 
	{
		rectGripper.right = min( rectGripper.right, rcClient.left - 1);
	}
	else 
	{
		rectGripper.bottom = min( rectGripper.bottom, rcClient.top - 1);
	}

	if (bClientCoord)
	{
		m_pBar->ScreenToClient (&rectGripper);
	}
	else
	{
		rectGripper.OffsetRect (-rectGripper.left, -rectGripper.top);
	}
}

⌨️ 快捷键说明

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