xj qian
2024-06-25 58c129e8f21f79396a822eaeadd78edf281b52a0
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#pragma once
 
#include "win32/win.hpp"
#include "wobject/xcontrol.hpp"
 
class xcombobox:  public xcontrol
{
public:
    xcombobox() :xcontrol(nullptr) {}
    xcombobox(void* impl) :xcontrol(impl) {}
 
public:
    xcombobox & operator =(const kcontrol* pcontrol)
    {
        this->setNativePointer((void *)pcontrol);
        return *this;
    }
public:
    int GetCurSel()
    {
        int CB_GETCURSEL  = 0x0147;
        return SendMessage(GetHWND(),CB_GETCURSEL,0,0);
    }
 
    int SetCurSel( int nIndex)
    {
        int CB_SETCURSEL  = 0x014E;
        return SendMessage(GetHWND(),CB_SETCURSEL,nIndex,0);
    }
            
    int GetCount()
    {
        int CB_GETCOUNT = 0x0146;
        return SendMessage(GetHWND(),CB_GETCOUNT,0,0);
    }
            
   string GetLBText(int nIndex)
    {
        int CB_GETLBTEXT     =  0x0148;
        int CB_GETLBTEXTLEN  =  0x0149;
        int nLen = SendMessage(GetHWND(),CB_GETLBTEXTLEN ,nIndex,0);
        string str = new wchar_t[nLen+1];
        SendMessage(GetHWND(),CB_GETLBTEXT ,nIndex, (LPARAM)str);
        return str;
    }
 
   string GetLBText()
    {
        int CB_GETLBTEXT     =  0x0148;
        int CB_GETLBTEXTLEN  =  0x0149;
        int nIndex = GetCurSel();
        int nLen = SendMessage(GetHWND(),CB_GETLBTEXTLEN ,nIndex,0);
         string str = new wchar_t[nLen+1];
        SendMessage(GetHWND(),CB_GETLBTEXT ,nIndex, (LPARAM)str);
        return str;
    }
 
    int SetItemIndex(int nIndex)
    {
        int CB_SETCURSEL = 0x014E;
        return SendMessage(GetHWND(),CB_SETCURSEL ,nIndex, 0);
    }
            
   int AddItem(string str)
    {
        int CB_ADDSTRING =  0x0143;
        return SendMessage(GetHWND(),CB_ADDSTRING  ,(WPARAM)0,(LPARAM)str);
    }
            
   int FindString(string str)
    {
        int CB_FINDSTRINGEXACT = 0x0158;
        return SendMessage(GetHWND(),CB_FINDSTRINGEXACT,0,(LPARAM)str);
    }
 
   int DeleteItem(int nIndex)
    {
        int CB_DELETESTRING = 0x0144;
        return SendMessage(GetHWND(),CB_DELETESTRING,nIndex,0);
    }
 
   int SelectString( int nIndex,string str) 
    {
        int CB_SELECTSTRING  = 0x014D;
        return SendMessage(GetHWND(),CB_SELECTSTRING,nIndex,(LPARAM)str);
    }
 
   int InsertString( int nIndex,string str) 
    {
        int CB_INSERTSTRING  = 0x014A;
        return SendMessage(GetHWND(),CB_INSERTSTRING,nIndex,(LPARAM)str);
    }
 
   int InsertString( string str) 
    {
        int CB_INSERTSTRING  = 0x014A;
        return SendMessage(GetHWND(),CB_INSERTSTRING,0,(LPARAM)str);
    }
 
   int ResetContent() 
    {
        int CB_RESETCONTENT  =  0x014B;
        return SendMessage(GetHWND(),CB_RESETCONTENT,0,0);
    }
 
   int SetItemData(int nIndex, LPARAM p) 
    {
        int CB_SETITEMDATA  =   0x0151;
        return SendMessage(GetHWND(),CB_SETITEMDATA,nIndex,p);
    }
 
   int GetItemData() 
    {
        int CB_GETITEMDATA  =   0x0150;
        int nIndex = GetCurSel();
        if(nIndex < 0) 
        return -1;
        else
        return SendMessage(GetHWND(),CB_GETITEMDATA,nIndex,0);
    }
 
   LPARAM GetItemData(int nIndex) 
    {
        int CB_GETITEMDATA  =   0x0150;
        return SendMessage(GetHWND(),CB_GETITEMDATA,nIndex,0);
    }
 
   int AddItem(string str, int p)
    {
        int CB_ADDSTRING =  0x0143;
        int h = SendMessage(GetHWND(),CB_ADDSTRING  ,0,(LPARAM)str);
        SetItemData( h, p);
        return h;
    }
   
   int AddItem(string str, string p)
    {
        int CB_ADDSTRING =  0x0143;
        int h = SendMessage(GetHWND(),CB_ADDSTRING  ,0,(LPARAM)str);
        SetItemData( h, (LPARAM)p);
        return h;
    }
 
