📄 bcgpminiframewnd.cpp
字号:
return lResult;
}
//**************************************************************************************
BOOL CBCGPMiniFrameWnd::OnEraseBkgnd(CDC* /*pDC*/)
{
return TRUE;
}
//**************************************************************************************
void CBCGPMiniFrameWnd::OnNcDestroy()
{
OnCancelMode();
CWnd::OnNcDestroy();
delete this;
}
//**************************************************************************************
void CBCGPMiniFrameWnd::OnCancelMode()
{
StopCaptionButtonsTracking ();
if (m_bCaptured)
{
if (GetDockMode () == DT_STANDARD)
{
m_dragFrameImpl.EndDrawDragFrame ();
if (!IsWindowVisible ())
{
// probably dragging control bar detached from tab window
CBCGPControlBar* pBar =
DYNAMIC_DOWNCAST (CBCGPControlBar, CWnd::FromHandlePermanent (m_hEmbeddedBar));
if (pBar != NULL && pBar->GetParent () == this)
{
BOOL bResult = pBar->DockControlBar (pBar, NULL, DM_DBL_CLICK);
pBar->ShowControlBar (TRUE, FALSE, TRUE);
if (!bResult)
{
return;
}
}
}
}
ReleaseCapture ();
m_bCaptured = false;
OnCapture (FALSE);
}
CWnd::OnCancelMode();
}
//**************************************************************************************
void CBCGPMiniFrameWnd::GetCaptionRect (CRect& rectCaption) const
{
CRect rectBorderSize;
rectBorderSize.SetRectEmpty ();
CalcBorderSize (rectBorderSize);
CRect rectWnd;
GetWindowRect (&rectWnd);
ScreenToClient (&rectWnd);
rectWnd.OffsetRect (rectBorderSize.left, m_nCaptionHeight + rectBorderSize.top);
rectCaption = CRect (rectWnd.left + rectBorderSize.left, rectWnd.top + rectBorderSize.top,
rectWnd.right - rectBorderSize.right,
rectWnd.top + rectBorderSize.top + m_nCaptionHeight);
}
//**************************************************************************************
void CBCGPMiniFrameWnd::OnNcMouseMove(UINT nHitTest, CPoint point)
{
if (!m_bBlockMove && !m_bCaptured)
{
OnTrackCaptionButtons (point);
}
CWnd::OnNcMouseMove(nHitTest, point);
}
//*************************************************************************************
void CBCGPMiniFrameWnd::OnTrackCaptionButtons (CPoint point)
{
UINT nHot = m_nHot;
CBCGPCaptionButton* pBtn = FindButton (point);
if (pBtn != NULL && pBtn->m_bEnabled)
{
m_nHot = pBtn->GetHit ();
pBtn->m_bFocused = TRUE;
}
else
{
m_nHot = HTNOWHERE;
}
if (m_nHot != nHot)
{
RedrawCaptionButton (pBtn);
CBCGPCaptionButton* pBtnOld = FindButton (nHot);
if (pBtnOld != NULL)
{
pBtnOld->m_bFocused = FALSE;
RedrawCaptionButton (pBtnOld);
}
}
if (m_nHit == HTNOWHERE)
{
if (nHot != HTNOWHERE && m_nHot == HTNOWHERE)
{
::ReleaseCapture();
}
else if (nHot == HTNOWHERE && m_nHot != HTNOWHERE)
{
SetCapture ();
}
}
}
//************************************************************************************
void CBCGPMiniFrameWnd::StopCaptionButtonsTracking ()
{
if (m_nHit != HTNOWHERE)
{
CBCGPCaptionButton* pBtn = FindButton (m_nHit);
m_nHit = HTNOWHERE;
ReleaseCapture ();
if (pBtn != NULL)
{
pBtn->m_bPushed = FALSE;
RedrawCaptionButton (pBtn);
}
}
if (m_nHot != HTNOWHERE)
{
CBCGPCaptionButton* pBtn = FindButton (m_nHot);
m_nHot = HTNOWHERE;
ReleaseCapture ();
if (pBtn != NULL)
{
pBtn->m_bFocused = FALSE;
RedrawCaptionButton (pBtn);
}
}
}
//************************************************************************************
BOOL CBCGPMiniFrameWnd::IsCustModeAndNotFloatingToolbar () const
{
CWnd* pEmbeddedWnd = CWnd::FromHandlePermanent (m_hEmbeddedBar);
if (CBCGPToolBar::IsCustomizeMode () && pEmbeddedWnd != NULL &&
!pEmbeddedWnd->IsKindOf (RUNTIME_CLASS (CBCGPToolBar)))
{
return TRUE;
}
return FALSE;
}
//************************************************************************************
int CBCGPMiniFrameWnd::GetCaptionButtonTotalWidth () const
{
int nTotalWidth = 0;
for (POSITION pos = m_lstCaptionButtons.GetHeadPosition (); pos != NULL;)
{
CBCGPCaptionButton* pBtn = (CBCGPCaptionButton*) m_lstCaptionButtons.GetNext (pos);
ASSERT_VALID (pBtn);
CRect rectBtn = pBtn->GetRect ();
nTotalWidth += rectBtn.Width ();
}
return nTotalWidth;
}
//************************************************************************************
void CBCGPMiniFrameWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
CBCGPControlBar* pContainedBar =
DYNAMIC_DOWNCAST (CBCGPControlBar, CWnd::FromHandlePermanent (m_hEmbeddedBar));
if (pContainedBar != NULL)
{
CSize sizeBase;
pContainedBar->GetMinSize (sizeBase);
CalcMinSize (sizeBase, lpMMI);
}
CWnd::OnGetMinMaxInfo(lpMMI);
}
//*****************************************************************************************
void CBCGPMiniFrameWnd::CalcMinSize (CSize& sizeBase, MINMAXINFO FAR* lpMMI)
{
CRect rectBorderSize;
CalcBorderSize (rectBorderSize);
lpMMI->ptMinTrackSize.x = sizeBase.cx +
rectBorderSize.left + rectBorderSize.right +
GetCaptionButtonTotalWidth ();
lpMMI->ptMinTrackSize.x = max (lpMMI->ptMinTrackSize.x, m_sizeMinSize.cx);
lpMMI->ptMinTrackSize.y = sizeBase.cy + m_nCaptionHeight +
rectBorderSize.top + rectBorderSize.bottom;
lpMMI->ptMinTrackSize.y = max (lpMMI->ptMinTrackSize.y, m_sizeMinSize.cy);
}
//*****************************************************************************************
void CBCGPMiniFrameWnd::OnContextMenu(CWnd* pWnd, CPoint point)
{
if (CBCGPToolBar::IsCustomizeMode () || m_bCaptured)
{
return;
}
CRect rectWnd;
GetWindowRect (&rectWnd);
CRect rectBorderSize;
CalcBorderSize (rectBorderSize);
CRect rectCaption (rectWnd.left + rectBorderSize.left, rectWnd.top + rectBorderSize.top,
rectWnd.right - rectBorderSize.right,
rectWnd.top + rectBorderSize.top + m_nCaptionHeight);
if (!rectCaption.PtInRect (point))
{
return;
}
CWnd* pParent = GetParent ();
if (pParent != NULL)
{
ASSERT_VALID (pParent);
pParent->SendMessage (BCGM_TOOLBARMENU, (WPARAM) GetSafeHwnd (),
MAKELPARAM(point.x, point.y));
}
}
//*************************************************************************************
void CBCGPMiniFrameWnd::OnCapture (BOOL bOnOff)
{
CBCGPControlBar* pBar =
DYNAMIC_DOWNCAST (CBCGPControlBar, CWnd::FromHandlePermanent (m_hEmbeddedBar));
if (pBar != NULL)
{
pBar->SetDragMode (bOnOff);
}
if (IsWindow (m_hWndToDestroyOnRelease) && !bOnOff)
{
::DestroyWindow (m_hWndToDestroyOnRelease);
m_hWndToDestroyOnRelease = NULL;
}
if (pBar != NULL && !bOnOff)
{
if (pBar->m_hwndMiniFrameToBeClosed != m_hWnd &&
IsWindow (pBar->m_hwndMiniFrameToBeClosed))
{
::DestroyWindow (pBar->m_hwndMiniFrameToBeClosed);
}
pBar->m_hwndMiniFrameToBeClosed = NULL;
}
}
//**************************************************************************************
void CBCGPMiniFrameWnd::OnDestroy()
{
if (m_bCaptured)
{
ReleaseCapture ();
m_bCaptured = false;
OnCapture (FALSE);
}
KillDockTimer ();
if (m_nRollTimerID != 0)
{
KillTimer (m_nRollTimerID);
}
// register with dock manager
CBCGPDockManager* pDockManager = globalUtils.GetDockManager (GetParent ());
if (pDockManager != NULL)
{
ASSERT_VALID (pDockManager);
pDockManager->RemoveMiniFrame (this);
}
POSITION pos = m_lstFrames.Find (GetSafeHwnd ());
ASSERT (pos != NULL);
m_lstFrames.RemoveAt (pos);
CWnd::OnDestroy();
}
//**************************************************************************************
void CBCGPMiniFrameWnd::SetDockTimer (UINT nTimeOut)
{
if (m_nDockTimerID != 0)
{
KillDockTimer ();
}
m_nDockTimerID = SetTimer (BCGP_DOCK_EVENT, nTimeOut, NULL);
}
//**************************************************************************************
void CBCGPMiniFrameWnd::KillDockTimer ()
{
if (m_nDockTimerID != 0)
{
KillTimer (m_nDockTimerID);
m_nDockTimerID = 0;
}
}
//*************************************************************************************
CBCGPBaseControlBar* CBCGPMiniFrameWnd::FindFloatingBarByID (UINT nID)
{
HWND hWnd = NULL;
if (!m_mapFloatingBars.Lookup (nID, hWnd))
{
return NULL;
}
CBCGPBaseControlBar* pBar =
DYNAMIC_DOWNCAST (CBCGPBaseControlBar, CWnd::FromHandlePermanent (hWnd));
return pBar;
}
//*************************************************************************************
CBCGPMiniFrameWnd* CBCGPMiniFrameWnd::FrameFromPoint (CPoint pt, int nSencitivity,
CBCGPMiniFrameWnd* pFrameToExclude,
BOOL bFloatMultiOnly)
{
for (POSITION pos = m_mapFloatingBars.GetStartPosition (); pos != NULL;)
{
UINT uID = 0;
HWND hWnd = NULL;
m_mapFloatingBars.GetNextAssoc (pos, uID, hWnd);
CBCGPBaseControlBar* pNextBar =
DYNAMIC_DOWNCAST (CBCGPBaseControlBar, CWnd::FromHandlePermanent (hWnd));
if (pNextBar == NULL)
{
continue;
}
if (!pNextBar->IsWindowVisible ())
{
continue;
}
if ((bFloatMultiOnly &&
((pNextBar->GetBarStyle () & CBRS_FLOAT_MULTI) || pNextBar->IsFloatingMulti ()) ||
!bFloatMultiOnly) && pNextBar->GetParentMiniFrame () != pFrameToExclude)
{
CRect rectBar, rectBarInflated;
pNextBar->GetWindowRect (rectBar);
rectBarInflated = rectBar;
if (rectBarInflated.PtInRect (pt))
{
// the point around bar
rectBar.InflateRect (-nSencitivity, -nSencitivity);
if (!rectBar.PtInRect (pt) || nSencitivity == 0)
{
// the point near the floating bar edges - return its parent frame
CBCGPMiniFrameWnd* pWnd =
DYNAMIC_DOWNCAST (CBCGPMiniFrameWnd, pNextBar->GetParentMiniFrame ());
if (pWnd != NULL && pWnd->IsWindowVisible ())
{
return pWnd;
}
return NULL;
}
}
}
}
return NULL;
}
//*************************************************************************************
void CBCGPMiniFrameWnd::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (m_bCaptured && nChar == VK_ESCAPE)
{
if (GetDockMode () == DT_STANDARD)
{
OnCancelMode ();
}
else
{
ReleaseCapture ();
CBCGPControlBar* pBar =
DYNAMIC_DOWNCAST (CBCGPControlBar, CWnd::FromHandlePermanent (m_hEmbeddedBar));
if (pBar != NULL &&
pBar->GetEnabledAlignment () & CBRS_ALIGN_ANY)
{
pBar->m_recentDockInfo.m_rectRecentFloatingRect = m_rectRecentFloatingRect;
if (!pBar->DockControlBar (pBar, NULL, DM_DBL_CLICK))
{
// was destroyed
return;
}
}
}
}
CWnd::OnChar(nChar, nRepCnt, nFlags);
}
//*************************************************************************************
void CBCGPMiniFrameWnd::AdjustLayout ()
{
CBCGPBaseControlBar* pBaseControlBar =
DYNAMIC_DOWNCAST (CBCGPBaseControlBar, CWnd::FromHandlePermanent (m_hEmbeddedBar));
if (pBaseControlBar != NULL)
{
pBaseControlBar->RecalcLayout ();
SizeToContent ();
}
}
//*************************************************************************************
BOOL CBCGPMiniFrameWnd::SaveState (LPCTSTR lpszProfileName, UINT uiID)
{
CBCGPBaseControlBar* pBaseControlBar =
DYNAMIC_DOWNCAST (CBCGPBaseControlBar, CWnd::FromHandlePermanent (m_hEmbeddedBar));
if (pBaseControlBar != NULL)
{
return pBaseControlBar->SaveState (lpszProfileName, uiID);
}
return TRUE;
}
//*************************************************************************************
BOOL CBCGPMiniFrameWnd::LoadState (LPCTSTR lpszProfileName, UINT uiID)
{
CBCGPBaseControlBar* pBaseControlBar =
DYNAMIC_DOWNCAST (CBCGPBaseControlBar, CWnd::FromHandlePermanent (m_hEmbeddedBar));
if (pBaseControlBar != NULL)
{
return pBaseControlBar->LoadState (lpszProfileName, uiID);
}
return TRUE;
}
//*************************************************************************************
void CBCGPMiniFrameWnd::Serialize (CArchive& ar)
{
CWnd::Serialize (ar);
if (ar.IsLoading ())
{
DWORD dwStyle = 0;
CRect rect; rect.SetRectEmpty ();
BOOL bIsVisible = FALSE;
ar >> dwStyle;
ar >> rect;
ar >> bIsVisible;
ar >> m_nRestoredEmbeddedBarID;
ar >> m_dwCaptionButtons;
ar >> m_bPinned;
if (!Create (_T (""), dwStyle, rect, CBCGPMiniFrameWnd::m_pParentWndForSerialize))
{
throw new CArchiveException;
return;
}
m_hParentWnd = CBCGPMiniFrameWnd::m_pParentWndForSerialize->m_hWnd;
}
else
{
CRect rect;
GetWindowRect (rect);
if (m_bRolledUp)
{
rect.bottom = rect.top + m_nHeightBeforeRollUp;
}
BOOL bIsVisible = IsWindowVisible ();
ar << GetStyle ();
ar << rect;
ar << bIsVisible;
CWnd* pEmbeddedWnd = CWnd::FromHandlePermanent (m_hEmbeddedBar);
if (pEmbeddedWnd != 0)
{
ar << pEmbeddedWnd->GetDlgCtrlID ();
}
else
{
ar << 0;
}
ar << m_dwCapt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -