/** * @file XTPResize.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(__XTPRESIZE_H__) # define __XTPRESIZE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * Enumeration used to determine attributes for resizing windows. * @details * XTPResize type defines the constants used by the CXTPResize * class to determine how a window will appear when it is resized. * @see * CXTPResize * * @see xtpResizeNoSizeIcon, xtpResizeNoHorizontal, xtpResizeNoVertical, xtpResizeNoMinsize, * xtpResizeNoClipChildren, xtpResizeNoTransparentGroup */ enum XTPResize { xtpResizeNoSizeIcon = 0x01, /**< Do not add size icon. */ xtpResizeNoHorizontal = 0x02, /**< No horizontal resizing. */ xtpResizeNoVertical = 0x04, /**< No vertical resizing. */ xtpResizeNoMinsize = 0x08, /**< Do not require a minimum size. */ xtpResizeNoClipChildren = 0x10, /**< Do not set clip children style. */ xtpResizeNoTransparentGroup = 0x20 /**< Do not set transparent style for group boxes. */ }; class CXTPResize; /** * @brief * CXTPResizeItem is a standalone helper class. It is used by CXTPResize to * maintain information about each item to be sized or moved. */ class _XTP_EXT_CLASS CXTPResizeItem { public: /** * @brief * Constructs a CXTPResizeItem object. * @param pWnd Pointer to the window to be sized or moved. * @param rrcSizing Reference to a CXTPResizeRect object. * @param rcWindow Reference to a CRect object. * @param bAutoDelete TRUE if the window is to be deleted. */ CXTPResizeItem(CWnd* pWnd, const CXTPResizeRect& rrcSizing, CRect& rcWindow, BOOL bAutoDelete); /** * @brief * Destroys a CXTPResizeItem object, handles cleanup and deallocation. */ virtual ~CXTPResizeItem(); public: /** * @brief * Called by CXTPResize to make group box controls window style * transparent. * @param pXTPResize Pointer to the resize manager. * @return * true if the WS_EX_TRANSPARENT style was set for the window, * otherwise false. */ virtual bool MakeTransparent(CXTPResize* pXTPResize); public: BOOL m_bIsGroupBox; /**< TRUE if the window is a group box. */ BOOL m_bAutoDelete; /**< TRUE if the window is to be deleted. */ BOOL m_bInitialSize; /**< Initial size/move has been completed. */ CWnd* m_pWnd; /**< A pointer to the window to be sized or moved. */ CXTPResizeRect m_rrcSizing; /**< Sizing option. */ CXTPResizeRect m_rrcWindow; /**< Last control size. */ CXTPResizeRect m_rrcInitWindow; /**< Initial control size. */ }; /** * @brief * The CXTPSizeIcon class is a CStatic derived helper class. It is used * by CXTPResize to display the sizing grip in the lower right corner of * a sizing window. */ class _XTP_EXT_CLASS CXTPSizeIcon : public CScrollBar { public: /** * @brief * Constructs a CXTPSizeIcon object. */ CXTPSizeIcon(); /** * @brief * Destroys a CXTPSizeIcon object, handles cleanup and deallocation. */ virtual ~CXTPSizeIcon(); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_MSG(CXTPSizeIcon) afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg void OnSetFocus(CWnd* pOldWnd); //}}AFX_MSG /** @endcond */ protected: HCURSOR m_hCursor; /**< Handle to the cursor displayed for the size icon. */ }; /** * @brief * CXTPResize is a base class. It is used by resizing dialogs, property * sheets, and form views. It acts as a manager to maintain the size and location * of the dialog and dialog items. */ class _XTP_EXT_CLASS CXTPResize { public: /** * @brief * Constructs a CXTPResize object. * @param pWnd Pointer to the parent or owner window object, of type CWnd, * to which the resizing object belongs. * @param nFlags Flags that are to be passed to CXTPResize that specify the * attributes of the resizing property page. See the Remarks * section for a list of flags. * @details * Styles to be added or removed can be combined by using the bitwise * OR (|) operator. It can be one or more of the following: * xtpResizeNoSizeIcon: Do not add size icon. * xtpResizeNoHorizontal: No horizontal resizing. * xtpResizeNoVertical: No vertical resizing. * xtpResizeNoMinsize: Do not require a minimum size. * xtpResizeNoClipChildren: Do not set clip children style. * xtpResizeNoTransparentGroup: Do not set transparent style * for group boxes. */ CXTPResize(CWnd* pWnd, const UINT nFlags = 0); /** * @brief * Destroys a CXTPResize object, handles cleanup and deallocation. */ virtual ~CXTPResize(); public: /** * @brief * The SetResize function specifies how much each side of a control will * move when the dialog is resized. If a control should be repositioned * (e.g. an OK button), then all four sides should move by the same amount * of pixels, as the dialog is resized. If a control should be resized * just as much as the dialog (e.g. the list control in the file dialog), * then the left and top sides shouldn't move, and the right and bottom * sides should move by the same amount of pixels as the dialog. * @param nID Specifies the control's ID. * @param left How much the left side will move when the dialog is resized. * @param top How much the top side will move when the dialog is resized. * @param right How much the right side will move when the dialog is resized. * @param bottom How much the bottom side will move when the dialog is resized. */ void SetResize(UINT nID, XTP_RESIZE left, XTP_RESIZE top, XTP_RESIZE right, XTP_RESIZE bottom); /** * @brief * The SetResize function specifies how much each side of a control will * move when the dialog is resized. If a control should be repositioned * (e.g. an OK button), then all four sides should move by the same amount * of pixels, as the dialog is resized. If a control should be resized * just as much as the dialog (e.g. the list control in the file dialog), * then the left and top sides shouldn't move, and the right and bottom * sides should move by the same amount of pixels as the dialog. * @param nID Specifies the control's ID. * @param rrcSizing How much the left, top, right, and bottom sides will move * when the dialog is resized. */ void SetResize(UINT nID, const XTP_RESIZERECT& rrcSizing); /** * @brief * The SetResize function specifies how much each side of a control will * move when the dialog is resized. If a control should be repositioned * (e.g. an OK button), then all four sides should move by the same amount * of pixels, as the dialog is resized. If a control should be resized * just as much as the dialog (e.g. the list control in the file dialog), * then the left and top sides shouldn't move, and the right and bottom * sides should move by the same amount of pixels as the dialog. * @param nID Specifies the control's ID, or 0 to use control's handle * value only. * @param hWnd HWND of the dialog item to be sized. * @param rrcSizing How much the left, top, right, and bottom sides will move * when the dialog is resized. */ void SetResize(UINT nID, HWND hWnd, const XTP_RESIZERECT& rrcSizing); /** * @brief * The SetResize function specifies how much each side of a control will * move when the dialog is resized. If a control should be repositioned * (e.g. an OK button), then all four sides should move by the same amount * of pixels, as the dialog is resized. If a control should be resized * just as much as the dialog (e.g. the list control in the file dialog), * then the left and top sides shouldn't move, and the right and bottom * sides should move by the same amount of pixels as the dialog. * @param nID Specifies the control's ID, or 0 to use control's handle * value only. * @param hWnd HWND of the dialog item to be sized. * @param rpTopLeft How much the top and left sides will move when the dialog * is resized. * @param rpBottomRight How much the bottom and right sides will move when the dialog * is resized. */ void SetResize(UINT nID, HWND hWnd, const XTP_RESIZEPOINT& rpTopLeft, const XTP_RESIZEPOINT& rpBottomRight); /** * @brief * The SetResize function specifies how much each side of a control will * move when the dialog is resized. If a control should be repositioned * (e.g. an OK button), then all four sides should move by the same amount * of pixels, as the dialog is resized. If a control should be resized * just as much as the dialog (e.g. the list control in the file dialog), * then the left and top sides shouldn't move, and the right and bottom * sides should move by the same amount of pixels as the dialog. * @param nID Specifies the control's ID. * @param rpTopLeft How much the top and left sides will move when the dialog * is resized. * @param rpBottomRight How much the bottom and right sides will move when the dialog * is resized. */ void SetResize(UINT nID, const XTP_RESIZEPOINT& rpTopLeft, const XTP_RESIZEPOINT& rpBottomRight); /** * @brief * This member function sets the minimum size explicitly. Initial size * is the default. * @param sz Specifies the minimum width and height the dialog can be sized to. */ void SetMinSize(CSize& sz); /** * @brief * This member function sets the maximum size. No maximum is the default. * @param sz Specifies the maximum width and height the dialog can be sized to. */ void SetMaxSize(CSize& sz); /** * @brief * This member function saves the window placement to the registry. * @param pszSection Name of a section in the initialization file or a key in the * Windows registry where placement information is stored. * @return * TRUE if successful. */ BOOL SavePlacement(LPCTSTR pszSection); /** * @brief * This member function loads saved window placement information from * the registry. * @param pszSection Name of a section in the initialization file or a key in the * Windows registry where placement information is stored. * @return * TRUE if the position was changed. */ BOOL LoadPlacement(LPCTSTR pszSection); /** * @brief * This member function loads saved window placement information from * the registry. This version is the same as LoadPlacement but there * is no need for calling SavePlacement when the window is destroyed. * This will be called automatically. * @param pszSection Name of a section in the initialization file or a key in the * Windows registry where placement information is stored. * @return * TRUE if the position was changed. */ BOOL AutoLoadPlacement(LPCTSTR pszSection); protected: /** * @brief * The SetResize function specifies how much each side of a control will * move when the dialog is resized. If a control should be repositioned * (e.g. an OK button), then all four sides should move by the same amount * of pixels, as the dialog is resized. If a control should be resized * just as much as the dialog (e.g. the list control in the file dialog), * then the left and top sides shouldn't move, and the right and bottom * sides should move by the same amount of pixels as the dialog. * @param pWnd Pointer to the dialog item to be resized. * @param rrcSizing How much the left, top, right, and bottom sides will move * when the dialog is resized. * @param rcWindow Initial size of the dialog item. */ void SetResize(CWnd* pWnd, const CXTPResizeRect& rrcSizing, CRect rcWindow); /** * @brief * This member function is called to remove the specified dialog item * from the list of items to be resized. * @param nID Specifies the control's ID. * @return * TRUE if successful, otherwise FALSE. */ BOOL RemoveResize(UINT nID); /** * @brief * This member function is called to purge the list that contains the dialog * items to be sized. */ void RemoveAllControls(); /** * @brief * This member function is called from OnInitDialog or OnInitialUpdate * to initialize the resize manager. */ virtual void Init(); /** * @brief * This member function is called from OnSize to move and resize the dialog * items that are managed. */ virtual void Size(); /** * @brief * This member function is called when a property sheet in wizard mode * has changed pages to alert the resize manager that the property sheet * (common control) has moved the page back to its original size/position * on the sheet. */ void Reset(); /** * @brief * Called to offset dialog items by the amount specified by ptOffset. * @param ptOffset CPoint determines the amount, in pixels, to offset * dialog items. */ void Offset(CPoint ptOffset); /** * @brief * Call this method to reset m_rrcWindow for an item. * @param pWnd Window to reset. */ void UpdateControlRect(CWnd* pWnd); /** * @brief * This member function is called from OnGetMinMaxInfo to get the * maximized position or dimensions or the minimum or maximum tracking * size. The maximized size is the size of the window when its borders * are fully extended. The maximum tracking size of the window is the * largest window size that can be achieved by using the borders to size * the window. The minimum tracking size of the window is the smallest * window size that can be achieved by using the borders to size the window. * @param pMMI Pointer to a MINMAXINFO structure that contains information about a * window's maximized size and position and its minimum and maximum * tracking size. For more information about this structure, see the * MINMAXINFO structure. */ void GetMinMaxInfo(MINMAXINFO* pMMI); /** * @brief * This method is called in the Size method to adjust a window rectangle to * fit real client size. * @param rcWindow Window rectangle to change. */ virtual void AdjustResizeRect(CSize& rcWindow); protected: // flags /** * @brief * This member function is called to determine if the specified flag * has been set for the resize manager. * @param eFlag Flag to check. It can be one of the values in the Remarks section. * @details * Styles to be added can one of the following: * xtpResizeNoSizeIcon: Do not add size icon. * xtpResizeNoHorizontal: No horizontal resizing. * xtpResizeNoVertical: No vertical resizing. * xtpResizeNoMinsize: Do not require a minimum size. * xtpResizeNoClipChildren: Do not set clip children style. * xtpResizeNoTransparentGroup: Do not set transparent style * for group boxes. * @return * TRUE if the specified flag has been set, otherwise FALSE. */ BOOL HasFlag(XTPResize eFlag); /** * @brief * This member function is called to set a specific flag for the resize * manager. * @param eFlag Flag to check. It can be one of the values in the Remarks section. * @details * Styles to be added can one of the following:
* xtpResizeNoSizeIcon: Do not add size icon. * xtpResizeNoHorizontal: No horizontal resizing. * xtpResizeNoVertical: No vertical resizing. * xtpResizeNoMinsize: Do not require a minimum size. * xtpResizeNoClipChildren: Do not set clip children style. * xtpResizeNoTransparentGroup: Do not set transparent style * for group boxes. */ void SetFlag(XTPResize eFlag); protected: // helper methods /** * @brief * Called by CXTPResize to resize a child window. * @param hdwp [in] Handle to a multiple-window position structure that contains * size and position information for one or more windows. This * structure is returned by BeginDeferWindowPos or by the most recent * call to DeferWindowPos. * @param pItem [in] Pointer to a CXTPResizeItem object that contains additional * information about the window being sized. * @param dx [in] Specifies the window's new width, in pixels. * @param dy [in] Specifies the window's new height, in pixels. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL Defer(HDWP& hdwp, CXTPResizeItem* pItem, int dx, int dy); protected: typedef CArray