/** * @file XTPSkinObjectFrame.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPSKINOBJECTFRAME_H__) # define __XTPSKINOBJECTFRAME_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** @cond */ # ifndef WM_NCMOUSELEAVE # define WM_NCMOUSELEAVE 0x02A2 # endif # ifndef WM_QUERYUISTATE # define WM_UPDATEUISTATE 0x0128 # define WM_QUERYUISTATE 0x0129 # define UISF_HIDEACCEL 0x2 # define UISF_HIDEFOCUS 0x1 # endif # define XTP_TID_MOUSELEAVE 0xACB # define XTP_TID_REFRESHFRAME 0xACD # define XTP_REFRESHFRAME_AFFECTED_STYLES WS_DLGFRAME # define XTP_REFRESHFRAME_DURATION 1000 struct _XTP_EXT_CLASS XTP_SKINSCROLLBAR_POSINFO : public XTP_SCROLLBAR_POSINFO { int nBar; BOOL fVisible; }; struct _XTP_EXT_CLASS XTP_SKINSCROLLBAR_TRACKINFO : public XTP_SCROLLBAR_TRACKINFO { BOOL fTrackVert; HWND hWndSB; HWND hWndSBNotify; int nBar; BOOL fNonClient; XTP_SKINSCROLLBAR_POSINFO* pSBInfo; /**< Overwrite XTP_SCROLLBAR_TRACKINFO::pSBInfo */ }; /** @endcond */ /** * @brief * CXTPSkinObjectFrame is a CXTPSkinObject derived class. It is the * parent control for all implementations that have borders or scrollbars. */ class _XTP_EXT_CLASS CXTPSkinObjectFrame : public CXTPSkinObject { /** @cond */ DECLARE_DYNCREATE(CXTPSkinObjectFrame) /** @endcond */ public: /** * @brief * Caption button class. */ class _XTP_EXT_CLASS CCaptionButton { public: /** * @brief * Constructs a CCaptionButton object. * @param nCommand Command ID of the button. * @param pFrame Pointer to the parent frame object. * @param nHTCode Hit test code of the button. * @param m_nClassPart Class part. */ CCaptionButton(int nCommand, CXTPSkinObjectFrame* pFrame, UINT nHTCode, int m_nClassPart); /** * @brief * Destroys a CCaptionButton object. */ virtual ~CCaptionButton(); /** * @brief * This method is called to draw the caption button. * @param pDC Pointer to the device context. * @param bFrameActive TRUE to set the frame to active. */ void Draw(CDC* pDC, BOOL bFrameActive); /** * @brief * Determines the pressed state of the button. * @return * TRUE if the button is pressed, otherwise FALSE. */ BOOL IsPressed() const; /** * @brief * Determines the highlighted state of the button. * @return * TRUE if the button is highlighted, otherwise FALSE. */ BOOL IsHighlighted() const; public: UINT m_nHTCode; /**< Hit test code. */ CRect m_rcButton; /**< Button bounding rectangle. */ int m_nClassPart; /**< Class part. */ CXTPSkinObjectFrame* m_pFrame; /**< Parent frame object. */ int m_nCommand; /**< Button Command. */ BOOL m_bEnabled; }; typedef CArray CCaptionButtons; public: /** * @brief * Constructs a CXTPSkinObjectFrame object. */ CXTPSkinObjectFrame(); /** * @brief * Destroys a CXTPSkinObjectFrame object, handles cleanup and deallocation. */ virtual ~CXTPSkinObjectFrame(); public: /** * @brief * Redraws the scrollbar of the frame. * @param nBar Orientation of the scrollbar; * 1 for vertical, 0 for horizontal. */ void RedrawScrollBar(int nBar); /** * @brief * Gets the borders of the window. * @return * The borders of the window. */ CRect GetBorders() const; /** * @brief * Determines if the caption is active. * @return * TRUE if the caption is active, otherwise FALSE. */ BOOL IsActive() const; /** * @brief * Gets the collection of caption buttons. * @return * A pointer to the collection of caption buttons. */ CCaptionButtons* GetCaptionButtons(); /** * @brief * Gets the client brush. * @param pDC Pointer to the device context. * @return * The client brush. */ virtual HBRUSH GetClientBrush(CDC* pDC); public: /** @cond */ BOOL IsFrameScrollBars(); HBRUSH GetClientBrush(HDC hDC, HWND hWnd, UINT nCtlColor); XTP_SKINSCROLLBAR_TRACKINFO* GetScrollBarTrackInfo() const; BOOL DrawMenuBar(); virtual void UpdateMenuBar(); /** @endcond */ protected: /** * @brief * This method is called when the skin is changed. * @param bPrevState TRUE if the previous skin was installed. * @param bNewState TRUE if the current skin is installed. */ virtual void OnSkinChanged(BOOL bPrevState, BOOL bNewState); /** * @brief * This method is called when visual metrics are changed. */ virtual void RefreshMetrics(); /** * @brief * This method is called when the hook is attached. * @param lpcs Pointer to a LPCREATESTRUCT structure that contains * information about the CWnd object being created. * @param bAuto TRUE to automatically skin the window when a new * window is created or when the user manually skins * the existing window. */ virtual void OnHookAttached(LPCREATESTRUCT lpcs, BOOL bAuto); /** * @brief * This method is called when the hook is detached. * @param bAuto TRUE to automatically skin the window when a new * window is created or when the user manually skins * the existing window. */ void OnHookDetached(BOOL bAuto); /** @cond */ public: void RedrawFrame(); BOOL HasCaption() const; BOOL HasWindowBorder() const; virtual int GetClientBrushMessage(); protected: void UpdateFrameRegion(CSize szFrameRegion); void UpdateButtons(); void InvalidateButtons(); CCaptionButton* HitTestButton(CPoint pt); void UpdateButton(int nID, BOOL bVisible, BOOL bEnabled, UINT htCode, int nClassPart); void RemoveButtons(); void RefreshFrameStyle(); HBRUSH FillBackground(CDC* pDC, LPCRECT lprc, int nMessage = WM_CTLCOLORSTATIC); HBRUSH GetFillBackgroundBrush(CDC* pDC, int nMessage); void ResizeFrame(BOOL bUpdateRegion = TRUE); protected: virtual void DrawFrame(CDC* pDC); void ScreenToFrame(LPPOINT lpPoint); void ClientToFrame(LPPOINT lpPoint); void AdjustFrame(CRect& rc); BOOL OnHookMessage(UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); BOOL OnHookDefWindowProc(UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); using CXTPSkinObject::OnCtlColor; BOOL OnCtlColor(UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult, BOOL bConsiderDlgTexture = FALSE); protected: void DrawScrollBar(CDC* pDC, XTP_SKINSCROLLBAR_POSINFO* pSBInfo); void TrackInit(CPoint point, XTP_SKINSCROLLBAR_POSINFO* pSBInfo, BOOL bDirect); void ContScroll(); void DoScroll(HWND hwnd, HWND hwndNotify, int cmd, int pos, BOOL fVert); void TrackBox(UINT message, CPoint point); void TrackThumb(UINT message, CPoint point); void MoveThumb(int px); int HitTestScrollBar(XTP_SKINSCROLLBAR_POSINFO* pSBInfo, POINT pt); void EndScroll(BOOL fCancel); void CalcScrollBarInfo(LPRECT lprc, XTP_SKINSCROLLBAR_POSINFO* pSBInfo, SCROLLINFO* pSI); void RedrawScrollBar(XTP_SKINSCROLLBAR_POSINFO* pSBInfo); void SetupScrollInfo(XTP_SKINSCROLLBAR_POSINFO* pSBInfo); CRect GetScrollBarRect(int sbCode); void TrackCaptionButton(); BOOL IsSizeBox(); virtual BOOL IsDefWindowProcAvail(int nMessage) const; BOOL PreHookMessage(UINT nMessage); BOOL IsFlatScrollBarInitialized() const; HWND FindMDIClient(); virtual BOOL HandleSysCommand(UINT nID, LPARAM lParam); /** @endcond */ protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPSkinObjectFrame) //}}AFX_VIRTUAL //{{AFX_MSG(CXTPSkinObjectFrame) afx_msg void OnNcPaint(); afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); afx_msg LRESULT OnNcHitTest(CPoint point); afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); afx_msg void OnNcRButtonUp(UINT nHitTest, CPoint point); afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point); afx_msg void HandleTimer(UINT_PTR nIDEvent); afx_msg void OnNcMouseLeave(); afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam); afx_msg BOOL OnNcActivate(BOOL bActive); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); afx_msg void OnPaint(); afx_msg LRESULT OnPrint(WPARAM, LPARAM); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); virtual BOOL HandleMouseMove(CPoint point); virtual LRESULT HandleNcHitTest(CPoint point); afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); afx_msg BOOL OnEraseBkgnd(CDC* pDC); LRESULT CallDefDlgProc(UINT nMessage, WPARAM wParam, LPARAM lParam); static void CALLBACK OnTimerInternal(HWND hWnd, UINT nMsg, UINT_PTR nIDEvent, DWORD dwTime); afx_msg LRESULT OnSetIcon(WPARAM, LPARAM); //}}AFX_MSG /** @endcond */ protected: void CancelMouseLeaveTracking(); HWND GetTopLevelWindow() const; private: void RefreshScrollBarsData(); public: BOOL m_bLockFrameDraw; /**< TRUE to lock draw. */ DWORD m_dwDialogTexture; /**< Dialog texture. */ CXTPSkinObjectFrame* m_pMDIClient; protected: CCaptionButtons m_arrButtons; /**< Caption buttons. */ CRect m_rcBorders; /**< Frame borders. */ CCaptionButton* m_pButtonHot; /**< Hot caption button. */ CCaptionButton* m_pButtonPressed; /**< Pressed caption button. */ BOOL m_bRegionChanged; /**< TRUE if region was changed. */ XTP_SKINSCROLLBAR_TRACKINFO* m_pSBTrack; /**< Track info of scrollbars. */ XTP_SKINSCROLLBAR_POSINFO m_spi[2]; /**< Scrollbar position info. */ CSize m_szFrameRegion; /**< Previous frame region. */ BOOL m_bMDIClient; /**< TRUE if the frame is a MDI client. */ BOOL m_bActive; /**< TRUE if the caption is active. */ DWORD m_dwStyle; /**< Styles of window. */ DWORD m_dwExStyle; /**< ExStyles of window. */ BOOL m_bInUpdateRegion; BOOL m_bInWindowPosChanged; int m_nCtlColorMessage; static CXTPThreadLocal m_bMenuStatus; private: friend class CXTPSkinManager; friend class CCaptionButton; }; AFX_INLINE BOOL CXTPSkinObjectFrame::IsActive() const { return m_bActive; } AFX_INLINE CRect CXTPSkinObjectFrame::GetBorders() const { return m_rcBorders; } /** @cond */ AFX_INLINE XTP_SKINSCROLLBAR_TRACKINFO* CXTPSkinObjectFrame::GetScrollBarTrackInfo() const { return m_pSBTrack; } /** @endcond */ AFX_INLINE CXTPSkinObjectFrame::CCaptionButtons* CXTPSkinObjectFrame::GetCaptionButtons() { return &m_arrButtons; } /** @cond */ AFX_INLINE void CXTPSkinObjectFrame::UpdateMenuBar() { } /** @endcond */ /** * @brief * CXTPSkinObjectUser32Control is a CXTPSkinObjectFrame derived class. * It is the base class for all User32 defined controls. */ class _XTP_EXT_CLASS CXTPSkinObjectUser32Control : public CXTPSkinObjectFrame { protected: /** * @brief * Constructs a CXTPSkinObjectUser32Control object. */ CXTPSkinObjectUser32Control(); protected: /** * @brief * Determines if the scrollbar position was changed. */ virtual void CheckScrollBarsDraw(); protected: /** @cond */ DECLARE_MESSAGE_MAP() // Overrides //{{AFX_VIRTUAL(CXTPSkinObjectUser32Control) BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPSkinObjectUser32Control) afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); //}}AFX_MSG protected: SCROLLINFO m_si[2]; /** @endcond */ }; /** * @brief * CXTPSkinObjectComCtl32Control is a CXTPSkinObjectUser32Control derived class. * It is the base class for all ComCtl32 defined controls. */ class _XTP_EXT_CLASS CXTPSkinObjectComCtl32Control : public CXTPSkinObjectUser32Control { protected: /** * @brief * Constructs a CXTPSkinObjectComCtl32Control object. */ CXTPSkinObjectComCtl32Control(); protected: /** * @brief * Determines if the scrollbar position was changed. */ virtual void CheckScrollBarsDraw(); }; /** * @brief * CXTPSkinObjectSolidFilled is a CXTPSkinObjectFrame derived class. * It is a helper class for unknown window classes that must be filled * with a solid color or brush. */ class _XTP_EXT_CLASS CXTPSkinObjectSolidFilled : public CXTPSkinObjectFrame { public: /** * @brief * Constructs a CXTPSkinObjectSolidFilled object. * @param crFill Color to fill the window background with. */ explicit CXTPSkinObjectSolidFilled(COLORREF crFill); /** * @brief * Constructs a CXTPSkinObjectSolidFilled object. * @param hbrFill Handle of a brush to fill the window background with. */ explicit CXTPSkinObjectSolidFilled(HBRUSH hbrFill); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_MSG(CXTPSkinObjectUser32Control) afx_msg void OnPaint(); afx_msg BOOL OnEraseBkgnd(CDC* pDC); //}}AFX_MSG /** @endcond */ }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSKINOBJECTFRAME_H__) /** @endcond */