📄 bcgpmdiframewnd.cpp
字号:
}
m_bContextHelp = FALSE;
}
//***************************************************************************************
BOOL CBCGPMDIFrameWnd::DockControlBarLeftOf (CBCGPControlBar* pBar, CBCGPControlBar* pLeftOf)
{
return m_dockManager.DockControlBarLeftOf (pBar, pLeftOf);
}
//***************************************************************************************
void CBCGPMDIFrameWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CMDIFrameWnd::OnActivate(nState, pWndOther, bMinimized);
switch (nState)
{
case WA_CLICKACTIVE:
UpdateWindow ();
break;
case WA_INACTIVE:
if (!CBCGPToolBar::IsCustomizeMode ())
{
m_Impl.DeactivateMenu ();
}
break;
}
}
//***************************************************************************************
#if _MSC_VER >= 1300
void CBCGPMDIFrameWnd::OnActivateApp(BOOL bActive, DWORD /*dwThreadID*/)
#else
void CBCGPMDIFrameWnd::OnActivateApp(BOOL bActive, HTASK /*hTask*/)
#endif
{
m_dockManager.OnActivateFrame (bActive);
}
//***************************************************************************************
void CBCGPMDIFrameWnd::EnableWindowsDialog (UINT uiMenuId,
LPCTSTR lpszMenuText,
BOOL bShowAllways,
BOOL bShowHelpButton)
{
ASSERT (lpszMenuText != NULL);
ASSERT (uiMenuId != 0);
m_uiWindowsDlgMenuId = uiMenuId;
m_strWindowsDlgMenuText = lpszMenuText;
m_bShowWindowsDlgAlways = bShowAllways;
m_bShowWindowsDlgHelpButton = bShowHelpButton;
}
//****************************************************************************
void CBCGPMDIFrameWnd::EnableWindowsDialog (UINT uiMenuId,
UINT uiMenuTextResId,
BOOL bShowAllways,
BOOL bShowHelpButton)
{
CString strMenuText;
VERIFY (strMenuText.LoadString (uiMenuTextResId));
EnableWindowsDialog (uiMenuId, strMenuText, bShowAllways, bShowHelpButton);
}
//****************************************************************************
void CBCGPMDIFrameWnd::ShowWindowsDialog ()
{
CBCGPLocalResource locaRes;
CBCGPWindowsManagerDlg dlg (this, m_bShowWindowsDlgHelpButton);
dlg.DoModal ();
}
//****************************************************************************
COleClientItem* CBCGPMDIFrameWnd::GetInPlaceActiveItem ()
{
CFrameWnd* pActiveFrame = GetActiveFrame ();
if (pActiveFrame == NULL)
{
return NULL;
}
ASSERT_VALID (pActiveFrame);
CView* pView = pActiveFrame->GetActiveView ();
if (pView == NULL)
{
return NULL;
}
ASSERT_VALID (pView);
COleDocument* pDoc = DYNAMIC_DOWNCAST (COleDocument, pView->GetDocument ());
if (pDoc == NULL)
{
return NULL;
}
ASSERT_VALID (pDoc);
return pDoc->GetInPlaceActiveItem (pView);
}
//****************************************************************************
void CBCGPMDIFrameWnd::OnUpdateFrameMenu (HMENU hMenuAlt)
{
CMDIFrameWnd::OnUpdateFrameMenu (hMenuAlt);
if (m_Impl.m_pMenuBar != NULL &&
(m_Impl.m_pMenuBar->GetStyle () & WS_VISIBLE))
{
COleClientItem* pActiveItem = GetInPlaceActiveItem ();
if (pActiveItem == NULL ||
pActiveItem->GetInPlaceWindow () == NULL)
{
SetMenu (NULL);
}
else
{
SetMenu (CMenu::FromHandle (hMenuAlt));
}
}
}
//****************************************************************************************
void CBCGPMDIFrameWnd::OnDestroy()
{
if (m_hAccelTable != NULL)
{
::DestroyAcceleratorTable (m_hAccelTable);
m_hAccelTable = NULL;
}
m_dockManager.m_bEnableAdjustLayout = FALSE;
CList<HWND, HWND> lstChildren;
CWnd* pNextWnd = GetTopWindow ();
while (pNextWnd != NULL)
{
if (m_wndClientArea.m_hWnd != pNextWnd->m_hWnd)
{
lstChildren.AddTail (pNextWnd->m_hWnd);
}
pNextWnd = pNextWnd->GetNextWindow ();
}
for (POSITION pos = lstChildren.GetHeadPosition (); pos != NULL;)
{
HWND hwndNext = lstChildren.GetNext (pos);
if (IsWindow (hwndNext) && ::GetParent (hwndNext) == m_hWnd)
{
::DestroyWindow (hwndNext);
}
}
CMDIFrameWnd::OnDestroy();
}
//*************************************************************************************
void CBCGPMDIFrameWnd::EnableMDITabs (BOOL bEnable/* = TRUE*/,
BOOL bIcons/* = TRUE*/,
CBCGPTabWnd::Location tabLocation /* = CBCGPTabWnd::LOCATION_BOTTOM*/,
BOOL bTabCloseButton/* = FALSE*/,
CBCGPTabWnd::Style style/* = CBCGPTabWnd::STYLE_3D_SCROLLED*/)
{
ASSERT (style == CBCGPTabWnd::STYLE_3D_SCROLLED ||
style == CBCGPTabWnd::STYLE_3D_ONENOTE);
m_wndClientArea.EnableMDITabs (bEnable, bIcons, tabLocation, bTabCloseButton, style);
}
//*************************************************************************************
void CBCGPMDIFrameWnd::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState)
{
ASSERT_VALID (this);
if (m_wndClientArea.DoesMDITabExist ())
{
m_wndClientArea.m_bTabIsVisible = !bPreview;
((CWnd&)m_wndClientArea.GetMDITabs ()).ShowWindow (
bPreview ? SW_HIDE : SW_SHOWNOACTIVATE);
}
m_dockManager.SetPrintPreviewMode (bPreview, pState);
DWORD dwSavedState = pState->dwStates;
CMDIFrameWnd::OnSetPreviewMode (bPreview, pState);
pState->dwStates = dwSavedState;
AdjustDockingLayout ();
RecalcLayout ();
}
//*************************************************************************************
BOOL CBCGPMDIFrameWnd::OnShowControlBars (BOOL bShow)
{
ASSERT_VALID (this);
BOOL bResult = m_dockManager.ShowControlBars (bShow);
AdjustDockingLayout ();
return bResult;
}
//*****************************************************************************
//******************* dockmanager layer ***************************************
//*****************************************************************************
void CBCGPMDIFrameWnd::AddDockBar ()
{
ASSERT_VALID (this);
}
//*****************************************************************************
BOOL CBCGPMDIFrameWnd::AddControlBar (CBCGPBaseControlBar* pControlBar, BOOL bTail)
{
ASSERT_VALID (this);
return m_dockManager.AddControlBar (pControlBar, bTail);
}
//*****************************************************************************
BOOL CBCGPMDIFrameWnd::InsertControlBar (CBCGPBaseControlBar* pControlBar,
CBCGPBaseControlBar* pTarget, BOOL bAfter)
{
ASSERT_VALID (this);
return m_dockManager.InsertControlBar (pControlBar, pTarget, bAfter);
}
//*****************************************************************************
void CBCGPMDIFrameWnd::RemoveControlBarFromDockManager (CBCGPBaseControlBar* pControlBar, BOOL bDestroy,
BOOL bAdjustLayout, BOOL bAutoHide)
{
ASSERT_VALID (this);
m_dockManager.RemoveControlBarFromDockManager (pControlBar, bDestroy, bAdjustLayout, bAutoHide);
}
//*****************************************************************************
void CBCGPMDIFrameWnd::DockControlBar (CBCGPBaseControlBar* pBar, UINT nDockBarID,
LPCRECT lpRect)
{
ASSERT_VALID (this);
m_dockManager.DockControlBar (pBar, nDockBarID, lpRect);
}
//*****************************************************************************
CBCGPBaseControlBar* CBCGPMDIFrameWnd::GetControlBar (UINT nID)
{
ASSERT_VALID (this);
CBCGPBaseControlBar* pBar = m_dockManager.FindBarByID (nID, TRUE);
return pBar;
}
//*****************************************************************************
void CBCGPMDIFrameWnd::ShowControlBar (CBCGPBaseControlBar* pBar, BOOL bShow,
BOOL bDelay, BOOL bActivate)
{
ASSERT_VALID (this);
ASSERT_VALID (pBar);
pBar->ShowControlBar (bShow, bDelay, bActivate);
}
//*****************************************************************************
CBCGPBaseControlBar* CBCGPMDIFrameWnd::ControlBarFromPoint (CPoint point,
int nSensitivity, bool bExactBar,
CRuntimeClass* pRTCBarType) const
{
ASSERT_VALID (this);
return m_dockManager.ControlBarFromPoint (point, nSensitivity, bExactBar,
pRTCBarType);
}
//*****************************************************************************
CBCGPBaseControlBar* CBCGPMDIFrameWnd::ControlBarFromPoint (CPoint point,
int nSensitivity, DWORD& dwAlignment,
CRuntimeClass* pRTCBarType) const
{
ASSERT_VALID (this);
return m_dockManager.ControlBarFromPoint (point, nSensitivity, dwAlignment,
pRTCBarType);
}
//*****************************************************************************
BOOL CBCGPMDIFrameWnd::IsPointNearDockBar (CPoint point, DWORD& dwBarAlignment,
BOOL& bOuterEdge) const
{
ASSERT_VALID (this);
return m_dockManager.IsPointNearDockBar (point, dwBarAlignment, bOuterEdge);
}
//*****************************************************************************
void CBCGPMDIFrameWnd::AdjustDockingLayout (HDWP hdwp)
{
ASSERT_VALID (this);
if (m_dockManager.IsInAdjustLayout ())
{
return;
}
m_dockManager.AdjustDockingLayout (hdwp);
AdjustClientArea ();
if (m_dockManager.IsOLEContainerMode ())
{
RecalcLayout ();
}
}
//*****************************************************************************
void CBCGPMDIFrameWnd::AdjustClientArea ()
{
CRect rectClientAreaBounds = m_dockManager.GetClientAreaBounds ();
rectClientAreaBounds.left += m_rectBorder.left;
rectClientAreaBounds.top += m_rectBorder.top;
rectClientAreaBounds.right -= m_rectBorder.right;
rectClientAreaBounds.bottom -= m_rectBorder.bottom;
m_wndClientArea.CalcWindowRect (rectClientAreaBounds, 0);
}
//*****************************************************************************
BOOL CBCGPMDIFrameWnd::OnMoveMiniFrame (CWnd* pFrame)
{
ASSERT_VALID (this);
return m_dockManager.OnMoveMiniFrame (pFrame);
}
//****************************************************************************************
BOOL CBCGPMDIFrameWnd::EnableDocking (DWORD dwDockStyle)
{
return m_dockManager.EnableDocking (dwDockStyle);
}
//****************************************************************************************
BOOL CBCGPMDIFrameWnd::EnableAutoHideBars (DWORD dwDockStyle)
{
return m_dockManager.EnableAutoHideBars (dwDockStyle);
}
//****************************************************************************************
void CBCGPMDIFrameWnd::RecalcLayout (BOOL bNotify)
{
if (m_bInRecalcLayout)
return;
m_bInRecalcLayout = TRUE;
if (!m_bIsMinimized)
{
CView* pView = GetActiveView ();
if (m_dockManager.IsPrintPreviewValid () ||
m_dockManager.IsOLEContainerMode ())
{
if (pView != NULL && pView->IsKindOf (RUNTIME_CLASS (CBCGPPrintPreviewView)))
{
m_dockManager.RecalcLayout (bNotify);
CRect rectClient = m_dockManager.GetClientAreaBounds ();
pView->SetWindowPos (NULL, rectClient.left, rectClient.top,
rectClient.Width (), rectClient.Height (),
SWP_NOZORDER | SWP_NOACTIVATE);
}
else
{
#ifdef _BCGP_USE_OLEIMPL_
COleClientItem* pActiveItem = GetInPlaceActiveItem ();
if (bNotify && pActiveItem != NULL && pActiveItem->m_pInPlaceFrame != NULL)
{
pActiveItem->m_pInPlaceFrame->OnRecalcLayout ();
}
#else
m_bInRecalcLayout = FALSE;
CMDIFrameWnd::RecalcLayout (bNotify);
#endif
AdjustClientArea ();
}
}
else
{
m_dockManager.RecalcLayout (bNotify);
AdjustClientArea ();
}
}
m_bInRecalcLayout = FALSE;
}
//****************************************************************************************
BOOL CBCGPMDIFrameWnd::NegotiateBorderSpace( UINT nBorderCmd, LPRECT lpRectBorder )
{
CRect border, request;
switch (nBorderCmd)
{
case borderGet:
{
CFrameWnd::NegotiateBorderSpace (nBorderCmd, lpRectBorder);
CRect rectBounds = m_dockManager.GetClientAreaBounds ();
ASSERT(lpRectBorder != NULL);
*lpRectBorder = rectBounds;
break;
}
case borderRequest:
return TRUE;
case borderSet:
return CFrameWnd::NegotiateBorderSpace (nBorderCmd, lpRectBorder);
default:
ASSERT(FALSE); // invalid CFrameWnd::BorderCmd
}
return TRUE;
}
//****************************************************************************************
int CBCGPMDIFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_dockManager.Create (this);
return 0;
}
//****************************************************************************************
void CBCGPMDIFrameWnd::OnSizing(UINT fwSide, LPRECT pRect)
{
CMDIFrameWnd::OnSizing(fwSide, pRect);
CRect rect;
GetWindowRect (rect);
if (rect.Size () != CRect (pRect).Size ())
{
AdjustDockingLayout ();
}
}
//****************************************************************************************
LRESULT CBCGPMDIFrameWnd::OnExitSizeMove (WPARAM, LPARAM)
{
m_dockManager.FixupVirtualRects ();
return 0;
}
//*************************************************************************************
void CBCGPMDIFrameWnd::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
{
CBCGPBaseControlBar* pBar = GetControlBar(pCmdUI->m_nID);
if (pBar != NULL)
{
pCmdUI->SetCheck(pBar->IsWindowVisible ());
return;
}
pCmdUI->ContinueRouting();
}
//*************************************************************************************
BOOL CBCGPMDIFrameWnd::OnBarCheck(UINT nID)
{
ASSERT_VALID (this);
CBCGPBaseControlBar* pBar = GetControlBar(nID);
if (pBar != NULL)
{
ShowControlBar(pBar, !pBar->IsWindowVisible (), FALSE, FALSE);
return TRUE;
}
return FALSE;
}
//********************************************************************************
LRESULT CBCGPMDIFrameWnd::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)
{
m_dockManager.SendMessageToMiniFrames (WM_IDLEUPDATECMDUI);
return 0L;
}
//********************************************************************************
void CBCGPMDIFrameWnd::OnSize(UINT nType, int cx, int cy)
{
if (m_bClosing)
{
CMDIFrameWnd::OnSize(nType, cx, cy);
return;
}
m_bIsMinimized = (nType == SIZE_MINIMIZED);
m_dockManager.OnActivateFrame (!m_bIsMinimized);
if (!m_bIsMinimized && nType != SIZE_MAXIMIZED && !m_bWasMaximized)
{
m_dockManager.m_bSizeFrame = TRUE;
AdjustDockingLayout ();
CMDIFrameWnd::OnSize(nType, cx, cy);
m_dockManager.m_bSizeFrame = FALSE;
BOOL bParam = FALSE;
SystemParametersInfo (SPI_GETDRAGFULLWINDOWS, 0, &bParam, 0);
if (!bParam)
{
RecalcLayout ();
}
return;
}
CMDIFrameWnd::OnSize(nType, cx, cy);
if (nType == SIZE_MAXIMIZED || (nType == SIZE_RESTORED && m_bWasMaximized))
{
RecalcLayout ();
}
m_bWasMaximized = (nType == SIZE_MAXIMIZED);
}
//**************************************************************************************
void CBCGPMDIFrameWnd::OnWindowNew()
{
CMDIChildWnd* pActiveChild = MDIGetActive();
if (pActiveChild == NULL)
{
ASSERT (FALSE);
return;
}
ASSERT_VALID (pActiveChild);
BOOL bIsZoomed = FALSE;
if (pActiveChild->IsZoomed ())
{
pActiveChild->ShowWindow (SW_RESTORE);
bIsZoomed = TRUE;
}
CMDIFrameWnd::OnWindowNew();
if (bIsZoomed)
{
pActiveChild = MDIGetActive();
if (pActiveChild != NULL)
{
pActiveChild->ShowWindow (SW_MAXIMIZE);
}
}
}
//**************************************************************************************
void CBCGPMDIFrameWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if (IsFullScreen ())
{
m_Impl.m_FullScreenMgr.OnGetMinMaxInfo (lpMMI);
}
else
{
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -