// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#pragma once
#include "afxcontrolbarutil.h"
#include "afxframeimpl.h"
#include <__atlmfc_core.h>
#pragma warning(push)
#pragma warning(disable : _ATLMFC_DISABLED_WARNINGS)
#ifdef _AFX_PACKING
#pragma pack(push, _AFX_PACKING)
#endif
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif
class CMDIFrameWndEx;
class CMDIChildWndEx;
class CMDITabProxyWnd : public CWnd
{
DECLARE_DYNCREATE(CMDITabProxyWnd)
public:
CMDITabProxyWnd();
virtual ~CMDITabProxyWnd();
void SetRelatedMDIChildFrame(CMDIChildWndEx* pRelatedMDIFrame);
HBITMAP GetClientBitmap(int nWidth, int nHeight, BOOL bIsThumbnail);
protected:
afx_msg BOOL OnSendIconicThumbnail(int cx, int cy);
afx_msg BOOL OnSendIconicLivePreviewBitmap();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnClose();
DECLARE_MESSAGE_MAP()
BOOL IsMDIChildActive();
CMDIChildWndEx* m_pRelatedMDIChildFrame;
};
/*============================================================================*/
// CMDIChildWndEx frame
class CMDIChildWndEx : public CMDIChildWnd
{
friend class CMDIClientAreaWnd;
friend class CMDIFrameWndEx;
friend class CMDITabProxyWnd;
DECLARE_DYNCREATE(CMDIChildWndEx)
protected:
CMDIChildWndEx(); // protected constructor used by dynamic creation
// Attributes
public:
AFX_IMPORT_DATA static BOOL m_bEnableFloatingBars;
AFX_IMPORT_DATA static DWORD m_dwExcludeStyle;
///
/// A combination of flags, which is passed by the framework to the SetTaskbarTabProperties method,
/// when a tab (MDI child) is being registered with Windows 7 taskbar tabs.
/// The default combination is STPF_USEAPPTHUMBNAILWHENACTIVE | STPF_USEAPPPEEKWHENACTIVE.
AFX_IMPORT_DATA static DWORD m_dwDefaultTaskbarTabPropertyFlags;
BOOL IsTabbedPane() const { return m_pTabbedControlBar != NULL; }
CDockablePane* GetTabbedPane() const { return m_pTabbedControlBar; }
CMDIFrameWndEx* GetMDIFrameWndEx() const { return m_pMDIFrame; }
protected:
// ---- MDITabGroup+
CMFCTabCtrl* m_pRelatedTabGroup;
// ---- MDITabGroup-
BOOL m_bToBeDestroyed;
BOOL m_bWasMaximized;
BOOL m_bIsMinimized;
CRect m_rectOriginal;
// set during OnMDIActivate to prevent unnecessary
// RecalcLayout in CMDIFrameWnd in OLE InPlace mode
BOOL m_bActivating;
BOOL m_bInOnCreate;
CFrameImpl m_Impl;
CDockingManager m_dockManager;
CDockablePane* m_pTabbedControlBar;
CMDIFrameWndEx* m_pMDIFrame;
CMDITabProxyWnd m_tabProxyWnd;
BOOL m_bTabRegistered;
BOOL m_bEnableTaskbarThumbnailClip;
// Operations
public:
// ---- MDITabGroup+
CMFCTabCtrl* GetRelatedTabGroup() { return m_pRelatedTabGroup; }
void SetRelatedTabGroup(CMFCTabCtrl* p) { m_pRelatedTabGroup = p; }
// ---- MDITabGroup-
void AddDockSite();
BOOL AddPane(CBasePane* pControlBar, BOOL bTail = TRUE);
BOOL InsertPane(CBasePane* pControlBar, CBasePane* pTarget, BOOL bAfter = TRUE);
void RemovePaneFromDockManager(CBasePane* pControlBar, BOOL bDestroy, BOOL bAdjustLayout, BOOL bAutoHide, CBasePane* pBarReplacement);
void DockPane(CBasePane* pBar, UINT nDockBarID = 0, LPCRECT lpRect = NULL);
void AddTabbedPane(CDockablePane* pControlBar);
CBasePane* PaneFromPoint(CPoint point, int nSensitivity, bool bExactBar, CRuntimeClass* pRTCBarType) const;
CBasePane* PaneFromPoint(CPoint point, int nSensitivity, DWORD& dwAlignment, CRuntimeClass* pRTCBarType) const;
BOOL IsPointNearDockSite(CPoint point, DWORD& dwBarAlignment, BOOL& bOuterEdge) const;
virtual void AdjustDockingLayout(HDWP hdwp = NULL);
BOOL EnableDocking(DWORD dwDockStyle);
BOOL EnableAutoHidePanes(DWORD dwDockStyle);
CBasePane* GetPane(UINT nID);
void ShowPane(CBasePane* pBar, BOOL bShow, BOOL bDelay, BOOL bActivate);
virtual BOOL OnMoveMiniFrame(CWnd* pFrame);
virtual void RecalcLayout(BOOL bNotify = TRUE);
virtual BOOL GetToolbarButtonToolTipText(CMFCToolBarButton* /*pButton*/, CString& /*strTTText*/) { return FALSE; }
BOOL DockPaneLeftOf(CPane* pBar, CPane* pLeftOf);
///
/// Registers MDI child with Windows 7 taskbar tabs.
/// A pointer to MDI child window whose thumbnail is inserted to the left of.
/// This window must already be registered through RegisterTaskbarTab. If this value is NULL, the new thumbnail is added to the end of the list.
virtual void RegisterTaskbarTab(CMDIChildWndEx* pWndBefore = NULL);
///
/// Returns TRUE if MDI child was successfully registered with Windows 7 taskbar tabs.
///
/// TRUE if MDI child is registered with Windows 7 taskbar tabs; otherwise FALSE.
BOOL IsRegisteredWithTaskbarTabs();
///
/// Invalidates iconic bitmap representation of MDI child.
/// Should be called when the live content or size of MDI child has changed
/// Returns FALSE is Windows 7 taskbar support is disabled or the MDI child
/// is not registered with Windows 7 taskbar tabs; otherwise returns TRUE.
BOOL InvalidateIconicBitmaps();
///
/// Tells whether the MDI child can appear on Windows 7 taskbar tabs.
/// Returns TRUE if MDI child can show on Windows 7 taskbar tabs.
/// Returns TRUE if MDI child can show on Windows 7 taskbar tabs,
/// or FALSE if MDI child can't be shown on Windows 7 taskbar tabs.
BOOL IsTaskbarTabsSupportEnabled();
///
/// Inserts MDI child before specified window on Windows 7 taskbar tabs.
/// A pointer to MDI child window whose thumbnail is inserted to the left of.
/// This window must already be registered through RegisterTaskbarTab. If this value is NULL, the new thumbnail is added to the end of the list.
void SetTaskbarTabOrder(CMDIChildWndEx* pWndBefore = NULL);
///
/// Activates corresponding Windows 7 taskbar tab.
void SetTaskbarTabActive();
///
/// Sets properties for a Windows 7 taskbar tab.
/// A combination of STPFLAG values. See ITaskbarList4::SetTabProperties for details.
void SetTaskbarTabProperties(DWORD dwFlags);
///
/// Removes MDI child from Windows 7 taskbar tabs.
/// Specifies whether this function needs to check the number of MDI children registered with MDI tabs.
/// If this number is 0, then this function removes clipping rectangle from application's taskbar thumbnail.
void UnregisterTaskbarTab(BOOL bCheckRegisteredMDIChildCount = TRUE);
///
/// Returns tab proxy window actually registered with Windows 7 taskbar tabs.
/// A pointer to CMDITabProxyWnd object, which is registered with Windows 7 taskbar tabs.
CMDITabProxyWnd* GetTabProxyWnd() { return &m_tabProxyWnd;}
///
/// Enables or disables automatic selection of a portion of a window's client area to display
/// as that window's thumbnail in the taskbar.
/// Specifies whether to enable (TRUE), or disable (FALSE) automatic selection of a portion of a window's client area to display.
void EnableTaskbarThumbnailClipRect(BOOL bEnable = TRUE);
///
/// Tells whether automatic selection of a portion of a window's client area to display
/// as that window's thumbnail in the taskbar is enabled or disabled.
///
/// Returns TRUE if automatic selection of a portion of a window's client area to display is enabled; otherwise FALSE.
BOOL IsTaskbarThumbnailClipRectEnabled() const { return m_bEnableTaskbarThumbnailClip; }
// Overrides
// Next methods used by MDI tabs:
virtual CString GetFrameText() const;
virtual HICON GetFrameIcon() const;
virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
virtual BOOL CanShowOnMDITabs();
virtual BOOL CanShowOnWindowsList() { return TRUE; }
virtual BOOL IsReadOnly() { return FALSE; }
virtual BOOL IsTabbedMDIChild();
///
/// Updates Windows 7 taskbar tab icon.
/// A handle to an icon to display on Windows 7 taskbar tab.
virtual void UpdateTaskbarTabIcon(HICON hIcon);
///
/// Tells the framework whether this MDI child can be displayed on Windows 7 taskbar tabs.
///
/// Override this method in a derived class and return FALSE to disable appearance of this MDI child
/// on Windows 7 taskbar tabs.
///
/// Should return TRUE if the content of MDI child can be displayed on Windows 7 taskbar thumbnails.
virtual BOOL CanShowOnTaskBarTabs() { return TRUE; }
///
/// Called by the framework when it needs to obtain a bitmap for iconic thumbnail of MDI child.
///
/// If processed, should return a handle to a valid 32bpp bitmap, otherwise NULL.
///
/// Override this method in a derived class an return a valid 32bpp bitmap for iconic thumbnail of MDI child.
/// This method is called only when MDI child is displayed on Windows 7 taskbar tabs.
/// If you return NULL, MFC calls default handlers and obtains bitmaps using PrintClient.
/// Specifies the width of required bitmap.
/// Specifies the height of required bitmap.
virtual HBITMAP OnGetIconicThumbnail(int nWidth, int nHeight)
{
UNREFERENCED_PARAMETER(nWidth);
UNREFERENCED_PARAMETER(nHeight);
return NULL;
}
///
/// Called by the framework when it needs to obtain a bitmap for live preview of MDI child.
///
/// If processed, should return a handle to a valid 32bpp bitmap, otherwise NULL.
///
/// Override this method in a derived class an return a valid 32bpp bitmap for live preview of MDI child.
/// This method is called only when MDI child is displayed on Windows 7 taskbar tabs.
/// If you return NULL, MFC calls default handlers and obtains bitmaps using PrintClient or PrintWindow.
/// This parameter is TRUE if the bitmap is requested for MDI child, which is currently active and the main window is not minimized.
/// The default processing in this case takes a snapshot of the main window.
/// Specifies the location of bitmap in the main (top level) window client coordinated. This point should be provided by callee.
virtual HBITMAP OnGetIconicLivePreviewBitmap(BOOL bIsMDIChildActive, CPoint& ptLocation)
{
UNREFERENCED_PARAMETER(bIsMDIChildActive);
UNREFERENCED_PARAMETER(ptLocation);
return NULL;
}
///
/// Called by the framework when it needs to stretch a bitmap for Windows 7 taskbar tab thumbnail preview of MDI child.
/// Should return TRUE if overridden and processed in a derived class.
/// A handle to a destination bitmap.
/// Specifies the destination rectangle.
/// A handle to a source bitmap.
/// Specifies the source rectangle.
virtual BOOL OnTaskbarTabThumbnailStretch(HBITMAP hBmpDst, const CRect& rectDst, HBITMAP hBmpSrc, const CRect& rectSrc);
///
/// Called by the framework when it needs to obtain a child window (usually a view or splitter window) to be displayed on Windows 7 taskbar tab thumbnail.
///
/// Should return a valid pointer to a CWnd object, whose preview should be displayed on
/// Windows 7 taskbar tab related to this MDI child. The default implementation returns
/// a child window of this MDI child with AFX_IDW_PANE_FIRST control ID (which is usually a CView-derived class).
virtual CWnd* GetTaskbarPreviewWnd();
///
/// Called by the framework when the user presses close button on Taskbar tab thumbnail..
virtual void OnPressTaskbarThmbnailCloseButton();
///
/// Called by the framework when the Taskbar tab thumbnail should process WM_ACTIVATE message.
///
/// The default implementation activates related MDI child frame.
/// Specifies whether the CWnd is being activated or deactivated.
/// Pointer to the CWnd being activated or deactivated. The pointer can be NULL, and it may be temporary.
/// Specifies the minimized state of the CWnd being activated or deactivated. A value of TRUE indicates the window is minimized.
virtual void OnTaskbarTabThumbnailActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
///
/// Called by the framework when the Taskbar tab thumbnail should process WM_MOUSEACTIVATE message.
///
/// The default implementation activates related MDI child frame.
/// Specifies a pointer to the top-level parent window of the window being activated. The pointer may be temporary and should not be stored.
/// Specifies the hit-test area code. A hit test is a test that determines the location of the cursor.
/// Specifies the mouse message number.
virtual int OnTaskbarTabThumbnailMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
///
/// Called by the framework when it needs to select a portion of a window's client area to display
/// as that window's thumbnail in the taskbar.
/// A rectangle in windows coordinates. This rectangle will be mapped to the client area of top level frame.
/// The rectangle should be empty to clear the clipping rectangle
virtual CRect GetTaskbarThumbnailClipRect() const;
CDockingManager* GetDockingManager() { return &m_dockManager; }
virtual LPCTSTR GetDocumentName(CObject** pObj);
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void ActivateFrame(int nCmdShow = -1);
virtual void OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
///
/// Called internally by the framework to set clipping rectangle to select a portion of a window's client area to display
/// as that window's thumbnail in the taskbar.
/// Specifies the new clipping rectangle. If rectangle is empty or null, the clipping is removed.
/// Returns TRUE if the functions succeeds; otherwise FALSE.
virtual BOOL SetTaskbarThumbnailClipRect(CRect rect);
// Implementation
protected:
virtual ~CMDIChildWndEx();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
afx_msg void OnDestroy();
afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
afx_msg void OnNcPaint();
afx_msg BOOL OnNcActivate(BOOL bActive);
afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
afx_msg LRESULT OnNcHitTest(CPoint point);
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg int OnSetText(LPCTSTR lpszText);
afx_msg HICON OnSetIcon(BOOL bIsLarge, HICON hIcon);
afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM wParam = 0, LPARAM lParam = 0);
afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg LRESULT OnChangeVisualManager(WPARAM wParam, LPARAM lParam);
afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point);
#if (NTDDI_VERSION >= NTDDI_WIN7)
afx_msg void OnSendIconicThumbnail(WPARAM wParam, LPARAM lParam);
afx_msg void OnSendIconicLivePreviewBitmap(WPARAM wParam, LPARAM lParam);
#endif
DECLARE_MESSAGE_MAP()
void AdjustClientArea();
///
/// Called internally by the framework to activate top level frame when the application should be activated
/// from a taskbar tab.
virtual void ActivateTopLevelFrame();
///
/// Called internally by the framework to set text of taskbar tab.
/// Specifies a text to set. Current implementation adds this text to application name if the MDI child has FWS_ADDTOTITLE style.
virtual void SetTaskbarTabText(LPCTSTR lpcszDefaultText);
};
extern AFX_IMPORT_DATA UINT AFX_WM_AFTER_TASKBAR_ACTIVATE;
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif
#ifdef _AFX_PACKING
#pragma pack(pop)
#endif
// _ATLMFC_DISABLED_WARNINGS
#pragma warning(pop)