-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathComboBoxExt.h
197 lines (176 loc) · 6.4 KB
/
ComboBoxExt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#if !defined(AFX_COMBOBOXEXT_H__314E0909_0E3F_4D06_A5F9_4AB4F098D2CD__INCLUDED_)
#define AFX_COMBOBOXEXT_H__314E0909_0E3F_4D06_A5F9_4AB4F098D2CD__INCLUDED_
#include <afxtempl.h>
#include "ComboBoxExtList.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ComboBoxExt.h : header file
#define WMU_POSTCLOSEUP (WM_USER + 64)
/////////////////////////////////////////////////////////////////////////////
// CComboBoxExt window
class CComboBoxExt : public CComboBox
{
// Construction
public:
CComboBoxExt();
// Attributes
public:
enum
{
MODE_STANDARD = 0,
MODE_DROPDOWN = 1,
MODE_AUTOCOMPLETE = 2
};
// Operations
public:
BOOL IsAlertBkg() const { return m_bAlertBkg; }
BOOL IsAlertText() const { return m_bAlertText; }
BOOL IsAdjustedDroppedWidth() const { return m_bAdjustDroppedWidth; }
int GetMode() const { return m_nMode; }
void SetMode(int nMode = CComboBoxExt::MODE_STANDARD) { m_nMode = nMode; }
void AdjustDroppedWidth(BOOL bAdjustDroppedWidth = TRUE) { m_bAdjustDroppedWidth = bAdjustDroppedWidth; }
COLORREF GetAlertColorBkg() const { return m_crAlertBkg; }
void SetAlertColorBkg(COLORREF crColor);
COLORREF GetAlertColorText() const { return m_crAlertText; }
void SetAlertColorText(COLORREF crColor) { m_crAlertText = crColor; }
int AddStringWithInfo(LPCTSTR lpszString, LPCTSTR lpszInfo, BOOL bShowItemTooltip = TRUE);
int InsertStringWithInfo(int nIndex, LPCTSTR lpszString, LPCTSTR lpszInfo, BOOL bShowItemTooltip = TRUE);
void SetLBInfo(int nIndex, LPCTSTR lpszInfo, BOOL bShowItemTooltip = TRUE);
void GetLBInfo(int nIndex, CString& rInfo) const;
void SetLBShowItemTooltip(int nIndex, BOOL bShow = TRUE);
BOOL GetLBShowItemTooltipState(int nIndex) const;
int FindInfo(int nStartAfter, LPCTSTR lpszString) const;
int FindInfoExact(int nIndexStart, LPCTSTR lpszFind) const;
int SelectInfo(int nStartAfter, LPCTSTR lpszString);
void AlertBkg(BOOL bAlert = TRUE, BOOL bRedraw = FALSE)
{
m_bAlertBkg = bAlert;
if(bRedraw)
Invalidate();
}
void AlertText(BOOL bAlert = TRUE, BOOL bRedraw = FALSE)
{
m_bAlertText = bAlert;
if(bRedraw)
Invalidate();
}
void SetEditTooltip(BOOL bShowTooltip, BOOL bTooltipOnInfo = FALSE, BOOL bShowEditTooltipOverItem = FALSE)
{
m_bShowTooltip = bShowTooltip;
m_bTooltipOnInfo = bTooltipOnInfo;
m_bShowEditTooltipOverItem = bShowEditTooltipOverItem;
}
void GetEditTooltip(BOOL& bShowTooltip, BOOL& bTooltipOnInfo, BOOL& bShowEditTooltipOverItem)
{
bShowTooltip = m_bShowTooltip;
bTooltipOnInfo = m_bTooltipOnInfo;
bShowEditTooltipOverItem = m_bShowEditTooltipOverItem;
}
void SetListTooltip(BOOL bShowTooltip, BOOL bTooltipOnInfo = FALSE, BOOL bShowListTooltipOverItem = FALSE)
{
m_ListBox.m_bShowTooltip = bShowTooltip;
m_ListBox.m_bTooltipOnInfo = bTooltipOnInfo;
m_ListBox.m_bShowListTooltipOverItem = bShowListTooltipOverItem;
}
void GetListTooltip(BOOL& bShowTooltip, BOOL& bTooltipOnInfo, BOOL& bShowListTooltipOverItem)
{
bShowTooltip = m_ListBox.m_bShowTooltip;
bTooltipOnInfo = m_ListBox.m_bTooltipOnInfo;
bShowListTooltipOverItem = m_ListBox.m_bShowListTooltipOverItem;
}
void SetEditTooltipOverItemPosition(BOOL bAbove = TRUE)
{
m_bEditTooltipOverItemPos = bAbove;
}
BOOL GetEditTooltipOverItemPosition() const
{
return m_bEditTooltipOverItemPos;
}
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CComboBoxExt)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CComboBoxExt();
DWORD GetItemData(int nIndex) const;
int SetItemData(int nIndex, DWORD dwItemData);
TOOLINFO* GetToolInfo() { return &m_ToolInfo; }
HWND* GetToolTipHwnd() { return &m_hWndToolTip; }
CComboBoxExtList* GetListBox() { return &m_ListBox; }
protected:
BOOL m_bEdit;
BOOL m_bAutoSelection;
BOOL m_bToolActive;
HWND m_hWndToolTip;
TOOLINFO m_ToolInfo;
CString m_sTypedText;
CString m_sCloseupText;
CComboBoxExtList m_ListBox;
DWORD m_dwStartSel, m_dwEndSel;
protected:
int m_nMode;
BOOL m_bAlertBkg;
BOOL m_bAlertText;
BOOL m_bAdjustDroppedWidth;
BOOL m_bAutoComplete;
BOOL m_bShowTooltip;
BOOL m_bTooltipOnInfo;
BOOL m_bShowEditTooltipOverItem; // this item make sense only when m_bTooltipOnInfo == TRUE
BOOL m_bEditTooltipOverItemPos; // this item make sense only when m_bShowEditTooltipOverItem == TRUE
CBrush m_BrushAlert;
COLORREF m_crAlertBkg;
COLORREF m_crAlertText;
class CItemData : public CObject
{
// Attributes
public:
DWORD m_dwItemData;
CString m_sItem;
CString m_sInfo;
BOOL m_bState;
BOOL m_bShowItemTooltip;
// Implementation
public:
CItemData();
CItemData(DWORD dwItemData, LPCTSTR lpszString);
CItemData(DWORD dwItemData, LPCTSTR lpszString, BOOL bState);
CItemData(DWORD dwItemData, LPCTSTR lpszString, LPCTSTR lpszInfo, BOOL bState);
CItemData(DWORD dwItemData, LPCTSTR lpszString, LPCTSTR lpszInfo, BOOL bState, BOOL bShowItemTooltip);
virtual ~CItemData();
};
CTypedPtrList<CPtrList, CItemData*> m_PtrList;
protected:
virtual void FitDropDownToItems();
virtual int AddItem(CItemData* pData);
virtual int DeleteItem(CItemData* pData);
// Generated message map functions
protected:
//{{AFX_MSG(CComboBoxExt)
afx_msg void OnDestroy();
afx_msg BOOL OnCloseup();
afx_msg BOOL OnDropdown();
afx_msg BOOL OnSelendok();
afx_msg BOOL OnSelchange();
afx_msg BOOL OnEditchange();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnTimer(UINT_PTR nIDEvent);
//}}AFX_MSG
afx_msg LRESULT OnAddString(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnInsertString(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnDeleteString(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnResetContent(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnPostCloseup(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COMBOBOXEXT_H__314E0909_0E3F_4D06_A5F9_4AB4F098D2CD__INCLUDED_)