/** * @file XTPComboBox.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(__XTPCOMBOBOX_H__) # define __XTPCOMBOBOX_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPComboBoxTheme; class CXTPComboBoxEditCtrl; class CXTPMarkupContext; /** * @brief * The CXTPComboBox class provides the functionality of a themed Windows combobox. */ class _XTP_EXT_CLASS CXTPComboBox : public CComboBox { /** @cond */ DECLARE_DYNAMIC(CXTPComboBox) /** @endcond */ public: /** * @brief * Constructs a CXTPComboBox object. */ CXTPComboBox(); /** * @brief * Destroys a CXTPComboBox object, handles cleanup and deallocation. */ virtual ~CXTPComboBox(); /** * @brief * Call this member function to initialize the combobox. This method * should be called directly after creating or sub-classing the control. * @param bAutoFont true to enable automatic font initialization. */ virtual void Initialize(bool bAutoFont = true); /** * @brief * Call this member function to switch the visual theme of the control. * @param nTheme New visual theme. Can be any of the values listed * in the Remarks section. * @return * TRUE if successful, otherwise FALSE. * @details * nTheme can be one of the theme IDs specified by XTPControlTheme. * @see * XTPControlTheme */ BOOL SetTheme(XTPControlTheme nTheme); /** * @brief * This member function is called to set the theme for the combobox * control using the theme specified by pTheme. * @param pTheme Pointer to a valid CXTPComboBox theme object. */ virtual void SetTheme(CXTPComboBoxTheme* pTheme); /** * @brief * Call this member function to retrieve a pointer to the current * theme used by the combobox. * @return * A CXTPComboBoxTheme pointer, or NULL if no theme is set. */ CXTPComboBoxTheme* GetTheme(); /** * @brief * Call this member function to retrieve a pointer to the current * theme used by the combobox. * @return * A CXTPComboBoxTheme pointer, or NULL if no theme is set. */ const CXTPComboBoxTheme* GetTheme() const; /** * @brief * Redraws the button. * @param bUpdateWindow TRUE to notify the parent window. */ void RedrawComboBox(BOOL bUpdateWindow = FALSE); /** * @brief * Gets the flat style appearance of the combobox. * @details * The control will appear flat until the mouse pointer moves * over it, at which point it appears three-dimensional. * @return * TRUE if the flat style is used, otherwise FALSE. */ BOOL GetFlatStyle() const; /** * @brief * Sets the flat style appearance of the button control. * @param bFlatStyle TRUE to use the flat style, otherwise FALSE. * @details * The control will appear flat until the mouse pointer moves * over it, at which point it appears three-dimensional. */ void SetFlatStyle(BOOL bFlatStyle = TRUE); /** * @brief * Determines if the control is drawn using visual styles/SkinFramework, * if supported. * @details * This method enables Windows XP visual styles for the control. * This Control will draw using visual styles if both the control * and the operating system support it. * Visual styles and SkinFramework skins are specifications for * the appearance of controls. GetUseVisualStyle determines whether * to use the currently set Windows XP visual style. If using * SkinFramework, then it determines whether to use the currently set * style of the SkinFramework. * @return * TRUE if the currently set Windows XP visual style will be used to * theme the control. If using SkinFramework, then the currently set * style of the SkinFramework will be used to skin the control. * FALSE if the currently set appearance/style in the OS will be used. */ BOOL GetUseVisualStyle() const; /** * @brief * Enables Windows XP visual styles for the control. * @details * This method enables Windows XP visual styles for the control. * This Control will draw using visual styles if both the control * and the operating system support it. * Visual styles and SkinFramework skins are specifications for * the appearance of controls. GetUseVisualStyle determines whether * to use the currently set Windows XP visual style. If using * SkinFramework, then it determines whether to use the currently set * style of the SkinFramework. * @param bUseVisualStyle TRUE if the currently set Windows XP visual style * will be used to theme the control. If using * SkinFramework, then the currently set style of the * SkinFramework will be used to skin the control. * FALSE if the currently set appearance/style in the * OS will be used. */ void SetUseVisualStyle(BOOL bUseVisualStyle = TRUE); /** * @brief * This member function enables/disables auto-completion. * @param bEnable TRUE to enable auto-completion, FALSE to disable auto-completion. * By default, this parameter is TRUE. */ void EnableAutoCompletion(BOOL bEnable = TRUE); /** * @brief * Call this member function to set the background color * for the CXTPComboBox control. * @param crBack An RGB color value representing the background color * for the CXTPComboBox control. * @see * SetTextColor, GetBackColor, GetTextColor */ virtual void SetBackColor(COLORREF crBack); /** * @brief * Call this member function to retrieve the background color * of the CXTPComboBox control. * @return * An RGB color value representing the background color * of the CXTPComboBox control. * @see * SetTextColor, SetBackColor, GetTextColor */ COLORREF GetBackColor() const; /** * @brief * Call this member function to set the text color * for the CXTPComboBox control. * @param crText An RGB value representing the text color * for the CXTPComboBox control. * @see * SetBackColor, GetBackColor, GetTextColor */ virtual void SetTextColor(COLORREF crText); /** * @brief * Call this member function to retrieve the text color * of the CXTPComboBox control. * @return * An RGB color value representing the text color * of the CXTPComboBox control. * @see * SetTextColor, SetBackColor, GetBackColor */ COLORREF GetTextColor() const; /** * @brief * This member function is called to update the color, text, and other * visual elements of the control. */ void RefreshMetrics(); /** * @brief * Call this member function to determine if the combobox has * input focus. * @return * TRUE if the combobox has input focus, otherwise FALSE. */ BOOL IsFocused() const; /** * @brief * Call this member function to determine if the combobox state * is highilghted, meaning that the mouse cursor is currently * hovering over the control. * @return * TRUE if the combobox state is highlighted, otherwise FALSE. */ BOOL IsHighlighted() const; /** * @brief * Call this member function to determine if the combobox is * currently dropped down. * @details Prefer calling this method intead of getting result of CB_GETDROPPEDSTATE message * which may produce false positive results. * @return * TRUE if the combobox state is dropped down. */ BOOL IsDroppedDown() const; /** * @brief * Call this member function to retrieve a handle to the client * background brush. * @param pDC Pointer to a valid device context. * @return * A HBRUSH handle representing the client background brush. */ HBRUSH GetClientBrush(CDC* pDC); /** * @brief * Call this member function to retrieve the size of the combobox * in client coordinates. * @return * A CRect object representing the client size for the combobox. */ CRect GetComboBoxRect() const; /** * @brief * This member fuction is called to set the highlighted state for * the combobox. * @param bHot TRUE to set the combobox state to highlighted. */ void SetHighlighted(BOOL bHot); protected: /** * @brief * Called by the framework to redraw the focused frame for the combobox. */ void RedrawFocusedFrame(); /** * @brief * Called by the framework to determine if the combobox needs to be redrawn. * @return * TRUE if the combobox needs to be redrawn. */ BOOL NeedRedraw(); /** @cond */ //{{AFX_VIRTUAL(CXTPComboBox) virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual void PreSubclassWindow(); virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL virtual void Init(); //{{AFX_MSG(CXTPComboBox) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnPaint(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnSysColorChange(); afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); // reflect message afx_msg BOOL OnEditUpdate(); afx_msg BOOL OnCloseUp(); afx_msg BOOL OnDropDown(); afx_msg void OnMouseLeave(); //}}AFX_MSG afx_msg LRESULT OnSetTheme(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() /** @endcond */ protected: BOOL m_bPreSubclassInit; /**< TRUE if the control has been subclassed. */ BOOL m_bUseVisualStyle; /**< TRUE to use Windows themes. */ BOOL m_bFlatStyle; /**< TRUE to draw the control using flat styles. This is mostly deprecated; use SetTheme() instead. */ BOOL m_bHighlighted; /**< TRUE when the combobox is highlighted. */ BOOL m_bFocused; /**< TRUE when the combobox has input focus. */ BOOL m_bAutoComp; /**< TRUE when the combobox is using the auto-complete feature. */ BOOL m_bDisableAC; /**< TRUE to disable auto-complete temporarily. */ CXTPComboBoxTheme* m_pTheme; /**< Pointer to the current theme object. */ CXTPComboBoxEditCtrl* m_pWndEdit; /**< Pointer to the edit-control for the combobox. */ private: friend class CXTPComboBoxEditCtrl; protected: BOOL m_bEnableMarkup; /**< TRUE to enable markup. */ CXTPMarkupContext* m_pMarkupContext; /**< Markup context. */ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); public: /** * @brief * Allows the use of a XAML snippet to be used for the text of * panes in the control. * @param bEnableMarkup TRUE to enable markup, FALSE to disable markup. */ void EnableMarkup(BOOL bEnableMarkup = TRUE); }; ///////////////////////////////////////////////////////////////////////////// /** @cond */ AFX_INLINE BOOL CXTPComboBox::GetUseVisualStyle() const { return m_bUseVisualStyle; } AFX_INLINE BOOL CXTPComboBox::IsFocused() const { return m_bFocused; } AFX_INLINE BOOL CXTPComboBox::IsHighlighted() const { return m_bHighlighted; } AFX_INLINE BOOL CXTPComboBox::GetFlatStyle() const { return m_bFlatStyle; } AFX_INLINE void CXTPComboBox::SetFlatStyle(BOOL bFlatStyle /* = TRUE*/) { m_bFlatStyle = bFlatStyle; if (m_hWnd) Invalidate(FALSE); } AFX_INLINE void CXTPComboBox::EnableAutoCompletion(BOOL bEnable /*=TRUE*/) { m_bAutoComp = bEnable; } /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // #if !defined(__XTPCOMBOBOX_H__) /** @endcond */