-
Notifications
You must be signed in to change notification settings - Fork 3
/
MyComboBoxEx.h
140 lines (122 loc) · 3.04 KB
/
MyComboBoxEx.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
#pragma once
#include "resource.h"
#define ID_MYCOMBO_SELENDOK 33800
/////////////////////////////////////////////////////////////////////////////
// CIconWnd window
class CIconWnd : public CStatic
{
DECLARE_DYNCREATE(CIconWnd)
// Construction/destruction
public:
CIconWnd();
virtual ~CIconWnd();
// Operations
public:
void SetIcon(HICON icon);
protected:
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
DECLARE_MESSAGE_MAP()
private:
// Attributes
CIconHelper m_icon;
};
/////////////////////////////////////////////////////////////////////////////
// CIconEdit window
class CIconEdit : public CEdit
{
DECLARE_DYNCREATE(CIconEdit)
// Construction/destruction
public:
CIconEdit();
virtual ~CIconEdit();
CWnd* m_pParentWnd;
BOOL m_bFontCreated;
CFont m_fontUI;
// Operations
public:
void SetIcon(HICON icon);
void SetIcon(UINT iconres);
protected:
virtual void PreSubclassWindow();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam); // Maps to WM_SETFONT
DECLARE_MESSAGE_MAP()
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
private:
void Prepare();
void CreateIcon();
// Attributes
CIconWnd m_icon;
CIconHelper m_internalIcon;
};
class CMyComboEdit : public CEdit
{
DECLARE_DYNCREATE(CMyComboEdit)
public:
CMyComboEdit()
{
m_pParentFrmWnd = NULL;
m_bIME = FALSE;
};
virtual ~CMyComboEdit(){};
CWnd* m_pParentFrmWnd;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CComboEditXP)
public:
//virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
protected:
//{{AFX_MSG(CComboEditXP)
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
//}}AFX_MSG
BOOL m_bIME;
DECLARE_MESSAGE_MAP()
};
class CMyComboBoxEx : public CComboBoxEx
{
public:
CMyComboBoxEx();
CWnd* m_pParentWnd;
CMyComboEdit m_Edit;
public:
//{{AFX_VIRTUAL(CMyComboBoxEx)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
m_pParentWnd = pParentWnd;
BOOL bRet = CComboBoxEx::Create(dwStyle, rect, pParentWnd, nID);
HWND hEdit = (HWND)::SendMessage(m_hWnd, CBEM_GETEDITCONTROL, 0, 0);
if (hEdit != NULL)
{
m_Edit.SubclassWindow(hEdit);
m_Edit.m_pParentFrmWnd = pParentWnd;
SHAutoComplete(m_Edit.m_hWnd, SHACF_URLALL | SHACF_AUTOSUGGEST_FORCE_ON | SHACF_AUTOAPPEND_FORCE_ON);
}
return bRet;
}
void AppendString(LPTSTR lpText)
{
if (!lpText)
return;
COMBOBOXEXITEM cbei = {0};
memset(&cbei, 0x00, sizeof(cbei));
cbei.mask = CBEIF_TEXT;
cbei.iItem = 0;
cbei.pszText = lpText;
InsertItem(&cbei);
}
public:
virtual ~CMyComboBoxEx();
protected:
//{{AFX_MSG(CMyComboBoxEx)
afx_msg void OnSelendok();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};