/** * @file XTPControlCustom.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(__XTPCONTROLCUSTOM_H__) # define __XTPCONTROLCUSTOM_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCommandBars; /** * @brief * Vertical options enumerator. * * Example: *
* CXTPControlCustom* pControl = (CXTPControlCustom*)pToolBar->GetControls()->Add(xtpControlCustom, * ID_VIEW_LOGO); * pControl->SetVerticalPositionOption(xtpVerticalShow); ** @see * CXTPControlCustom::SetVerticalPositionOption, xtpVerticalHide, xtpVerticalShow, xtpVerticalButton */ enum XTPControlCustomVerticalOptions { xtpVerticalHide, /**< To hide control if parent toolbar vertically docked.*/ xtpVerticalShow, /**< To show control if parent toolbar vertically docked.*/ xtpVerticalButton /**< To show control as button.*/ }; /** * @brief * CXTPControlCustom is a CXTPControlButton derived class. It represents * the control with some child window. */ class _XTP_EXT_CLASS CXTPControlCustom : public CXTPControlButton , public CXTPHookManagerHookAble { public: /** * @brief * Constructs a CXTPControlCustom object. */ CXTPControlCustom(); /** * @brief * Destroys a CXTPControlCustom object, handles cleanup and deallocation. */ ~CXTPControlCustom(); public: /** * @brief * Call this method to create a new CXTPControlCustom object with * pWndChild as a child window. * @param pWndChild Pointer to the child window. * @return * Pointer to new CXTPControlCustom object. */ static CXTPControlCustom* AFX_CDECL CreateControlCustom(CWnd* pWndChild); public: /** * @brief * Call this method to attach the window to the control. * @param pWnd Pointer to a child CWnd object. */ void SetControl(CWnd* pWnd); /** * @brief * Call this method to retrieve the child window of the control. * @return * A pointer to a CWnd object. */ CWnd* GetControl(); /** * @brief * This method sets the child window size. * @param szControl Size of the child window. */ void SetSize(CSize szControl); /** * @brief * This method sets the margins of the child window. * @param cxRight Right border gap. * @param cxTop Top border gap. * @param cxLeft Left border gap. * @param cxBottom Bottom border gap. */ void SetBorders(int cxRight, int cxTop, int cxLeft, int cxBottom); /** * @brief * Call this method to set vertical options to the control. * @param options XTPControlCustomVerticalOptions type to be set. * Can be any of the values listed in the Remarks section. * @details * Vertical options refer to how the control will be displayed * when the toolbar it docked vertically. It can be one of the following: * xtpVerticalHide: To hide control. * xtpVerticalShow: To show control. * xtpVerticalButton: To show control as button. * @see * XTPControlCustomVerticalOptions */ void SetVerticalPositionOption(XTPControlCustomVerticalOptions options); /** * @brief * This method is called when the control's enabled state is changed. */ virtual void OnEnabledChanged(); protected: /** * @brief * Call this member to set the bounding rectangle of the control. * @param rcControl Bounding rectangle of the control. */ virtual void SetRect(CRect rcControl); /** * @brief * This method is called to determine the size of the control. * @param pDC Pointer to a valid device context * @return * A CSize object containing the size of the control. */ virtual CSize GetSize(CDC* pDC); /** * @brief * This method is called to draw the control. * @param pDC Pointer to a valid device context. */ virtual void Draw(CDC* pDC); /** * @brief * This method is called to hide the control. * @param dwFlags Reasons to hide. * @see * XTPControlHideFlags */ virtual void SetHideFlags(DWORD dwFlags); /** * @brief * This method is called when the action property is changed. * @param nProperty Property of the action. * @see * OnActionChanging */ virtual void OnActionChanged(int nProperty); /** * @brief * This method is called before recalculating the parent command * bar size to calculate the dimensions of the control. * @param dwMode Flags used to determine the height and width of the * dynamic command bar. See Remarks section for a list of * values. * @details * The following predefined flags are used to determine the height and * width of the dynamic command bar. Use the bitwise-OR (|) operator to * combine the flags. * * LM_STRETCH: Indicates whether the command bar should be * stretched to the size of the frame. Set if the bar is * not a docking bar (not available for docking). Not set * when the bar is docked or floating (available for * docking). If set, LM_STRETCH returns dimensions based * on the LM_HORZ state. LM_STRETCH works similarly to * the the bStretch parameter used in CalcFixedLayout; * see that member function for more information about * the relationship between stretching and orientation. * LM_HORZ: Indicates that the bar is horizontally or * vertically oriented. Set if the bar is horizontally * oriented, and if it is vertically oriented, it is not * set. LM_HORZ works similarly to the the bHorz * parameter used in CalcFixedLayout; see that member * function for more information about the relationship * between stretching and orientation. * LM_MRUWIDTH: Most Recently Used Dynamic Width. Uses the * remembered most recently used width. * LM_HORZDOCK: Horizontal Docked Dimensions. Returns the * dynamic size with the largest width. * LM_VERTDOCK: Vertical Docked Dimensions. Returns the dynamic * size with the largest height. * LM_COMMIT: Resets LM_MRUWIDTH to current width of * floating command bar. * * The framework calls this member function to calculate the dimensions * of a dynamic command bar. * * Override this member function to provide your own layout in classes * you derive from CXTPControl. XTP classes derived from CXTPControl, * such as CXTPControlComboBox, override this member function to provide * their own implementation. * @see * CXTPControlComboBox, CXTPControl, CXTPControlEdit, * CXTPControlWindowList, CXTPControlWorkspaceActions, CXTPControlToolbars, * CXTPControlOleItems, CXTPControlRecentFileList, CXTPControlSelector, * CXTPControlListBox */ virtual void OnCalcDynamicSize(DWORD dwMode); /** * @brief * Either eads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ virtual void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * This method is called to copy the control. * @param pControl Pointer to a source CXTPControl object * @param bRecursive TRUE to copy recursively. */ virtual void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE); /** * @brief * This method is called when the user clicks the control. * @param bKeyboard TRUE if the control is selected using the keyboard. * @param pt Mouse cursor position. */ virtual void OnClick(BOOL bKeyboard = FALSE, CPoint pt = CPoint(0, 0)); /** * @brief * The implementation may implement a custom drag over handling logic in this method. * @param pCommandBar Pointer to a CXTPCommandBar object. * @param point Mouse position. * @param dropEffect DROPEFFECT enumerator. * @return * TRUE if custom implementation handles drag over, otherwise FALSE. */ virtual BOOL DoCustomDragOver(CXTPCommandBar* pCommandBar, CPoint point, DROPEFFECT& dropEffect); /** * @brief * This member function is called by WindowProc, or is called * during message reflection. * @param hWnd Window handle that the message belongs to. * @param nMessage Specifies the message to be sent. * @param wParam Specifies additional message-dependent information. * @param lParam Specifies additional message-dependent information. * @param lResult The return value of WindowProc. Depends on the message; * may be NULL. * @return A non-zero value if a hooked message is processed, 0 otherwise. */ int OnHookMessage(HWND hWnd, UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); /** * @brief * This method is called when a control is removed from the * parent controls collection. */ virtual void OnRemoved(); private: CWnd* FindChildWindow(CXTPCommandBars* pCommandBars, UINT nID); void ShowHideChildControl(); protected: HWND m_hwndControl; /**< The child window. */ CRect m_rcBorders; /**< Borders. */ BOOL m_bControlVisible; /**< TRUE if child window is visible. */ CSize m_szControl; /**< Size of the control. */ XTPControlCustomVerticalOptions m_verticalOptions; /**< Vertical options. */ int m_nControlID; /**< ID of the custom control. */ public: # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() afx_msg long OleGetHandle(); afx_msg void OleSetHandle(long nHandle); enum { dispidHandle = 50L, }; DECLARE_OLETYPELIB_EX(CXTPControlCustom); void OleSetSize(int, int); /** @endcond */ # endif DECLARE_XTP_CONTROL(CXTPControlCustom) }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPCONTROLCUSTOM_H__) /** @endcond */