WTL Controls
Back to the WTL Controls Home Page.
ComboBoxPlus.h
Go to the documentation of this file.
1 #pragma once
2 #include "stdafx.h"
3 //--------------------------------------------------------------------------------------
4 //--------------------------------------------------------------------------------------
5 //
6 //
7 // WTL Control Library
8 // by
9 // Bright Ideas Software®
10 // Copyright © 2018 by Bright Ideas Software.
11 //
12 //
13 //
14 //--------------------------------------------------------------------------------------
15 //--------------------------------------------------------------------------------------
16 
17 namespace BIS_WTL_CONTROLS
18 {
19 
70  class CComboBoxPlus : public CWindowImpl<CComboBoxPlus, CComboBox>
71  {
72 
73 
74  public:
75 
77  DECLARE_WND_SUPERCLASS(_T("CComboBoxPlus"), CComboBox::GetWndClassName())
79 
80 
81  CComboBoxPlus() noexcept;
82  virtual ~CComboBoxPlus();
83 
84  void SubclassComboBox(HWND hWnd);
85  void UnSubclassComboBox();
86 
87  void SetControlBackColor(COLORREF value);
88  COLORREF GetControlBackColor() const;
89 
90  void SetControlTextColor(COLORREF value);
91  COLORREF GetControlTextColor() const;
92 
93  void SetControlFocusedBackColor(COLORREF value);
94  COLORREF GetControlFocusedBackColor() const;
95 
96  void SetControlFocusedTextColor(COLORREF value);
97  COLORREF GetControlFocusedTextColor() const;
98 
99  void SetListBoxBackColor(COLORREF value);
100  COLORREF GetListBoxBackColor() const;
101 
102  void SetListBoxTextColor(COLORREF value);
103  COLORREF GetListBoxTextColor() const;
104 
105  void SetAutoAdjustDropRectWidth(bool value);
106  bool GetAutoAdjustDropRectWidth() const;
107 
108  void SetMaxDropDownWidth(int value);
109  int GetMaxDropDownWidth() const;
110 
111  void SetReadOnly(bool read_only = true);
112  bool GetReadOnly() const;
113 
114  void UpdateDropDownWidth();
115 
116  private:
117 
118  bool m_bAutoAdjustDropWidth;
119  int m_iMaxDropDownWidth;
120 
121  HWND m_wndControl;
122  HWND m_wndListBox;
123 
124  CEdit m_ControlWnd;
125  CListBox m_ListBox;
126 
127  bool m_bReadOnly;
128 
129  void UpdateBrushes();
130  void DeleteBrushes();
131 
132  COLORREF m_ControlTextColor;
133  COLORREF m_ControlBackColor;
134 
135  COLORREF m_ControlFocusedBackColor;
136  COLORREF m_ControlFocusedTextColor;
137 
138  COLORREF m_ListBoxTextColor;
139  COLORREF m_ListBoxBackColor;
140 
141  HBRUSH m_ControlBackBrush;
142  HBRUSH m_ControlFocusedBackBrush;
143  HBRUSH m_ListBoxBackBrush;
144 
145 
146  LRESULT OnCtlColorControl(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
147  HBRUSH OnCtlColorListBox(CDCHandle dc, CListBox listBox);
148 
149 
150 
151  BEGIN_MSG_MAP(CComboBoxPlus)
152  MSG_WM_CTLCOLORLISTBOX(OnCtlColorListBox)
153  MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorControl)
154  MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorControl)
155  DEFAULT_REFLECTION_HANDLER()
156  END_MSG_MAP()
157 
158 
159  };
160 };
void SetMaxDropDownWidth(int value)
Sets the upper limit to the width of the dropdown list, if it is being automatically adjusted...
void SetListBoxBackColor(COLORREF value)
Set a new background color for the listbox portion of the combobox.
void SetListBoxTextColor(COLORREF value)
Set a new text color for the listbox portion of the combobox.
COLORREF GetListBoxBackColor() const
Default: COLOR_WINDOW.
void SubclassComboBox(HWND hWnd)
Subclass a combobox control and create GDI brushes.
void UnSubclassComboBox()
Un-subclass main and component windows; free GDI resources.
COLORREF GetControlFocusedBackColor() const
Default: COLOR_WINDOW.
bool GetAutoAdjustDropRectWidth() const
Default: true.
void SetAutoAdjustDropRectWidth(bool value)
Change the AutoAdjustRectWidth state.
COLORREF GetControlBackColor() const
Default: COLOR_WINDOW.
int GetMaxDropDownWidth() const
Default: 400 pixels.
A CComboBox descendant providing customizable background and text colors for both the edit and list b...
Definition: ComboBoxPlus.h:70
void SetControlFocusedTextColor(COLORREF value)
Set a new text color for the control portion of the combobox when it has focus.
void UpdateDropDownWidth()
Force an update of the width of the drop down list.
bool GetReadOnly() const
Default: false.
COLORREF GetControlFocusedTextColor() const
Default: CLR_RED.
void SetControlFocusedBackColor(COLORREF value)
Set a new background color for the control portion of the combobox when it has focus.
COLORREF GetControlTextColor() const
Default: COLOR_WINDOWTEXT.
void SetControlTextColor(COLORREF value)
Set a new text color for the control portion of the combobox when it doesn&#39;t have focus...
void SetReadOnly(bool read_only=true)
Change the read-only state of the combobox.
COLORREF GetListBoxTextColor() const
Default: COLOR_WINDOWTEXT.
void SetControlBackColor(COLORREF value)
Sets a new background color for the control portion of the combobx when it doesn&#39;t have focus...