   int InsertString( string str, LPARAM p) 
    {
        int CB_INSERTSTRING  = 0x014A;
        int h =  SendMessage(GetHWND(),CB_INSERTSTRING,0,(LPARAM)str);
    
        SetItemData( h, p);
        return h;
    }
    
 
   /////
   static int GetCurSel(HWND hWnd)
   {
       int CB_GETCURSEL = 0x0147;
       return SendMessage(hWnd, CB_GETCURSEL, 0, 0);
   }
 
   static int SetCurSel(HWND hWnd,int nIndex)
   {
       int CB_SETCURSEL = 0x014E;
       return SendMessage(hWnd, CB_SETCURSEL, nIndex, 0);
   }
 
   static int GetCount(HWND hWnd)
   {
       int CB_GETCOUNT = 0x0146;
       return SendMessage(hWnd, CB_GETCOUNT, 0, 0);
   }
 
   static string GetLBText(HWND hWnd,int nIndex)
   {
       int CB_GETLBTEXT = 0x0148;
       int CB_GETLBTEXTLEN = 0x0149;
       int nLen = SendMessage(hWnd, CB_GETLBTEXTLEN, nIndex, 0);
       string str = new wchar_t[nLen + 1];
       SendMessage(hWnd, CB_GETLBTEXT, nIndex, (LPARAM)str);
       return str;
   }
 
   static string GetLBText(HWND hWnd)
   {
       int CB_GETLBTEXT = 0x0148;
       int CB_GETLBTEXTLEN = 0x0149;
       int nIndex = GetCurSel(hWnd);
       int nLen = SendMessage(hWnd, CB_GETLBTEXTLEN, nIndex, 0);
       string str = new wchar_t[nLen + 1];
       SendMessage(hWnd, CB_GETLBTEXT, nIndex, (LPARAM)str);
       return str;
   }
 
   static int SetItemIndex(HWND hWnd,int nIndex)
   {
       int CB_SETCURSEL = 0x014E;
       return SendMessage(hWnd, CB_SETCURSEL, nIndex, 0);
   }
 
   static int AddItem(HWND hWnd,string str)
   {
       int CB_ADDSTRING = 0x0143;
       return SendMessage(hWnd, CB_ADDSTRING, (WPARAM)0, (LPARAM)str);
   }
 
   static int FindString(HWND hWnd,string str)
   {
       int CB_FINDSTRINGEXACT = 0x0158;
       return SendMessage(hWnd, CB_FINDSTRINGEXACT, 0, (LPARAM)str);
   }
 
   static int DeleteItem(HWND hWnd,int nIndex)
   {
       int CB_DELETESTRING = 0x0144;
       return SendMessage(hWnd, CB_DELETESTRING, nIndex, 0);
   }
 
   static int SelectString(HWND hWnd,int nIndex, string str)
   {
       int CB_SELECTSTRING = 0x014D;
       return SendMessage(hWnd, CB_SELECTSTRING, nIndex, (LPARAM)str);
   }
 
   static int InsertString(HWND hWnd,int nIndex, string str)
   {
       int CB_INSERTSTRING = 0x014A;
       return SendMessage(hWnd, CB_INSERTSTRING, nIndex, (LPARAM)str);
   }
 
   static int InsertString(HWND hWnd,string str)
   {
       int CB_INSERTSTRING = 0x014A;
       return SendMessage(hWnd, CB_INSERTSTRING, 0, (LPARAM)str);
   }
 
   int ResetContent(HWND hWnd)
   {
       int CB_RESETCONTENT = 0x014B;
       return SendMessage(hWnd, CB_RESETCONTENT, 0, 0);
   }
 
   static int SetItemData(HWND hWnd,int nIndex, LPARAM p)
   {
       int CB_SETITEMDATA = 0x0151;
       return SendMessage(hWnd, CB_SETITEMDATA, nIndex, p);
   }
 
   static int GetItemData(HWND hWnd)
   {
       int CB_GETITEMDATA = 0x0150;
       int nIndex = GetCurSel(hWnd);
       if (nIndex < 0)
           return -1;
       else
           return SendMessage(hWnd, CB_GETITEMDATA, nIndex, 0);
   }
 
   static LPARAM GetItemData(HWND hWnd,int nIndex)
   {
       int CB_GETITEMDATA = 0x0150;
       return SendMessage(hWnd, CB_GETITEMDATA, nIndex, 0);
   }
 
   static int AddItem(HWND hWnd,string str, int p)
   {
       int CB_ADDSTRING = 0x0143;
       int h = SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)str);
       SetItemData(hWnd,h, p);
       return h;
   }
 
   static int AddItem(HWND hWnd,string str, string p)
   {
       int CB_ADDSTRING = 0x0143;
       int h = SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)str);
       SetItemData(hWnd,h, (LPARAM)p);
       return h;
   }
 
   static int InsertString(HWND hWnd,string str, LPARAM p)
   {
       int CB_INSERTSTRING = 0x014A;
       int h = SendMessage(hWnd, CB_INSERTSTRING, 0, (LPARAM)str);
 
       SetItemData(hWnd,h, p);
       return h;
   }
};