【VC开源代码栏目提醒】:网学会员VC开源代码为您提供CJCONTROLBAR.CPP参考,解决您在CJCONTROLBAR.CPP学习中工作中的难题,参考学习。
// CJControlBar.cpp : implementation file
//
// DevStudio Style Resizable Docking Control Bar.
//
// Copyright ?1998 Written by Kirk Stowell
// mailto:kstowell@codejockeys.com
// http://www.codejockeys.com/kstowell/index.html
//
// The code contained in this file is based on the original
// CSizingControlBar class written by Cristi Posea,
// mailto:cristi@gds.ro
// http://www.codeguru.com/docking/docking_window2.shtml
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name and all copyright
// notices remains intact. If the source code in this file is used in
// any commercial application then a statement along the lines of
// "Portions Copyright ?1998 Kirk Stowell" must be included in
// the startup banner, "About" box or printed documentation. An email
// letting me know that you are using it would be nice as well. That's
// not much to ask considering the amount of work that went into this.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage/loss of business that
// this product may cause.
//
// ==========================================================================
// HISTORY:
// ==========================================================================
// 1.00 17 Oct 1998 - Initial re-write and release.
// 1.01 20 Oct 1998 - Fixed problem with gripper and buttons
// disappearing when docking toggled. Overloaded
// IsFloating() method from base class.
// 1.02 22 Nov 1998 - Modified set cursor to display normal size
// cursor when static linked.
// ==========================================================================
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CJControlBar.h"
#include <afxpriv.h> // for CDockContext
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCJControlBar
#define IDC_BUTTON_HIDE 1000
#define IDC_BUTTON_MINI 1001
CCJControlBar::CCJControlBar()
{
m_sizeMin = CSize(32, 32);
m_sizeHorz = CSize(200, 200);
m_sizeVert = CSize(200, 200);
m_sizeFloat = CSize(200, 200);
m_bTracking = FALSE;
m_bInRecalcNC = FALSE;
m_cxEdge = 5;
m_menuID = 0;
m_bGripper = TRUE;
m_bButtons = TRUE;
}
CCJControlBar::~CCJControlBar()
{
}
IMPLEMENT_DYNAMIC(CCJControlBar, CControlBar)
BEGIN_MESSAGE_MAP(CCJControlBar, CControlBar)
//{{AFX_MSG_MAP(CCJControlBar)
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_SETCURSOR()
ON_WM_WINDOWPOSCHANGED()
ON_WM_NCPAINT()
ON_WM_NCLBUTTONDOWN()
ON_WM_NCHITTEST()
ON_WM_NCCALCSIZE()
ON_WM_LBUTTONDOWN()
ON_WM_CAPTURECHANGED()
ON_WM_LBUTTONDBLCLK()
ON_WM_PAINT()
ON_WM_CREATE()
ON_COMMAND(IDC_BUTTON_HIDE, OnButtonClose)
ON_UPDATE_COMMAND_UI(IDC_BUTTON_HIDE, OnUpdateButtonClose)
ON_COMMAND(IDC_BUTTON_MINI, OnButtonMinimize)
ON_UPDATE_COMMAND_UI(IDC_BUTTON_MINI, OnUpdateButtonMinimize)
ON_WM_CONTEXTMENU()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCJControlBar message handlers
void CCJControlBar::OnUpdateCmdUI(CFrameWnd * pTarget, BOOL bDisableIfNoHndler)
{
UpdateDialogControls(pTarget, bDisableIfNoHndler);
}
BOOL CCJControlBar::Create(CWnd * pParentWnd, UINT nID, LPCTSTR lpszWindowName, CSize sizeDefault, DWORD dwStyle)
{
ASSERT_VALID(pParentWnd); // must have a parent
ASSERT (((dwStyle & CBRS_SIZE_FIXED) != CBRS_SIZE_FIXED) &&
((dwStyle & CBRS_SIZE_DYNAMIC) != CBRS_SIZE_DYNAMIC));
// save the style
SetBarStyle(dwStyle & CBRS_ALL);
CString wndclass = ::AfxRegisterWndClass(CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW),
::GetSysColorBrush(COLOR_BTNFACE), 0);
m_sizeHorz = m_sizeVert = m_sizeFloat = sizeDefault;
dwStyle &= ~CBRS_ALL;
dwStyle &= WS_VISIBLE | WS_CHILD;
return CWnd::Create(wndclass, lpszWindowName, dwStyle,
CRect(0,0,0,0), pParentWnd, nID);
}
CSize CCJControlBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
CRect rc;
m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_TOP)->GetWindowRect(rc);
int nHorzDockBarWidth = bStretch ? 32767 : rc.Width() + 4;
m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT)->GetWindowRect(rc);
int nVertDockBarHeight = bStretch ? 32767 : rc.Height() + 4;
if (bHorz)
return CSize(nHorzDockBarWidth, m_sizeHorz.cy);
else
return CSize(m_sizeVert.cx, nVertDockBarHeight);
}
CSize CCJControlBar::CalcDynamicLayout(int nLength, DWORD dwMode)
{
if (dwMode & (LM_HORZDOCK | LM_VERTDOCK))
{
if (nLength == -1)
GetDockingFrame()->DelayRecalcLayout();
return CControlBar::CalcDynamicLayout(nLength,dwMode);
}
if (dwMode & LM_MRUWIDTH)
return m_sizeFloat;
if (dwMode & LM_COMMIT)
{
m_sizeFloat.cx = nLength;
return m_sizeFloat;
}
if (dwMode & LM_LENGTHY)
return CSize(m_sizeFloat.cx,
m_sizeFloat.cy = max(m_sizeMin.cy, nLength));
else
return CSize(max(m_sizeMin.cx, nLength), m_sizeFloat.cy);
}
void CCJControlBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
CControlBar::OnWindowPosChanged(lpwndpos);
// Find on which side are we docked
m_nDockBarID = GetParent()->GetDlgCtrlID();
if (m_bInRecalcNC == FALSE)
{
m_bInRecalcNC = TRUE;
// Force recalc the non-client area
SetWindowPos(NULL, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE |
SWP_NOACTIVATE | SWP_NOZORDER |
SWP_FRAMECHANGED);
m_bInRecalcNC = FALSE;
}
if (m_bButtons)
{
ASSERT(m_ImageList);
if (IsFloating()) {
m_btnClose.ShowWindow(SW_HIDE);
m_btnMinim.ShowWindow(SW_HIDE);
return;
}
else {
m_btnClose.ShowWindow(SW_SHOW);
m_btnMinim.ShowWindow(SW_SHOW);
}
CRect rcClose(GetButtonRect());
CRect rcMinim(GetButtonRect());
if (IsHorzDocked()) {
rcMinim.OffsetRect(0,14);
m_btnMinim.SetIcon(m_ImageList->ExtractIcon(2),CSize(13,13));
}
else {
rcClose.OffsetRect(14,0);
m_btnMinim.SetIcon(m_ImageList->ExtractIcon(1),CSize(13,13));
}
m_btnClose.MoveWindow(rcClose);
m_btnMinim.MoveWindow(rcMinim);
}
Invalidate();
}
BOOL CCJControlBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if ((nHitTest != HTSIZE) || m_bTracking)
return CControlBar::OnSetCursor(pWnd, nHitTest, message);
#if defined(MFCXLIB_STATIC)
HINSTANCE hInst = AfxFindR
上一篇:
CJCOMBOBOX.CPP
下一篇:
高职院理实一体信息技术论文