/** * @file XTPControlComboBox.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(__XTPCONTOLCOMBOBOX_H__) # define __XTPCONTOLCOMBOBOX_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" # define WM_XTP_SHELLAUTOCOMPLETESTART (WM_XTP_COMMANDBARS_BASE + 30) class CXTPControlComboBox; class CXTPControlComboBoxAutoCompleteWnd; /** @cond */ /** * CXTPControlComboBoxAutoCompleteWnd implementation. * used internally in CXTPControlComboBox and CXTPControlEdit controls */ class _XTP_EXT_CLASS CXTPControlComboBoxAutoCompleteWnd : public CXTPHookManagerHookAble { public: CXTPControlComboBoxAutoCompleteWnd(); ~CXTPControlComboBoxAutoCompleteWnd(); public: HRESULT ShellAutoComplete(HWND hEdit, DWORD dwFlags); void CloseWindow(); void SetupMessageHook(BOOL bSetup); BOOL IsDialogCode(UINT nChar, LPARAM lParam); private: static CXTPControlComboBoxAutoCompleteWnd* m_pWndMonitor; static LRESULT CALLBACK CallWndProc(int code, WPARAM wParam, LPARAM lParam); virtual int OnHookMessage(HWND hWnd, UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); void SetAutoCompeteHandle(HWND); public: HWND m_hWndAutoComplete; private: static HHOOK m_hHookMessage; HWND m_hWndEdit; }; /** @endcond */ /** * @brief * CXTPControlComboBoxPopupBar is a CXTPPopupBar derived class. * It represents the base class for combo pop-ups. */ class _XTP_EXT_CLASS CXTPControlComboBoxPopupBar : public CXTPPopupBar { /** @cond */ DECLARE_XTP_COMMANDBAR(CXTPControlComboBoxPopupBar) /** @endcond */ public: /** * @brief * Constructs a CXTPControlComboBoxPopupBar object. */ CXTPControlComboBoxPopupBar(); public: /** @cond */ // {{AFX_VIRUAL(CXTPControlComboBoxPopupBar) virtual int GetCurSel() const { return CB_ERR; } virtual int FindString(int /*nStartAfter*/, LPCTSTR /*lpszItem*/) const { return CB_ERR; } virtual int FindStringExact(int /*nIndexStart*/, LPCTSTR /*lpsz*/) const { return CB_ERR; } virtual int SetTopIndex(int /*nIndex*/) { return CB_ERR; } virtual void SetCurSel(int /*nIndex*/) { } virtual void GetText(int /*nIndex*/, CString& /*rString*/) const { } virtual BOOL ProcessHookKeyDown(CXTPControlComboBox* pComboBox, UINT nChar, LPARAM lParam); BOOL OnHookKeyDown(UINT nChar, LPARAM lParam); virtual int GetCount() const { return CB_ERR; } // }}AFX_VIRUAL /** @endcond */ }; /** * @brief * CXTPControlComboBoxList is a CXTPControlComboBoxPopupBar derived class. * It represents a list box of CXTPControlComboBox control. */ class _XTP_EXT_CLASS CXTPControlComboBoxList : public CXTPControlComboBoxPopupBar { public: /** * @brief * Constructs a CXTPControlButton object. */ CXTPControlComboBoxList(); public: /** * @brief * Creates list box. */ virtual void CreateListBox(); /** * @return * Retrieves list box window. */ CListBox* GetListBoxCtrl() const; protected: /** * @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, then the pop-up bar becomes visible. * @param pControlPopup Pointer to a CXTPControlPopup object. * @param bSelectFirst TRUE to select the first item. * @return * TRUE if successful; otherwise FALSE. */ virtual BOOL Popup(CXTPControlPopup* pControlPopup, BOOL bSelectFirst = FALSE); /** * @brief * Call this member to change the tracking state. * @param bMode TRUE to set the tracking mode, otherwise FALSE. * @param bSelectFirst TRUE to select the first item. * @param bKeyboard TRUE if the item is pop-up'ed by the keyboard. * @see * IsTrackingMode. * @return * TRUE if the method was successful, otherwise FALSE. */ virtual BOOL SetTrackingMode(int bMode, BOOL bSelectFirst, BOOL bKeyboard = FALSE); /** * @brief * This method is called to draw the command bar in the given context. * @param pDC Pointer to a valid device context. * @param rcClipBox The rectangular area of the control that is invalid. */ virtual void DrawCommandBar(CDC* pDC, CRect rcClipBox); /** * @brief * The framework calls this member function when a non-system key * is pressed. * @param nChar Specifies the virtual key code of the given key. * @param lParam Specifies additional message-dependent information. * @return * TRUE if key handled, otherwise FALSE */ virtual BOOL OnHookKeyDown(UINT nChar, LPARAM lParam); /** * @brief * Call this member to retrieve the customize mode of the command bars. * @return * TRUE if command bars are in customized mode, otherwise FALSE. */ virtual BOOL IsCustomizable() const { return FALSE; } /** * @brief * Either reads 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 makes a copy of the command bar. * @param pCommandBar Command bar to be copied. * @param bRecursive TRUE to copy recursively. */ virtual void Copy(CXTPCommandBar* pCommandBar, BOOL bRecursive = FALSE); protected: /** @cond */ //{{AFX_VIRUAL(CXTPControlComboBoxList) virtual int GetCurSel() const { return GetListBoxCtrl()->GetCurSel(); } virtual int FindString(int nStartAfter, LPCTSTR lpszItem) const { return GetListBoxCtrl()->FindString(nStartAfter, lpszItem); } virtual int FindStringExact(int nIndexStart, LPCTSTR lpsz) const { return GetListBoxCtrl()->FindStringExact(nIndexStart, lpsz); } virtual int SetTopIndex(int nIndex) { return GetListBoxCtrl()->SetTopIndex(nIndex); } virtual void SetCurSel(int nIndex) { GetListBoxCtrl()->SetCurSel(nIndex); } virtual void GetText(int nIndex, CString& rString) const { GetListBoxCtrl()->GetText(nIndex, rString); } //}}AFX_VIRUAL /** @endcond */ protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_MSG(CXTPControlComboBoxList) afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnNcPaint(); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG /** @endcond */ /** * @brief * This method is called to process key down events. * @param pComboBox Owner combobox pointer. * @param nChar Specifies the virtual key code of the given key. * @param lParam Keystroke-message information. * @return * TRUE if the message was processed, otherwise FALSE. */ BOOL ProcessHookKeyDown(CXTPControlComboBox* pComboBox, UINT nChar, LPARAM lParam); /** * @brief * This member function is called to draw the combobox. * @param lpDrawItemStruct A long pointer to a DRAWITEMSTRUCT structure. * The structure contains information about the item * to be drawn and the type of drawing required. */ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); /** * @brief * Override this method and fill in the MEASUREITEMSTRUCT structure * to inform Windows of the list-box dimensions. * @param lpMeasureItemStruct Specifies a long pointer to a MEASUREITEMSTRUCT * structure. */ virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); private: DECLARE_XTP_COMMANDBAR(CXTPControlComboBoxList) friend class CXTPControlComboBox; int m_nListIconId; /**< Icon identifier */ }; ////////////////////////////////////////////////////////////////////////// /** * @brief * Inplace Edit control of the combo. */ class _XTP_EXT_CLASS CXTPControlComboBoxEditCtrl : public CXTPCommandBarEditCtrl { public: /** * @brief * Retrieves parent CXTPControlComboBox object. * @return * Pointer to parent CXTPControlComboBox. */ CXTPControlComboBox* GetControlComboBox() const; protected: /** * @brief * This method is called to refresh the char format of edit control. */ void UpdateCharFormat(); /** @cond */ DECLARE_MESSAGE_MAP() BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); //{{AFX_MSG(CXTPControlComboBoxEditCtrl) afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnDestroy(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); afx_msg void OnEditChanged(); afx_msg LRESULT OnEnableDisable(WPARAM, LPARAM); afx_msg LRESULT OnWindowFromPoint(WPARAM, LPARAM); afx_msg void OnShellAutoCompleteStart(); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); //}}AFX_MSG /** @endcond */ protected: CXTPControlComboBox* m_pControl; /**< Parent Combobox. */ private: friend class CXTPControlComboBox; }; /** * @brief * CXTPControlComboBox is a CXTPControl derived class. * It represents a combobox control. */ class _XTP_EXT_CLASS CXTPControlComboBox : public CXTPControlPopup { public: /** * @brief * Constructs a CXTPControlComboBox object. * @param pCommandBars Pointer to parent CommandBars class. */ CXTPControlComboBox(CXTPCommandBars* pCommandBars = NULL); /** * @brief * Destroys a CXTPControlComboBox object, handles cleanup and deallocation. */ virtual ~CXTPControlComboBox(); public: /** * @brief * Call this member to get the style of edit control. * @return * The style of edit control. * @see * SetEditStyle */ DWORD GetEditStyle() const; /** * @brief * Call this member to set the style of edit control. * @param dwStyle The style to be set. * @see * GetEditStyle */ void SetEditStyle(DWORD dwStyle); /** * @brief * Call this member to insert/delete an edit box in the combobox * when the control has focus. * @param bSet TRUE to set the combobox to have an edit control. * @details * If bSet is TRUE, an edit control will be used to display the text * when the combobox control is clicked. This allows the user to * edit or copy the text. * @see * GetDropDownListStyle */ void SetDropDownListStyle(BOOL bSet = TRUE); /** * @brief * Call this member to determine if the combobox has an edit control. * @return * TRUE if the combobox has an edit control, otherwise FALSE. * @see * SetDropDownListStyle */ BOOL GetDropDownListStyle() const; /** * @brief * Call this member to set the width of the dropdown list. * @param nWidth The width of the dropdown list. */ void SetDropDownWidth(int nWidth); /** * @brief * Call this member to set the count of items in the dropdown list. * @param nDropDownItemCount The count of items in the dropdown list. */ void SetDropDownItemCount(int nDropDownItemCount); /** * @brief * Call this member to retrieve the dropdown list width. * @return * Width of the dropdown list. */ int GetDropDownWidth() const; /** * @brief * Call this member function to add a string to a list box. * @param lpsz The string that is to be added. * @return * The zero-based index of the string in the list box. The return value is LB_ERR * if an error occurs. */ int AddString(LPCTSTR lpsz); /** * @brief * Call this member to retrieve the number of items in a list box. * @return * The number of items in the list box, or LB_ERR if an error occurs. */ int GetCount() const; /** * @brief * Call this member to retrieve a string from the list box of a combobox control. * @param nIndex Contains the zero-based index of the list-box string to be copied. * @param str A reference to a CString. */ void GetLBText(int nIndex, CString& str) const; /** * @brief * Call this member to remove all items from the list box of a combobox control. */ void ResetContent(); /** * @brief * Call this member to find the first list-box string (in a combobox) that * matches the string specified in str. * @param nIndexStart Specifies the zero-based index of the item before the first item * to be searched. * @param lpsz The string to search for. * @return * The zero-based index of the matching item, or CB_ERR if the search was * unsuccessful. * @see * FindString */ int FindStringExact(int nIndexStart, LPCTSTR lpsz) const; /** * @brief * Call this member to insert a string into the list box of a * combobox control. * @param nIndex Contains the zero-based index to the position in the list box that * will receive the string. * @param lpsz The string that is to be inserted. * @return * The zero-based index of a newly inserted item, or CB_ERR if insertion was * unsuccessful. */ int InsertString(int nIndex, LPCTSTR lpsz); /** * @brief * Call this member to get the currently selected item's text * @return * The text that is currently selected. */ virtual CString GetListBoxText() const; /** * @brief * Call this member to get the edit control of the combobox control. * @return * A pointer to the CEdit control. */ CXTPControlComboBoxEditCtrl* GetEditCtrl() const; /** * @brief * Call this member to select a string in the list box of a combobox. * @param nIndex Specifies the zero-based index of the string to select. */ void SetCurSel(int nIndex); /** * @brief * Call this member function to determine which item in the combobox is selected. * @return * The zero-based index of the currently selected item in the list box of a combobox, * or CB_ERR if no item is selected. */ int GetCurSel() const; /** * @brief * Call the GetDroppedState member function to determine whether the list box * of a drop-down combobox is visible (dropped down). * @return * Nonzero if the list box is visible; otherwise 0. */ BOOL GetDroppedState() const; /** * @brief * Call this member to get the edit text. * @return * The Edit control text. */ CString GetEditText() const; /** * @brief * Call this member to modify the style of a list box. * @param dwRemove Styles to remove. * @param dwAdd Styles to add. */ void ModifyListBoxStyle(DWORD dwRemove, DWORD dwAdd); /** * @brief * Call this member to set the edit control text. * @param lpszText New text of the edit control. * @see * FindStringExact, FindString */ void SetEditText(const CString& lpszText); /** * @brief * Call this member to set the grayed-out text displayed in the edit control * which provides a helpful description of what the control is used for. * @param lpszEditHint Edit hint to be set. * * Example: *
pCombo->SetEditHint(_T("Click to find a contact");
* @see
* GetEditHint
*/
void SetEditHint(LPCTSTR lpszEditHint);
/**
* @brief
* Call this member to get the grayed-out text displayed in the edit control
* which provides a helpful description of what the control is used for.
* @return
* Edit hint of the control
* @see
* SetEditHint
*/
CString GetEditHint() const;
/**
* @brief
* This method is called to get the default char format of rich edit text.
* @return Returns default char format of rich edit text
*/
virtual CHARFORMAT2 GetDefaultCharFormat();
/**
* @brief
* This member function enables or disables shell auto completion.
* @param dwFlags Flags that will be passed to SHAutoComplete function.
* @details
* Flags can be combined by using the bitwise
* OR (|) operator. It can be one or more of the following:
* SHACF_FILESYSTEM: This includes the File System as well as the rest of
* the shell (Desktop/My Computer/Control Panel/).
* SHACF_URLALL: Include the URL's in the users History and Recently Used
* lists. Equivalent to SHACF_URLHISTORY | SHACF_URLMRU.
* HACF_URLHISTORY: URLs in the User's History.
* SHACF_URLMRU: URLs in the User's Recently Used list.
* SHACF_FILESYS_ONLY: Include only the file system. Do not include
* virtual folders such as Desktop or Control Panel.
*/
void EnableShellAutoComplete(DWORD dwFlags = SHACF_FILESYSTEM | SHACF_URLALL);
/**
* @brief
* This member function enables or disables auto completion.
* @param bAutoComplete TRUE to enable auto completion, otherwise FALSE.
*/
void EnableAutoComplete(BOOL bAutoComplete = TRUE);
/**
* @brief
* This method finds the first string in a list box that contains the
* specified prefix, without changing the list-box selection.
* @param nStartAfter Contains the zero-based index of the item before the
* first item to be searched. When the search reaches the
* bottom of the list box, it continues from the top of
* the list box back to the item specified by nStartAfter.
* If nStartAfter is -1, the entire list box is searched
* from the beginning.
* @param lpszItem Points to the null-terminated string that contains the
* prefix to search for. The search is case independent,
* so this string may contain any combination of uppercase
* and lowercase letters.
* @return
* The zero-based index of the matching item, or LB_ERR if the search
* was unsuccessful.
* @see
* FindStringExact
*/
int FindString(int nStartAfter, LPCTSTR lpszItem) const;
/**
* @brief
* This method retrieves the application-supplied, 32-bit value associated
* with the specified combobox item.
* @param nIndex Contains the zero-based index of an item in the combobox's list box.
* @return
* The 32-bit value associated with the item, or CB_ERR if an error occurs.
*/
DWORD_PTR GetItemData(int nIndex) const;
/**
* @brief
* This method sets the 32-bit value associated with the specified item in
* a combobox.
* @param nIndex Contains a zero-based index of the item to set.
* @param dwItemData Contains the new value to associate with the item.
* @return
* CB_ERR if an error occurs.
*/
int SetItemData(int nIndex, DWORD_PTR dwItemData);
/**
* @brief
* Call this member function to delete a string.
* @param nIndex Contains a zero-based index of the item to delete.
*/
void DeleteItem(long nIndex);
/**
* @brief
* This method is called when the control's enabled state is changed.
*/
void OnEnabledChanged();
/**
* @brief
* Either reads this object from or writes this object to an archive.
* @param pPX A CXTPPropExchange object to serialize to or from.
*/
void DoPropExchange(CXTPPropExchange* pPX);
/**
* @brief
* Call this member to compare controls.
* @param pOther The control to compare with.
* @return
* TRUE if the controls are identical, otherwise FALSE.
*/
virtual BOOL Compare(CXTPControl* pOther);
/**
* @brief
* Call this method to get the width of a label.
* @return
* Width of the label.
* @see
* SetLabelWidth, SetStyle, GetStyle
*/
int GetLabelWidth() const;
/**
* @brief
* Call this method to set the width of a label.
* @param nLabelWidth Width of the label to be set.
* @see
* GetLabelWidth, SetStyle, GetStyle
*/
void SetLabelWidth(int nLabelWidth);
/**
* @brief
* Call this member to determine if the caption of the control is visible.
* @return
* TRUE if the caption of the control is visible, otherwise FALSE.
*/
virtual BOOL IsCaptionVisible() const;
/**
* @brief
* Call this member to determine if the icon is visible for a combobox control.
* @return
* TRUE if the icon is visible, otherwise FALSE.
*/
BOOL IsImageVisible() const;
/**
* @brief
* Call this method to get the width of a thumb button.
* @return
* Width of the thumb button.
* @see
* SetThumbWidth
*/
int GetThumbWidth() const;
/**
* @brief
* This method is called to set the width of a thumb button.
* @param nThumbWidth Width of the thumb button to be set.
* @see
* GetThumbWidth
*/
void SetThumbWidth(int nThumbWidth);
/**
* @brief
* Call this method to determine if control has focus.
* @return True if control has focus, false otherwise
*/
BOOL HasFocus() const;
/**
* @brief
* This method draws the text of control if the style is CBS_DROPDOWNLIST.
* @param pDC Pointer to a valid device context.
* @param rcText Rectangle to draw.
*/
virtual void DrawEditText(CDC* pDC, CRect rcText);
/**
* @return
* Retrieves list box window.
*/
CListBox* GetListBoxCtrl() const;
/**
* @return
* Returns child pop-up bar.
*/
CXTPControlComboBoxPopupBar* GetComboBoxPopupBar() const;
/**
* @brief
* Call this member to set the edit icon's identifier.
* @param nId Icon's identifier to be set.
*/
void SetEditIconId(int nId);
/**
* @brief
* Call this member to get the edit icon's identifier.
* @return
* Edit icon's identifier.
*/
int GetEditIconId() const;
/**
* @brief
* Call this member to set the combo list icon's identifier.
* @param nId Icon's identifier to be set.
*/
void SetListIconId(int nId);
/**
* @brief
* Call this member to get the combo list icon's identifier.
* @return
* Combo list icon's identifier.
*/
int GetListIconId() const;
/** @cond */
// deprecated
virtual CString GetText() const
{
return GetListBoxText();
}
/** @endcond */
/**
* @brief
* Call this member to set focus to the control.
* @param bFocused TRUE to set focus to the control.
*/
virtual void SetFocused(BOOL bFocused);
/**
* @brief
* Call this member to get the focused state of the control.
* @return
* TRUE if the control has focus, otherwise FALSE.
*/
virtual BOOL IsFocused() const;
/**
* @brief
* This method is called when edit control's text is changed
*/
virtual void OnEditChanged();
/**
* @brief
* This method is called when the selected string is changed.
*/
virtual void OnSelChanged();
/**
* @brief
* This method is called when the control is executed.
*/
virtual void OnExecute();
/**
* @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 an action property is changed
* @param nProperty Property of the action.
* @see
* OnActionChanging
*/
virtual void OnActionChanged(int nProperty);
/**
* @brief
* This method is called when an action property is about to be changed.
* @param nProperty Property of the action
* @see
* OnActionChanged
*/
virtual void OnActionChanging(int nProperty);
/**
* @brief
* This method sets the maximum text length that the user may enter
* into an edit control.
* @param nTextLimit Maximum text length user may enter.
* @see
* GetTextLimit
*/
void SetTextLimit(int nTextLimit);
/**
* @brief
* This method gets the maximum text length that the user may enter
* into an edit control.
* @return
* Maximum text length user may enter.
* @see
* SetTextLimit
*/
int GetTextLimit() const;
protected:
/**
* @brief
* This method is called to check if a control can accept focus.
* @return True if control can accept focus, false if not
* @see
* SetFocused
*/
virtual BOOL IsFocusable() const;
/**
* @brief
* This method creates an edit control. Override it to use inherited edit control.
* @return Creates an edit control
*/
virtual CXTPControlComboBoxEditCtrl* CreateEditControl();
/**
* @brief
* Called after the mouse hovers over the control.
*/
void OnMouseHover();
/**
* @brief
* This method is called when the edit control gets focus.
* @param pOldWnd Pointer to a CWnd object.
*/
virtual void OnSetFocus(CWnd* pOldWnd);
/**
* @brief
* This method is called when the edit control loses focus.
*/
virtual void OnKillFocus();
/**
* @brief
* This method is called to get the real rect of an edit control of a combobox.
* @param rcControl Rectangle of combobox area.
*/
virtual void DeflateEditRect(CRect& rcControl);
/**
* @brief
* This method is called when the control becomes selected.
* @param bSelected TRUE if the control becomes selected.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL OnSetSelected(int bSelected);
/**
* @brief
* Call this member to set the bounding rectangle of the control.
* @param rcControl Bounding rectangle of the control.
*/
void SetRect(CRect rcControl);
/**
* @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.
*/
void OnClick(BOOL bKeyboard = FALSE, CPoint pt = CPoint(0, 0));
/**
* @brief
* This method is called when the user activates a control using its underline.
*/
virtual void OnUnderlineActivate();
/**
* @brief
* This method is called to copy the control.
* @param pControl Pointer to a source CXTPControl object.
* @param bRecursive TRUE to copy recursively.
*/
void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE);
/**
* @brief
* This method is called when a non-system key is pressed.
* @param nChar Specifies the virtual key code of the given key.
* @param lParam Specifies additional message-dependent information.
* @return
* TRUE if the key was handled, otherwise FALSE.
*/
BOOL OnHookKeyDown(UINT nChar, LPARAM lParam);
/**
* @brief
* This method is called to assign a parent command bar object.
* @param pParent Pointer to a CXTPCommandBar object.
*/
void SetParent(CXTPCommandBar* pParent);
/**
* @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 the current width of the
* 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
* CXTPControl, CXTPControlCustom, CXTPControlEdit,
* CXTPControlWindowList, CXTPControlWorkspaceActions, CXTPControlToolbars,
* CXTPControlOleItems, CXTPControlRecentFileList, CXTPControlSelector,
* CXTPControlListBox
*/
virtual void OnCalcDynamicSize(DWORD dwMode);
/**
* @brief
* This method is called to pop-up the control.
* @param bPopup TRUE to set pop-up.
* @return
* TRUE if successful, otherwise FALSE.
*/
virtual BOOL OnSetPopup(BOOL bPopup);
/**
* @brief
* This member checks if the user can resize the control.
* @return
* TRUE if resize is available.
*/
virtual BOOL IsCustomizeResizeAllow() const;
/**
* @brief
* This member returns the minimum width that the combobox
* can be sized to by the user while in customization mode.
* @return
* Width of label + Width of Dropdown button + 5
*/
virtual int GetCustomizeMinWidth() const;
/**
* @brief
* This method is called when a control is removed from the
* parent controls collection.
*/
virtual void OnRemoved();
/**
* @brief
* This member is called when the mouse cursor moves.
* @param point Specifies the x- and y- coordinates of the cursor.
*/
virtual void OnMouseMove(CPoint point);
/** @cond */
protected:
public:
void UpdatePopupSelection();
protected:
BOOL IsValidList() const;
void _SetEditText(const CString& lpszText);
CString _GetEditText() const;
virtual BOOL OnHookMouseWheel(UINT nFlags, short zDelta, CPoint pt);
virtual void OnThemeChanged();
void ShowHideEditControl();
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
/** @endcond */
# ifdef _XTP_COMMANDBARS_ACTIVEX
/** @cond */
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
DECLARE_OLETYPELIB_EX(CXTPControlComboBox);
afx_msg void OleSetDropDownWidth(long nWidth);
afx_msg void OleSetDropDownListStyle(BOOL bSet);
afx_msg void OleAddItem(LPCTSTR strText, const VARIANT* varIndex);
afx_msg BSTR OleList(long nIndex);
afx_msg void OleClear();
afx_msg void OleRemoveItem(long nIndex);
afx_msg BSTR OleGetText();
afx_msg void OleSetText(LPCTSTR str);
afx_msg long OleGetListIndex();
afx_msg void OleSetListIndex(long nIndex);
afx_msg long OleFindItem(LPCTSTR strText);
afx_msg int OleGetCount();
afx_msg HWND OleGetEditHandle();
afx_msg long OleGetItemData(int nIndex);
afx_msg void OleSetItemData(int nIndex, long nNumber);
afx_msg BSTR OleGetEditHint();
afx_msg DWORD OleGetShellAutoComplete();
afx_msg void OleSetShellAutoComplete(DWORD dwShellAutoCompleteFlags);
afx_msg BOOL OleGetThemedItems();
afx_msg void OleSetThemedItems(BOOL bThemedItems);
afx_msg void OleSetEditIconId(int nId);
afx_msg int OleGetEditIconId();
afx_msg void OleSetListIconId(int nId);
afx_msg int OleGetListIconId();
enum
{
dispidStyle = 50L,
dispidAddItem = 51L,
dispidDropDownWidth = 52L,
dispidDropDownListStyle = 53L,
dispidWidth = 54L,
dispidList = 55L,
dispidClear = 56L,
dispidListCount = 57L,
dispidRemoveItem = 58L,
dispidText = 59L,
dispidListIndex = 60L,
dispidFindItem = 61L,
};
/** @endcond */
# endif
/** @cond */
DECLARE_XTP_CONTROL(CXTPControlComboBox)
/** @endcond */
protected:
CXTPControlComboBoxEditCtrl* m_pEdit; /**< Child edit control. */
BOOL m_bDropDown; /**< TRUE if the combo is dropdown. */
XTPButtonStyle m_comboStyle; /**< Style of the combobox. */
int m_nLastSel; /**< Last user selected index (used during display of list box). */
CString m_strLastText; /**< Last Text before user select focus and change it. */
BOOL m_bDelayDestroy; /**< TRUE if need to recreate control. */
BOOL m_bDelayReposition; /**< Need to reposition control. */
int m_nLabelWidth; /**< Width of the label. */
int m_nThumbWidth; /**< Width of the thumb area. */
CString m_strEditHint; /**< Grayed-out text displayed in the edit control that displayed a
helpful description. */
BOOL m_bAutoComplete; /**< TRUE if Auto Complete is enabled. */
BOOL m_bIgnoreAutoComplete; /**< TRUE to disable auto complete till next key event. */
DWORD m_dwShellAutoCompleteFlags; /**< Shell auto complete flags. */
BOOL m_bFocused; /**< TRUE if control is focused. */
int m_nEditIconId; /**< Edit Icon identifier. */
BOOL m_bSelEndOk; /**< TRUE if user selects a list item. */
int m_nDropDownItemCount; /**< Maximum drop down items. */
mutable CString m_strEditText; /**< Edit text. */
mutable BOOL m_bEditChanged; /**< TRUE if Edit Text is changed. */
int m_nTextLimit; /**< The maximum number of characters that can be entered into an edit
control. */
CXTPControlComboBoxAutoCompleteWnd* m_pAutoCompleteWnd; /**< Auto Complete hook window. */
DWORD m_dwEditStyle; /**< Edit style. */
private:
int m_nCurSel;
BOOL m_bIgnoreSelection;
friend class CXTPControlComboBoxList;
friend class CXTPControlComboBoxEditCtrl;
};
//////////////////////////////////////////////////////////////////////////
AFX_INLINE void CXTPControlComboBox::SetDropDownWidth(int nWidth)
{
m_pCommandBar->SetWidth(nWidth);
}
AFX_INLINE int CXTPControlComboBox::AddString(LPCTSTR lpsz)
{
return GetListBoxCtrl()->AddString(lpsz);
}
AFX_INLINE int CXTPControlComboBox::GetCount() const
{
return GetListBoxCtrl()->GetCount();
}
AFX_INLINE void CXTPControlComboBox::GetLBText(int nIndex, CString& str) const
{
GetComboBoxPopupBar()->GetText(nIndex, str);
}
AFX_INLINE void CXTPControlComboBox::ResetContent()
{
GetListBoxCtrl()->ResetContent();
}
AFX_INLINE int CXTPControlComboBox::FindStringExact(int nIndexStart, LPCTSTR lpsz) const
{
return GetComboBoxPopupBar()->FindStringExact(nIndexStart, lpsz);
}
AFX_INLINE int CXTPControlComboBox::InsertString(int nIndex, LPCTSTR lpsz)
{
return GetListBoxCtrl()->InsertString(nIndex, lpsz);
}
AFX_INLINE CXTPControlComboBoxEditCtrl* CXTPControlComboBox::GetEditCtrl() const
{
return m_pEdit;
}
AFX_INLINE int CXTPControlComboBox::FindString(int nStartAfter, LPCTSTR lpszItem) const
{
return GetComboBoxPopupBar()->FindString(nStartAfter, lpszItem);
}
AFX_INLINE DWORD_PTR CXTPControlComboBox::GetItemData(int nIndex) const
{
return (DWORD_PTR)GetListBoxCtrl()->GetItemData(nIndex);
}
AFX_INLINE int CXTPControlComboBox::SetItemData(int nIndex, DWORD_PTR dwItemData)
{
return GetListBoxCtrl()->SetItemData(nIndex, dwItemData);
}
AFX_INLINE BOOL CXTPControlComboBox::IsCustomizeResizeAllow() const
{
return TRUE;
}
AFX_INLINE CXTPControlComboBox* CXTPControlComboBoxEditCtrl::GetControlComboBox() const
{
return m_pControl;
}
AFX_INLINE int CXTPControlComboBox::GetLabelWidth() const
{
return m_nLabelWidth;
}
AFX_INLINE int CXTPControlComboBox::GetEditIconId() const
{
return m_nEditIconId;
}
AFX_INLINE int CXTPControlComboBox::GetThumbWidth() const
{
return m_nThumbWidth;
}
/** @cond */
AFX_INLINE void CXTPControlComboBox::OnThemeChanged()
{
m_bDelayReposition = TRUE;
}
/** @endcond */
AFX_INLINE void CXTPControlComboBox::SetDropDownItemCount(int nDropDownItemCount)
{
m_nDropDownItemCount = nDropDownItemCount;
}
/** @cond */
# include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"
#endif //#if !defined(__XTPCONTOLCOMBOBOX_H__)
/** @endcond */