1 | /* $Id: combo.cpp,v 1.20 1999-12-21 17:03:43 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Combo controls
|
---|
4 | *
|
---|
5 | * Copyright 1997 Alex Korobka
|
---|
6 | * Copyright 1999 Christoph Bratschi
|
---|
7 | *
|
---|
8 | * FIXME: roll up in Netscape 3.01.
|
---|
9 | *
|
---|
10 | * WINE version: 991212
|
---|
11 | *
|
---|
12 | * Status: in progress
|
---|
13 | * Version: ?.??
|
---|
14 | */
|
---|
15 |
|
---|
16 | /* CB: bugs
|
---|
17 | - problems with focus handling (Win32 <-> OS/2)
|
---|
18 | will be fixed soon
|
---|
19 | - several other bugs
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include <string.h>
|
---|
23 | #include <os2win.h>
|
---|
24 | #include "controls.h"
|
---|
25 | #include "combo.h"
|
---|
26 | #include "initterm.h"
|
---|
27 |
|
---|
28 | #ifdef DEBUG
|
---|
29 | char *GetMsgText(int Msg);
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | /* bits in the dwKeyData */
|
---|
33 | #define KEYDATA_ALT 0x2000
|
---|
34 | #define KEYDATA_PREVSTATE 0x4000
|
---|
35 |
|
---|
36 | /*
|
---|
37 | * Additional combo box definitions
|
---|
38 | */
|
---|
39 |
|
---|
40 | #define CB_NOTIFY( lphc, code ) \
|
---|
41 | (SendMessageA( (lphc)->owner, WM_COMMAND, \
|
---|
42 | MAKEWPARAM(GetWindowLongA((lphc)->hwndself,GWL_ID), (code)), (lphc)->hwndself))
|
---|
43 | #define CB_GETEDITTEXTLENGTH( lphc ) \
|
---|
44 | (SendMessageA( (lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ))
|
---|
45 |
|
---|
46 | /*
|
---|
47 | * Look and feel dependant "constants"
|
---|
48 | */
|
---|
49 | #define COMBO_YBORDERGAP 5
|
---|
50 | #define COMBO_XBORDERSIZE() ( 2 )
|
---|
51 | #define COMBO_YBORDERSIZE() ( 2 )
|
---|
52 | #define COMBO_EDITBUTTONSPACE() ( 0 )
|
---|
53 | #define EDIT_CONTROL_PADDING() ( 1 )
|
---|
54 |
|
---|
55 | /***********************************************************************
|
---|
56 | * COMBO_NCCreate
|
---|
57 | */
|
---|
58 | static LRESULT COMBO_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
59 | {
|
---|
60 | LPHEADCOMBO lphc;
|
---|
61 |
|
---|
62 | if ( hwnd &&
|
---|
63 | (lphc = (LPHEADCOMBO)HeapAlloc(GetProcessHeap(), 0, sizeof(HEADCOMBO))) )
|
---|
64 | {
|
---|
65 | LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
|
---|
66 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
67 | DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE);
|
---|
68 |
|
---|
69 | memset( lphc, 0, sizeof(HEADCOMBO) );
|
---|
70 | SetInfoPtr(hwnd,(DWORD)lphc);
|
---|
71 |
|
---|
72 | /* some braindead apps do try to use scrollbar/border flags */
|
---|
73 |
|
---|
74 | lphc->dwStyle = (lpcs->style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL));
|
---|
75 | dwStyle &= ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL);
|
---|
76 | SetWindowLongA(hwnd,GWL_STYLE,dwStyle);
|
---|
77 |
|
---|
78 | /*
|
---|
79 | * We also have to remove the client edge style to make sure
|
---|
80 | * we don't end-up with a non client area.
|
---|
81 | */
|
---|
82 | dwExStyle &= ~(WS_EX_CLIENTEDGE);
|
---|
83 | SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle);
|
---|
84 |
|
---|
85 | if( !(lpcs->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) )
|
---|
86 | lphc->dwStyle |= CBS_HASSTRINGS;
|
---|
87 | if( !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
|
---|
88 | lphc->wState |= CBF_NOTIFY;
|
---|
89 |
|
---|
90 | //TRACE("[0x%08x], style = %08x\n",
|
---|
91 | // (UINT)lphc, lphc->dwStyle );
|
---|
92 |
|
---|
93 | return TRUE;
|
---|
94 | }
|
---|
95 | return FALSE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | /***********************************************************************
|
---|
99 | * COMBO_NCDestroy
|
---|
100 | */
|
---|
101 | static LRESULT COMBO_NCDestroy(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
102 | {
|
---|
103 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
104 |
|
---|
105 | if( lphc )
|
---|
106 | {
|
---|
107 | //TRACE("[%04x]: freeing storage\n", CB_HWND(lphc));
|
---|
108 |
|
---|
109 | if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox )
|
---|
110 | DestroyWindow( lphc->hWndLBox );
|
---|
111 |
|
---|
112 | HeapFree( GetProcessHeap(), 0, lphc );
|
---|
113 | SetInfoPtr(hwnd,0);
|
---|
114 | }
|
---|
115 |
|
---|
116 | return DefWindowProcA(hwnd,WM_NCDESTROY,wParam,lParam);
|
---|
117 | }
|
---|
118 |
|
---|
119 | /***********************************************************************
|
---|
120 | * CBGetTextAreaHeight
|
---|
121 | *
|
---|
122 | * This method will calculate the height of the text area of the
|
---|
123 | * combobox.
|
---|
124 | * The height of the text area is set in two ways.
|
---|
125 | * It can be set explicitely through a combobox message of through a
|
---|
126 | * WM_MEASUREITEM callback.
|
---|
127 | * If this is not the case, the height is set to 13 dialog units.
|
---|
128 | * This height was determined through experimentation.
|
---|
129 | */
|
---|
130 | static INT CBGetTextAreaHeight(
|
---|
131 | HWND hwnd,
|
---|
132 | LPHEADCOMBO lphc)
|
---|
133 | {
|
---|
134 | INT iTextItemHeight;
|
---|
135 |
|
---|
136 | if( lphc->editHeight ) /* explicitly set height */
|
---|
137 | {
|
---|
138 | iTextItemHeight = lphc->editHeight;
|
---|
139 | }
|
---|
140 | else
|
---|
141 | {
|
---|
142 | TEXTMETRICA tm;
|
---|
143 | HDC hDC = GetDC(hwnd);
|
---|
144 | HFONT hPrevFont = 0;
|
---|
145 | INT baseUnitY;
|
---|
146 |
|
---|
147 | if (lphc->hFont)
|
---|
148 | hPrevFont = SelectObject( hDC, lphc->hFont );
|
---|
149 |
|
---|
150 | GetTextMetricsA(hDC, &tm);
|
---|
151 |
|
---|
152 | baseUnitY = tm.tmHeight;
|
---|
153 |
|
---|
154 | if( hPrevFont )
|
---|
155 | SelectObject( hDC, hPrevFont );
|
---|
156 |
|
---|
157 | ReleaseDC(hwnd, hDC);
|
---|
158 |
|
---|
159 | iTextItemHeight = ((13 * baseUnitY) / 8);
|
---|
160 |
|
---|
161 | /*
|
---|
162 | * This "formula" calculates the height of the complete control.
|
---|
163 | * To calculate the height of the text area, we have to remove the
|
---|
164 | * borders.
|
---|
165 | */
|
---|
166 | iTextItemHeight -= 2*COMBO_YBORDERSIZE();
|
---|
167 | }
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * Check the ownerdraw case if we haven't asked the parent the size
|
---|
171 | * of the item yet.
|
---|
172 | */
|
---|
173 | if ( CB_OWNERDRAWN(lphc) &&
|
---|
174 | (lphc->wState & CBF_MEASUREITEM) )
|
---|
175 | {
|
---|
176 | MEASUREITEMSTRUCT measureItem;
|
---|
177 | RECT clientRect;
|
---|
178 | INT originalItemHeight = iTextItemHeight;
|
---|
179 |
|
---|
180 | /*
|
---|
181 | * We use the client rect for the width of the item.
|
---|
182 | */
|
---|
183 | GetClientRect(hwnd, &clientRect);
|
---|
184 |
|
---|
185 | lphc->wState &= ~CBF_MEASUREITEM;
|
---|
186 |
|
---|
187 | /*
|
---|
188 | * Send a first one to measure the size of the text area
|
---|
189 | */
|
---|
190 | measureItem.CtlType = ODT_COMBOBOX;
|
---|
191 | measureItem.CtlID = GetWindowLongA(lphc->hwndself,GWL_ID);
|
---|
192 | measureItem.itemID = -1;
|
---|
193 | measureItem.itemWidth = clientRect.right;
|
---|
194 | measureItem.itemHeight = iTextItemHeight - 6; /* ownerdrawn cb is taller */
|
---|
195 | measureItem.itemData = 0;
|
---|
196 | SendMessageA(lphc->owner, WM_MEASUREITEM,
|
---|
197 | (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
|
---|
198 | iTextItemHeight = 6 + measureItem.itemHeight;
|
---|
199 |
|
---|
200 | /*
|
---|
201 | * Send a second one in the case of a fixed ownerdraw list to calculate the
|
---|
202 | * size of the list items. (we basically do this on behalf of the listbox)
|
---|
203 | */
|
---|
204 | if (lphc->dwStyle & CBS_OWNERDRAWFIXED)
|
---|
205 | {
|
---|
206 | measureItem.CtlType = ODT_COMBOBOX;
|
---|
207 | measureItem.CtlID = GetWindowLongA(lphc->hwndself,GWL_ID);
|
---|
208 | measureItem.itemID = 0;
|
---|
209 | measureItem.itemWidth = clientRect.right;
|
---|
210 | measureItem.itemHeight = originalItemHeight;
|
---|
211 | measureItem.itemData = 0;
|
---|
212 | SendMessageA(lphc->owner, WM_MEASUREITEM,
|
---|
213 | (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
|
---|
214 | lphc->fixedOwnerDrawHeight = measureItem.itemHeight;
|
---|
215 | }
|
---|
216 |
|
---|
217 | /*
|
---|
218 | * Keep the size for the next time
|
---|
219 | */
|
---|
220 | lphc->editHeight = iTextItemHeight;
|
---|
221 | }
|
---|
222 |
|
---|
223 | return iTextItemHeight;
|
---|
224 | }
|
---|
225 |
|
---|
226 | /***********************************************************************
|
---|
227 | * CBForceDummyResize
|
---|
228 | *
|
---|
229 | * The dummy resize is used for listboxes that have a popup to trigger
|
---|
230 | * a re-arranging of the contents of the combobox and the recalculation
|
---|
231 | * of the size of the "real" control window.
|
---|
232 | */
|
---|
233 | static void CBForceDummyResize(
|
---|
234 | LPHEADCOMBO lphc)
|
---|
235 | {
|
---|
236 | RECT windowRect;
|
---|
237 | int newComboHeight;
|
---|
238 |
|
---|
239 | newComboHeight = CBGetTextAreaHeight(CB_HWND(lphc),lphc) + 2*COMBO_YBORDERSIZE();
|
---|
240 |
|
---|
241 | GetWindowRect(CB_HWND(lphc), &windowRect);
|
---|
242 |
|
---|
243 | /*
|
---|
244 | * We have to be careful, resizing a combobox also has the meaning that the
|
---|
245 | * dropped rect will be resized. In this case, we want to trigger a resize
|
---|
246 | * to recalculate layout but we don't want to change the dropped rectangle
|
---|
247 | * So, we pass the height of text area of control as the height.
|
---|
248 | * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
|
---|
249 | * message.
|
---|
250 | */
|
---|
251 | SetWindowPos( CB_HWND(lphc),
|
---|
252 | (HWND)0,
|
---|
253 | 0, 0,
|
---|
254 | windowRect.right - windowRect.left,
|
---|
255 | newComboHeight,
|
---|
256 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
|
---|
257 | }
|
---|
258 |
|
---|
259 | /***********************************************************************
|
---|
260 | * CBCalcPlacement
|
---|
261 | *
|
---|
262 | * Set up component coordinates given valid lphc->RectCombo.
|
---|
263 | */
|
---|
264 | static void CBCalcPlacement(
|
---|
265 | HWND hwnd,
|
---|
266 | LPHEADCOMBO lphc,
|
---|
267 | LPRECT lprEdit,
|
---|
268 | LPRECT lprButton,
|
---|
269 | LPRECT lprLB)
|
---|
270 | {
|
---|
271 | /*
|
---|
272 | * Again, start with the client rectangle.
|
---|
273 | */
|
---|
274 | GetClientRect(hwnd, lprEdit);
|
---|
275 |
|
---|
276 | /*
|
---|
277 | * Remove the borders
|
---|
278 | */
|
---|
279 | InflateRect(lprEdit, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
|
---|
280 |
|
---|
281 | /*
|
---|
282 | * Chop off the bottom part to fit with the height of the text area.
|
---|
283 | */
|
---|
284 | lprEdit->bottom = lprEdit->top + CBGetTextAreaHeight(hwnd, lphc);
|
---|
285 |
|
---|
286 | /*
|
---|
287 | * The button starts the same vertical position as the text area.
|
---|
288 | */
|
---|
289 | CopyRect(lprButton, lprEdit);
|
---|
290 |
|
---|
291 | /*
|
---|
292 | * If the combobox is "simple" there is no button.
|
---|
293 | */
|
---|
294 | if( CB_GETTYPE(lphc) == CBS_SIMPLE )
|
---|
295 | lprButton->left = lprButton->right = lprButton->bottom = 0;
|
---|
296 | else
|
---|
297 | {
|
---|
298 | /*
|
---|
299 | * Let's assume the combobox button is the same width as the
|
---|
300 | * scrollbar button.
|
---|
301 | * size the button horizontally and cut-off the text area.
|
---|
302 | */
|
---|
303 | lprButton->left = lprButton->right - GetSystemMetrics(SM_CXVSCROLL);
|
---|
304 | lprEdit->right = lprButton->left;
|
---|
305 | }
|
---|
306 |
|
---|
307 | /*
|
---|
308 | * In the case of a dropdown, there is an additional spacing between the
|
---|
309 | * text area and the button.
|
---|
310 | */
|
---|
311 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
|
---|
312 | {
|
---|
313 | lprEdit->right -= COMBO_EDITBUTTONSPACE();
|
---|
314 | }
|
---|
315 |
|
---|
316 | /*
|
---|
317 | * If we have an edit control, we space it away from the borders slightly.
|
---|
318 | */
|
---|
319 | if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST)
|
---|
320 | {
|
---|
321 | InflateRect(lprEdit, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
|
---|
322 | }
|
---|
323 |
|
---|
324 | /*
|
---|
325 | * Adjust the size of the listbox popup.
|
---|
326 | */
|
---|
327 | if( CB_GETTYPE(lphc) == CBS_SIMPLE )
|
---|
328 | {
|
---|
329 | /*
|
---|
330 | * Use the client rectangle to initialize the listbox rectangle
|
---|
331 | */
|
---|
332 | GetClientRect(hwnd, lprLB);
|
---|
333 |
|
---|
334 | /*
|
---|
335 | * Then, chop-off the top part.
|
---|
336 | */
|
---|
337 | lprLB->top = lprEdit->bottom + COMBO_YBORDERSIZE();
|
---|
338 | }
|
---|
339 | else
|
---|
340 | {
|
---|
341 | //SvL: Listbox size might have changed!
|
---|
342 | if(lphc->hWndLBox)
|
---|
343 | GetWindowRect(lphc->hWndLBox, lprLB);
|
---|
344 |
|
---|
345 | /*
|
---|
346 | * Make sure the dropped width is as large as the combobox itself.
|
---|
347 | */
|
---|
348 | if (lphc->droppedWidth < (lprButton->right + COMBO_XBORDERSIZE()))
|
---|
349 | {
|
---|
350 | lprLB->right = lprLB->left + (lprButton->right + COMBO_XBORDERSIZE());
|
---|
351 |
|
---|
352 | /*
|
---|
353 | * In the case of a dropdown, the popup listbox is offset to the right.
|
---|
354 | * so, we want to make sure it's flush with the right side of the
|
---|
355 | * combobox
|
---|
356 | */
|
---|
357 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
|
---|
358 | lprLB->right -= COMBO_EDITBUTTONSPACE();
|
---|
359 | }
|
---|
360 | else
|
---|
361 | lprLB->right = lprLB->left + lphc->droppedWidth;
|
---|
362 | }
|
---|
363 |
|
---|
364 | //TRACE("\ttext\t= (%i,%i-%i,%i)\n",
|
---|
365 | // lprEdit->left, lprEdit->top, lprEdit->right, lprEdit->bottom);
|
---|
366 |
|
---|
367 | //TRACE("\tbutton\t= (%i,%i-%i,%i)\n",
|
---|
368 | // lprButton->left, lprButton->top, lprButton->right, lprButton->bottom);
|
---|
369 |
|
---|
370 | //TRACE("\tlbox\t= (%i,%i-%i,%i)\n",
|
---|
371 | // lprLB->left, lprLB->top, lprLB->right, lprLB->bottom );
|
---|
372 | }
|
---|
373 |
|
---|
374 | /***********************************************************************
|
---|
375 | * CBGetDroppedControlRect
|
---|
376 | */
|
---|
377 | static void CBGetDroppedControlRect( LPHEADCOMBO lphc, LPRECT lpRect)
|
---|
378 | {
|
---|
379 | /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
|
---|
380 | of the combo box and the lower right corner of the listbox */
|
---|
381 |
|
---|
382 | GetWindowRect(lphc->hwndself, lpRect);
|
---|
383 |
|
---|
384 | lpRect->right = lpRect->left + lphc->droppedRect.right - lphc->droppedRect.left;
|
---|
385 | lpRect->bottom = lpRect->top + lphc->droppedRect.bottom - lphc->droppedRect.top;
|
---|
386 |
|
---|
387 | }
|
---|
388 |
|
---|
389 | /***********************************************************************
|
---|
390 | * COMBO_WindowPosChanging
|
---|
391 | */
|
---|
392 | static LRESULT COMBO_WindowPosChanging(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
393 | {
|
---|
394 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
395 | WINDOWPOS *posChanging = (WINDOWPOS*)lParam;
|
---|
396 |
|
---|
397 | dprintf(("COMBO_WindowPosChanging"));
|
---|
398 |
|
---|
399 | /*
|
---|
400 | * We need to override the WM_WINDOWPOSCHANGING method to handle all
|
---|
401 | * the non-simple comboboxes. The problem is that those controls are
|
---|
402 | * always the same height. We have to make sure they are not resized
|
---|
403 | * to another value.
|
---|
404 | */
|
---|
405 | if ( ( CB_GETTYPE(lphc) != CBS_SIMPLE ) &&
|
---|
406 | ((posChanging->flags & SWP_NOSIZE) == 0) )
|
---|
407 | {
|
---|
408 | int newComboHeight;
|
---|
409 |
|
---|
410 | newComboHeight = CBGetTextAreaHeight(hwnd,lphc) +
|
---|
411 | 2*COMBO_YBORDERSIZE();
|
---|
412 |
|
---|
413 | /*
|
---|
414 | * Resizing a combobox has another side effect, it resizes the dropped
|
---|
415 | * rectangle as well. However, it does it only if the new height for the
|
---|
416 | * combobox is different than the height it should have. In other words,
|
---|
417 | * if the application resizing the combobox only had the intention to resize
|
---|
418 | * the actual control, for example, to do the layout of a dialog that is
|
---|
419 | * resized, the height of the dropdown is not changed.
|
---|
420 | */
|
---|
421 | if (posChanging->cy != newComboHeight)
|
---|
422 | {
|
---|
423 | lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight;
|
---|
424 |
|
---|
425 | posChanging->cy = newComboHeight;
|
---|
426 | }
|
---|
427 | }
|
---|
428 |
|
---|
429 | return 0;
|
---|
430 | }
|
---|
431 |
|
---|
432 | /***********************************************************************
|
---|
433 | * COMBO_Create
|
---|
434 | */
|
---|
435 | static LRESULT COMBO_Create(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
436 | {
|
---|
437 | static char clbName[] = "ComboLBox";
|
---|
438 | static char editName[] = "Edit";
|
---|
439 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
440 |
|
---|
441 | LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
|
---|
442 |
|
---|
443 | if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
|
---|
444 | else if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
|
---|
445 |
|
---|
446 | lphc->hwndself = hwnd;
|
---|
447 | lphc->owner = lpcs->hwndParent;
|
---|
448 |
|
---|
449 | /*
|
---|
450 | * The item height and dropped width are not set when the control
|
---|
451 | * is created.
|
---|
452 | */
|
---|
453 | lphc->droppedWidth = lphc->editHeight = 0;
|
---|
454 |
|
---|
455 | /*
|
---|
456 | * The first time we go through, we want to measure the ownerdraw item
|
---|
457 | */
|
---|
458 | lphc->wState |= CBF_MEASUREITEM;
|
---|
459 |
|
---|
460 | /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
|
---|
461 |
|
---|
462 | if( lphc->owner || !(lpcs->style & WS_VISIBLE) )
|
---|
463 | {
|
---|
464 | UINT lbeStyle = 0;
|
---|
465 | UINT lbeExStyle = 0;
|
---|
466 |
|
---|
467 | /*
|
---|
468 | * Initialize the dropped rect to the size of the client area of the
|
---|
469 | * control and then, force all the areas of the combobox to be
|
---|
470 | * recalculated.
|
---|
471 | */
|
---|
472 | GetClientRect( hwnd, &lphc->droppedRect );
|
---|
473 |
|
---|
474 | CBCalcPlacement(hwnd,
|
---|
475 | lphc,
|
---|
476 | &lphc->textRect,
|
---|
477 | &lphc->buttonRect,
|
---|
478 | &lphc->droppedRect );
|
---|
479 |
|
---|
480 | /*
|
---|
481 | * Adjust the position of the popup listbox if it's necessary
|
---|
482 | */
|
---|
483 | if ( CB_GETTYPE(lphc) != CBS_SIMPLE )
|
---|
484 | {
|
---|
485 | lphc->droppedRect.top = lphc->textRect.bottom + COMBO_YBORDERSIZE();
|
---|
486 |
|
---|
487 | /*
|
---|
488 | * If it's a dropdown, the listbox is offset
|
---|
489 | */
|
---|
490 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
|
---|
491 | lphc->droppedRect.left += COMBO_EDITBUTTONSPACE();
|
---|
492 |
|
---|
493 | ClientToScreen(hwnd, (LPPOINT)&lphc->droppedRect);
|
---|
494 | ClientToScreen(hwnd, (LPPOINT)&lphc->droppedRect.right);
|
---|
495 | }
|
---|
496 |
|
---|
497 | /* create listbox popup */
|
---|
498 |
|
---|
499 | lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS) |
|
---|
500 | (lpcs->style & (WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE));
|
---|
501 |
|
---|
502 | if( lphc->dwStyle & CBS_SORT )
|
---|
503 | lbeStyle |= LBS_SORT;
|
---|
504 | if( lphc->dwStyle & CBS_HASSTRINGS )
|
---|
505 | lbeStyle |= LBS_HASSTRINGS;
|
---|
506 | if( lphc->dwStyle & CBS_NOINTEGRALHEIGHT )
|
---|
507 | lbeStyle |= LBS_NOINTEGRALHEIGHT;
|
---|
508 | if( lphc->dwStyle & CBS_DISABLENOSCROLL )
|
---|
509 | lbeStyle |= LBS_DISABLENOSCROLL;
|
---|
510 |
|
---|
511 | if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */
|
---|
512 | {
|
---|
513 | lbeStyle |= WS_CHILD | WS_VISIBLE;
|
---|
514 |
|
---|
515 | /*
|
---|
516 | * In win 95 look n feel, the listbox in the simple combobox has
|
---|
517 | * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
|
---|
518 | */
|
---|
519 | lbeStyle &= ~WS_BORDER;
|
---|
520 | lbeExStyle |= WS_EX_CLIENTEDGE;
|
---|
521 | }
|
---|
522 | else /* popup listbox */
|
---|
523 | lbeStyle |= WS_POPUP;
|
---|
524 |
|
---|
525 | /* Dropdown ComboLBox is not a child window and we cannot pass
|
---|
526 | * ID_CB_LISTBOX directly because it will be treated as a menu handle.
|
---|
527 | */
|
---|
528 | lphc->hWndLBox = CreateWindowExA(lbeExStyle,
|
---|
529 | clbName,
|
---|
530 | NULL,
|
---|
531 | lbeStyle,
|
---|
532 | lphc->droppedRect.left,
|
---|
533 | lphc->droppedRect.top,
|
---|
534 | lphc->droppedRect.right - lphc->droppedRect.left,
|
---|
535 | lphc->droppedRect.bottom - lphc->droppedRect.top,
|
---|
536 | lphc->hwndself,
|
---|
537 | (lphc->dwStyle & CBS_DROPDOWN)? (HMENU)0 : (HMENU)ID_CB_LISTBOX,
|
---|
538 | GetWindowLongA(lphc->hwndself,GWL_HINSTANCE),
|
---|
539 | (LPVOID)lphc );
|
---|
540 |
|
---|
541 | /*
|
---|
542 | * The ComboLBox is a strange little beast (when it's not a CBS_SIMPLE)...
|
---|
543 | * It's a popup window but, when you get the window style, you get WS_CHILD.
|
---|
544 | * When created, it's parent is the combobox but, when you ask for it's parent
|
---|
545 | * after that, you're supposed to get the desktop. (see MFC code function
|
---|
546 | * AfxCancelModes)
|
---|
547 | * To achieve this in Wine, we have to create it as a popup and change
|
---|
548 | * it's style to child after the creation.
|
---|
549 | */
|
---|
550 | if ( (lphc->hWndLBox!= 0) &&
|
---|
551 | (CB_GETTYPE(lphc) != CBS_SIMPLE) )
|
---|
552 | {
|
---|
553 | SetWindowLongA(lphc->hWndLBox,
|
---|
554 | GWL_STYLE,
|
---|
555 | (GetWindowLongA(lphc->hWndLBox, GWL_STYLE) | WS_CHILD) & ~WS_POPUP);
|
---|
556 | }
|
---|
557 |
|
---|
558 | if( lphc->hWndLBox )
|
---|
559 | {
|
---|
560 | BOOL bEdit = TRUE;
|
---|
561 | lbeStyle = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT;
|
---|
562 |
|
---|
563 | /*
|
---|
564 | * In Win95 look, the border fo the edit control is
|
---|
565 | * provided by the combobox
|
---|
566 | */
|
---|
567 | if( lphc->wState & CBF_EDIT )
|
---|
568 | {
|
---|
569 | if( lphc->dwStyle & CBS_OEMCONVERT )
|
---|
570 | lbeStyle |= ES_OEMCONVERT;
|
---|
571 | if( lphc->dwStyle & CBS_AUTOHSCROLL )
|
---|
572 | lbeStyle |= ES_AUTOHSCROLL;
|
---|
573 | if( lphc->dwStyle & CBS_LOWERCASE )
|
---|
574 | lbeStyle |= ES_LOWERCASE;
|
---|
575 | else if( lphc->dwStyle & CBS_UPPERCASE )
|
---|
576 | lbeStyle |= ES_UPPERCASE;
|
---|
577 |
|
---|
578 | lphc->hWndEdit = CreateWindowExA(0,
|
---|
579 | editName,
|
---|
580 | NULL,
|
---|
581 | lbeStyle,
|
---|
582 | lphc->textRect.left, lphc->textRect.top,
|
---|
583 | lphc->textRect.right - lphc->textRect.left,
|
---|
584 | lphc->textRect.bottom - lphc->textRect.top,
|
---|
585 | lphc->hwndself,
|
---|
586 | (HMENU)ID_CB_EDIT,
|
---|
587 | GetWindowLongA(lphc->hwndself,GWL_HINSTANCE),
|
---|
588 | NULL );
|
---|
589 |
|
---|
590 | if( !lphc->hWndEdit )
|
---|
591 | bEdit = FALSE;
|
---|
592 | }
|
---|
593 |
|
---|
594 | if( bEdit )
|
---|
595 | {
|
---|
596 | /*
|
---|
597 | * If the combo is a dropdown, we must resize the control to fit only
|
---|
598 | * the text area and button. To do this, we send a dummy resize and the
|
---|
599 | * WM_WINDOWPOSCHANGING message will take care of setting the height for
|
---|
600 | * us.
|
---|
601 | */
|
---|
602 | if( CB_GETTYPE(lphc) != CBS_SIMPLE )
|
---|
603 | {
|
---|
604 | CBForceDummyResize(lphc);
|
---|
605 | }
|
---|
606 |
|
---|
607 | //TRACE("init done\n");
|
---|
608 | return hwnd;
|
---|
609 | }
|
---|
610 | //ERR("edit control failure.\n");
|
---|
611 | } //else ERR("listbox failure.\n");
|
---|
612 | } //else ERR("no owner for visible combo.\n");
|
---|
613 |
|
---|
614 | /* CreateWindow() will send WM_NCDESTROY to cleanup */
|
---|
615 |
|
---|
616 | return -1;
|
---|
617 | }
|
---|
618 |
|
---|
619 | /***********************************************************************
|
---|
620 | * CBPaintButton
|
---|
621 | *
|
---|
622 | * Paint combo button (normal, pressed, and disabled states).
|
---|
623 | */
|
---|
624 | static void CBPaintButton(
|
---|
625 | LPHEADCOMBO lphc,
|
---|
626 | HDC hdc,
|
---|
627 | RECT rectButton)
|
---|
628 | {
|
---|
629 | if( lphc->wState & CBF_NOREDRAW )
|
---|
630 | return;
|
---|
631 |
|
---|
632 |
|
---|
633 | UINT buttonState = DFCS_SCROLLCOMBOBOX;
|
---|
634 |
|
---|
635 | if (lphc->wState & CBF_BUTTONDOWN)
|
---|
636 | {
|
---|
637 | buttonState |= DFCS_PUSHED;
|
---|
638 | }
|
---|
639 |
|
---|
640 | if (CB_DISABLED(lphc))
|
---|
641 | {
|
---|
642 | buttonState |= DFCS_INACTIVE;
|
---|
643 | }
|
---|
644 |
|
---|
645 | DrawFrameControl(hdc,&rectButton,DFC_SCROLL,buttonState);
|
---|
646 | }
|
---|
647 |
|
---|
648 | /***********************************************************************
|
---|
649 | * CBPaintText
|
---|
650 | *
|
---|
651 | * Paint CBS_DROPDOWNLIST text field / update edit control contents.
|
---|
652 | */
|
---|
653 | static void CBPaintText(
|
---|
654 | LPHEADCOMBO lphc,
|
---|
655 | HDC hdc,
|
---|
656 | RECT rectEdit)
|
---|
657 | {
|
---|
658 | INT id, size = 0;
|
---|
659 | LPSTR pText = NULL;
|
---|
660 |
|
---|
661 | if( lphc->wState & CBF_NOREDRAW ) return;
|
---|
662 |
|
---|
663 | /* follow Windows combobox that sends a bunch of text
|
---|
664 | * inquiries to its listbox while processing WM_PAINT. */
|
---|
665 |
|
---|
666 | if( (id = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0) ) != LB_ERR )
|
---|
667 | {
|
---|
668 | size = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, id, 0);
|
---|
669 | if( (pText = (char*)HeapAlloc( GetProcessHeap(), 0, size + 1)) != NULL )
|
---|
670 | {
|
---|
671 | SendMessageA( lphc->hWndLBox, LB_GETTEXT, (WPARAM)id, (LPARAM)pText );
|
---|
672 | pText[size] = '\0'; /* just in case */
|
---|
673 | } else return;
|
---|
674 | }
|
---|
675 |
|
---|
676 | if( lphc->wState & CBF_EDIT )
|
---|
677 | {
|
---|
678 | if( CB_HASSTRINGS(lphc) ) SetWindowTextA( lphc->hWndEdit, pText ? pText : "" );
|
---|
679 | if( lphc->wState & CBF_FOCUSED )
|
---|
680 | SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
|
---|
681 | }
|
---|
682 | else /* paint text field ourselves */
|
---|
683 | {
|
---|
684 | UINT itemState;
|
---|
685 | HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
|
---|
686 |
|
---|
687 | /*
|
---|
688 | * Give ourselves some space.
|
---|
689 | */
|
---|
690 | InflateRect( &rectEdit, -1, -1 );
|
---|
691 |
|
---|
692 | if ( (lphc->wState & CBF_FOCUSED) &&
|
---|
693 | !(lphc->wState & CBF_DROPPED) )
|
---|
694 | {
|
---|
695 | /* highlight */
|
---|
696 |
|
---|
697 | FillRect( hdc, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) );
|
---|
698 | SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
|
---|
699 | SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
|
---|
700 | itemState = ODS_SELECTED | ODS_FOCUS;
|
---|
701 | }
|
---|
702 | else
|
---|
703 | itemState = 0;
|
---|
704 |
|
---|
705 | if( CB_OWNERDRAWN(lphc) )
|
---|
706 | {
|
---|
707 | DRAWITEMSTRUCT dis;
|
---|
708 | HRGN clipRegion;
|
---|
709 | DWORD dwStyle = GetWindowLongA(lphc->hwndself,GWL_STYLE);
|
---|
710 |
|
---|
711 | /*
|
---|
712 | * Save the current clip region.
|
---|
713 | * To retrieve the clip region, we need to create one "dummy"
|
---|
714 | * clip region.
|
---|
715 | */
|
---|
716 | clipRegion = CreateRectRgnIndirect(&rectEdit);
|
---|
717 |
|
---|
718 | if (GetClipRgn(hdc, clipRegion)!=1)
|
---|
719 | {
|
---|
720 | DeleteObject(clipRegion);
|
---|
721 | clipRegion=(HRGN)NULL;
|
---|
722 | }
|
---|
723 |
|
---|
724 | if ( dwStyle & WS_DISABLED )
|
---|
725 | itemState |= ODS_DISABLED;
|
---|
726 |
|
---|
727 | dis.CtlType = ODT_COMBOBOX;
|
---|
728 | dis.CtlID = GetWindowLongA(lphc->hwndself,GWL_ID);
|
---|
729 | dis.hwndItem = lphc->hwndself;
|
---|
730 | dis.itemAction = ODA_DRAWENTIRE;
|
---|
731 | dis.itemID = id;
|
---|
732 | dis.itemState = itemState;
|
---|
733 | dis.hDC = hdc;
|
---|
734 | dis.rcItem = rectEdit;
|
---|
735 | dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA,
|
---|
736 | (WPARAM)id, 0 );
|
---|
737 |
|
---|
738 | /*
|
---|
739 | * Clip the DC and have the parent draw the item.
|
---|
740 | */
|
---|
741 | IntersectClipRect(hdc,
|
---|
742 | rectEdit.left, rectEdit.top,
|
---|
743 | rectEdit.right, rectEdit.bottom);
|
---|
744 |
|
---|
745 | SendMessageA(lphc->owner, WM_DRAWITEM,
|
---|
746 | GetWindowLongA(lphc->hwndself,GWL_ID), (LPARAM)&dis );
|
---|
747 |
|
---|
748 | /*
|
---|
749 | * Reset the clipping region.
|
---|
750 | */
|
---|
751 | SelectClipRgn(hdc, clipRegion);
|
---|
752 | }
|
---|
753 | else
|
---|
754 | {
|
---|
755 | ExtTextOutA( hdc,
|
---|
756 | rectEdit.left + 1,
|
---|
757 | rectEdit.top + 1,
|
---|
758 | ETO_OPAQUE | ETO_CLIPPED,
|
---|
759 | &rectEdit,
|
---|
760 | pText ? pText : "" , size, NULL );
|
---|
761 |
|
---|
762 | if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED))
|
---|
763 | DrawFocusRect( hdc, &rectEdit );
|
---|
764 | }
|
---|
765 |
|
---|
766 | if( hPrevFont )
|
---|
767 | SelectObject(hdc, hPrevFont );
|
---|
768 | }
|
---|
769 | if (pText)
|
---|
770 | HeapFree( GetProcessHeap(), 0, pText );
|
---|
771 | }
|
---|
772 |
|
---|
773 | /***********************************************************************
|
---|
774 | * CBPaintBorder
|
---|
775 | */
|
---|
776 | static void CBPaintBorder(
|
---|
777 | HWND hwnd,
|
---|
778 | LPHEADCOMBO lphc,
|
---|
779 | HDC hdc)
|
---|
780 | {
|
---|
781 | RECT clientRect;
|
---|
782 |
|
---|
783 | if (CB_GETTYPE(lphc) != CBS_SIMPLE)
|
---|
784 | {
|
---|
785 | GetClientRect(hwnd, &clientRect);
|
---|
786 | }
|
---|
787 | else
|
---|
788 | {
|
---|
789 | CopyRect(&clientRect, &lphc->textRect);
|
---|
790 |
|
---|
791 | InflateRect(&clientRect, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
|
---|
792 | InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
|
---|
793 | }
|
---|
794 |
|
---|
795 | DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
|
---|
796 | }
|
---|
797 |
|
---|
798 | /***********************************************************************
|
---|
799 | * COMBO_PrepareColors
|
---|
800 | *
|
---|
801 | * This method will sent the appropriate WM_CTLCOLOR message to
|
---|
802 | * prepare and setup the colors for the combo's DC.
|
---|
803 | *
|
---|
804 | * It also returns the brush to use for the background.
|
---|
805 | */
|
---|
806 | static HBRUSH COMBO_PrepareColors(
|
---|
807 | HWND hwnd,
|
---|
808 | LPHEADCOMBO lphc,
|
---|
809 | HDC hDC)
|
---|
810 | {
|
---|
811 | HBRUSH hBkgBrush;
|
---|
812 |
|
---|
813 | /*
|
---|
814 | * Get the background brush for this control.
|
---|
815 | */
|
---|
816 | if (CB_DISABLED(lphc))
|
---|
817 | {
|
---|
818 | hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORSTATIC,
|
---|
819 | hDC, lphc->hwndself );
|
---|
820 |
|
---|
821 | /*
|
---|
822 | * We have to change the text color since WM_CTLCOLORSTATIC will
|
---|
823 | * set it to the "enabled" color. This is the same behavior as the
|
---|
824 | * edit control
|
---|
825 | */
|
---|
826 | SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT));
|
---|
827 | }
|
---|
828 | else
|
---|
829 | {
|
---|
830 | if (lphc->wState & CBF_EDIT)
|
---|
831 | {
|
---|
832 | hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLOREDIT,
|
---|
833 | hDC, lphc->hwndself );
|
---|
834 | }
|
---|
835 | else
|
---|
836 | {
|
---|
837 | hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX,
|
---|
838 | hDC, lphc->hwndself );
|
---|
839 | }
|
---|
840 | }
|
---|
841 |
|
---|
842 | /*
|
---|
843 | * Catch errors.
|
---|
844 | */
|
---|
845 | if( !hBkgBrush )
|
---|
846 | hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
|
---|
847 |
|
---|
848 | return hBkgBrush;
|
---|
849 | }
|
---|
850 |
|
---|
851 | /***********************************************************************
|
---|
852 | * COMBO_EraseBackground
|
---|
853 | */
|
---|
854 | static LRESULT COMBO_EraseBackground(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
855 | {
|
---|
856 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
857 | HBRUSH hBkgBrush;
|
---|
858 | RECT clientRect;
|
---|
859 | HDC hDC;
|
---|
860 |
|
---|
861 | hDC = (wParam) ? (HDC)wParam:GetDC(hwnd);
|
---|
862 |
|
---|
863 | /*
|
---|
864 | * Calculate the area that we want to erase.
|
---|
865 | */
|
---|
866 | if (CB_GETTYPE(lphc) != CBS_SIMPLE)
|
---|
867 | {
|
---|
868 | GetClientRect(hwnd, &clientRect);
|
---|
869 | }
|
---|
870 | else
|
---|
871 | {
|
---|
872 | CopyRect(&clientRect, &lphc->textRect);
|
---|
873 |
|
---|
874 | InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
|
---|
875 | }
|
---|
876 |
|
---|
877 | /*
|
---|
878 | * Retrieve the background brush
|
---|
879 | */
|
---|
880 | hBkgBrush = COMBO_PrepareColors(hwnd, lphc, hDC);
|
---|
881 |
|
---|
882 | FillRect(hDC, &clientRect, hBkgBrush);
|
---|
883 |
|
---|
884 | if (!wParam)
|
---|
885 | ReleaseDC(hwnd, hDC);
|
---|
886 |
|
---|
887 | return TRUE;
|
---|
888 | }
|
---|
889 |
|
---|
890 | static LRESULT COMBO_GetDlgCode(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
891 | {
|
---|
892 | return DLGC_WANTARROWS | DLGC_WANTCHARS;
|
---|
893 | }
|
---|
894 |
|
---|
895 | /***********************************************************************
|
---|
896 | * COMBO_Paint
|
---|
897 | */
|
---|
898 | static LRESULT COMBO_Paint(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
899 | {
|
---|
900 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
901 | PAINTSTRUCT ps;
|
---|
902 | HDC hDC;
|
---|
903 |
|
---|
904 | hDC = (wParam) ? (HDC)wParam:BeginPaint(hwnd,&ps);
|
---|
905 |
|
---|
906 |
|
---|
907 | if( hDC && !(lphc->wState & CBF_NOREDRAW) )
|
---|
908 | {
|
---|
909 | HBRUSH hPrevBrush, hBkgBrush;
|
---|
910 |
|
---|
911 | /*
|
---|
912 | * Retrieve the background brush and select it in the
|
---|
913 | * DC.
|
---|
914 | */
|
---|
915 | hBkgBrush = COMBO_PrepareColors(hwnd,lphc,hDC);
|
---|
916 |
|
---|
917 | hPrevBrush = SelectObject( hDC, hBkgBrush );
|
---|
918 |
|
---|
919 | /*
|
---|
920 | * In non 3.1 look, there is a sunken border on the combobox
|
---|
921 | */
|
---|
922 | CBPaintBorder(CB_HWND(lphc), lphc, hDC);
|
---|
923 |
|
---|
924 | if( !IsRectEmpty(&lphc->buttonRect) )
|
---|
925 | {
|
---|
926 | CBPaintButton(lphc, hDC, lphc->buttonRect);
|
---|
927 | }
|
---|
928 |
|
---|
929 | if( !(lphc->wState & CBF_EDIT) )
|
---|
930 | {
|
---|
931 | /*
|
---|
932 | * The text area has a border only in Win 3.1 look.
|
---|
933 | */
|
---|
934 |
|
---|
935 | CBPaintText( lphc, hDC, lphc->textRect);
|
---|
936 | }
|
---|
937 |
|
---|
938 | if( hPrevBrush )
|
---|
939 | SelectObject( hDC, hPrevBrush );
|
---|
940 | }
|
---|
941 |
|
---|
942 | if(!wParam) EndPaint(hwnd,&ps);
|
---|
943 |
|
---|
944 | return 0;
|
---|
945 | }
|
---|
946 |
|
---|
947 | static LRESULT COMBO_PrintClient(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
948 | {
|
---|
949 | if (lParam & PRF_ERASEBKGND) COMBO_EraseBackground(hwnd,wParam,lParam);
|
---|
950 |
|
---|
951 | return COMBO_Paint(hwnd,wParam,lParam);
|
---|
952 | }
|
---|
953 |
|
---|
954 | /***********************************************************************
|
---|
955 | * CBUpdateLBox
|
---|
956 | *
|
---|
957 | * Select listbox entry according to the contents of the edit control.
|
---|
958 | */
|
---|
959 | static INT CBUpdateLBox( LPHEADCOMBO lphc )
|
---|
960 | {
|
---|
961 | INT length, idx;
|
---|
962 | LPSTR pText = NULL;
|
---|
963 |
|
---|
964 | idx = LB_ERR;
|
---|
965 | length = CB_GETEDITTEXTLENGTH( lphc );
|
---|
966 |
|
---|
967 | if( length > 0 )
|
---|
968 | pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1);
|
---|
969 |
|
---|
970 | //TRACE("\t edit text length %i\n", length );
|
---|
971 |
|
---|
972 | if( pText )
|
---|
973 | {
|
---|
974 | if( length ) GetWindowTextA( lphc->hWndEdit, pText, length + 1);
|
---|
975 | else pText[0] = '\0';
|
---|
976 | idx = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
|
---|
977 | (WPARAM)(-1), (LPARAM)pText );
|
---|
978 | HeapFree( GetProcessHeap(), 0, pText );
|
---|
979 | }
|
---|
980 |
|
---|
981 | if( idx >= 0 )
|
---|
982 | {
|
---|
983 | SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)idx, 0 );
|
---|
984 | /* probably superfluous but Windows sends this too */
|
---|
985 | SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)idx, 0 );
|
---|
986 | }
|
---|
987 | return idx;
|
---|
988 | }
|
---|
989 |
|
---|
990 | /***********************************************************************
|
---|
991 | * CBUpdateEdit
|
---|
992 | *
|
---|
993 | * Copy a listbox entry to the edit control.
|
---|
994 | */
|
---|
995 | static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
|
---|
996 | {
|
---|
997 | INT length;
|
---|
998 | LPSTR pText = NULL;
|
---|
999 |
|
---|
1000 | //TRACE("\t %i\n", index );
|
---|
1001 |
|
---|
1002 | if( index >= 0 ) /* got an entry */
|
---|
1003 | {
|
---|
1004 | length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, (WPARAM)index, 0);
|
---|
1005 | if( length )
|
---|
1006 | {
|
---|
1007 | pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1);
|
---|
1008 | if(pText)
|
---|
1009 | {
|
---|
1010 | SendMessageA( lphc->hWndLBox, LB_GETTEXT,
|
---|
1011 | (WPARAM)index, (LPARAM)pText );
|
---|
1012 | }
|
---|
1013 | }
|
---|
1014 | }
|
---|
1015 | lphc->wState |= CBF_NOEDITNOTIFY;
|
---|
1016 |
|
---|
1017 | SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, pText ? (LPARAM)pText : (LPARAM)"" );
|
---|
1018 |
|
---|
1019 | if( pText )
|
---|
1020 | HeapFree( GetProcessHeap(), 0, pText );
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | /***********************************************************************
|
---|
1024 | * CBDropDown
|
---|
1025 | *
|
---|
1026 | * Show listbox popup.
|
---|
1027 | */
|
---|
1028 | static void CBDropDown( LPHEADCOMBO lphc )
|
---|
1029 | {
|
---|
1030 | RECT rect;
|
---|
1031 | int nItems = 0;
|
---|
1032 | int i;
|
---|
1033 | int nHeight;
|
---|
1034 | int nDroppedHeight,nTempDroppedHeight;
|
---|
1035 |
|
---|
1036 | //TRACE("[%04x]: drop down\n", CB_HWND(lphc));
|
---|
1037 |
|
---|
1038 | CB_NOTIFY( lphc, CBN_DROPDOWN );
|
---|
1039 |
|
---|
1040 | /* set selection */
|
---|
1041 |
|
---|
1042 | lphc->wState |= CBF_DROPPED;
|
---|
1043 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
|
---|
1044 | {
|
---|
1045 | lphc->droppedIndex = CBUpdateLBox( lphc );
|
---|
1046 |
|
---|
1047 | if( !(lphc->wState & CBF_CAPTURE) )
|
---|
1048 | CBUpdateEdit( lphc, lphc->droppedIndex );
|
---|
1049 | }
|
---|
1050 | else
|
---|
1051 | {
|
---|
1052 | lphc->droppedIndex = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
|
---|
1053 |
|
---|
1054 | if( lphc->droppedIndex == LB_ERR )
|
---|
1055 | lphc->droppedIndex = 0;
|
---|
1056 |
|
---|
1057 | SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)lphc->droppedIndex, 0 );
|
---|
1058 | SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | /* now set popup position */
|
---|
1062 | GetWindowRect( lphc->hwndself, &rect );
|
---|
1063 |
|
---|
1064 | /*
|
---|
1065 | * If it's a dropdown, the listbox is offset
|
---|
1066 | */
|
---|
1067 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
|
---|
1068 | rect.left += COMBO_EDITBUTTONSPACE();
|
---|
1069 |
|
---|
1070 | /* if the dropped height is greater than the total height of the dropped
|
---|
1071 | items list, then force the drop down list height to be the total height
|
---|
1072 | of the items in the dropped list */
|
---|
1073 |
|
---|
1074 | /* And Remove any extra space (Best Fit) */
|
---|
1075 | nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
|
---|
1076 | nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
|
---|
1077 | nHeight = COMBO_YBORDERSIZE();
|
---|
1078 | nTempDroppedHeight = 0;
|
---|
1079 | for (i = 0; i < nItems; i++)
|
---|
1080 | {
|
---|
1081 | nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0);
|
---|
1082 |
|
---|
1083 | /* Did we pass the limit of what can be displayed */
|
---|
1084 | if (nHeight > nDroppedHeight)
|
---|
1085 | {
|
---|
1086 | break;
|
---|
1087 | }
|
---|
1088 | nTempDroppedHeight = nHeight;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | nDroppedHeight = nTempDroppedHeight;
|
---|
1092 |
|
---|
1093 | SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
|
---|
1094 | lphc->droppedRect.right - lphc->droppedRect.left,
|
---|
1095 | nDroppedHeight,
|
---|
1096 | SWP_NOACTIVATE | SWP_NOREDRAW);
|
---|
1097 |
|
---|
1098 |
|
---|
1099 | if( !(lphc->wState & CBF_NOREDRAW) )
|
---|
1100 | RedrawWindow( lphc->hwndself, NULL, 0, RDW_INVALIDATE |
|
---|
1101 | RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
|
---|
1102 |
|
---|
1103 | ShowWindow( lphc->hWndLBox, SW_SHOWNA );
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | /***********************************************************************
|
---|
1107 | * CBRollUp
|
---|
1108 | *
|
---|
1109 | * Hide listbox popup.
|
---|
1110 | */
|
---|
1111 | static void CBRollUp( LPHEADCOMBO lphc, BOOL ok, BOOL bButton )
|
---|
1112 | {
|
---|
1113 | HWND hWnd = lphc->hwndself;
|
---|
1114 |
|
---|
1115 | CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL );
|
---|
1116 |
|
---|
1117 | if( IsWindow( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE )
|
---|
1118 | {
|
---|
1119 |
|
---|
1120 | //TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok );
|
---|
1121 |
|
---|
1122 | if( lphc->wState & CBF_DROPPED )
|
---|
1123 | {
|
---|
1124 | RECT rect;
|
---|
1125 |
|
---|
1126 | lphc->wState &= ~CBF_DROPPED;
|
---|
1127 | ShowWindow( lphc->hWndLBox, SW_HIDE );
|
---|
1128 | if(GetCapture() == lphc->hWndLBox)
|
---|
1129 | {
|
---|
1130 | ReleaseCapture();
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
|
---|
1134 | {
|
---|
1135 | INT index = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
|
---|
1136 | CBUpdateEdit( lphc, index );
|
---|
1137 | rect = lphc->buttonRect;
|
---|
1138 | }
|
---|
1139 | else
|
---|
1140 | {
|
---|
1141 | if( bButton )
|
---|
1142 | {
|
---|
1143 | UnionRect( &rect,
|
---|
1144 | &lphc->buttonRect,
|
---|
1145 | &lphc->textRect);
|
---|
1146 | }
|
---|
1147 | else
|
---|
1148 | rect = lphc->textRect;
|
---|
1149 |
|
---|
1150 | bButton = TRUE;
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | if( bButton && !(lphc->wState & CBF_NOREDRAW) )
|
---|
1154 | RedrawWindow( hWnd, &rect, 0, RDW_INVALIDATE |
|
---|
1155 | RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
|
---|
1156 | CB_NOTIFY( lphc, CBN_CLOSEUP );
|
---|
1157 | }
|
---|
1158 | }
|
---|
1159 | }
|
---|
1160 |
|
---|
1161 | /***********************************************************************
|
---|
1162 | * COMBO_FlipListbox
|
---|
1163 | *
|
---|
1164 | * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
|
---|
1165 | */
|
---|
1166 | BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL bRedrawButton )
|
---|
1167 | {
|
---|
1168 | if( lphc->wState & CBF_DROPPED )
|
---|
1169 | {
|
---|
1170 | CBRollUp( lphc, TRUE, bRedrawButton );
|
---|
1171 | return FALSE;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | CBDropDown( lphc );
|
---|
1175 | return TRUE;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | /***********************************************************************
|
---|
1179 | * COMBO_GetLBWindow
|
---|
1180 | *
|
---|
1181 | * Edit control helper.
|
---|
1182 | */
|
---|
1183 | HWND COMBO_GetLBWindow( HWND hwnd )
|
---|
1184 | {
|
---|
1185 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1186 |
|
---|
1187 | return lphc ? lphc->hWndLBox:0;
|
---|
1188 | }
|
---|
1189 |
|
---|
1190 |
|
---|
1191 | /***********************************************************************
|
---|
1192 | * CBRepaintButton
|
---|
1193 | */
|
---|
1194 | static void CBRepaintButton( LPHEADCOMBO lphc )
|
---|
1195 | {
|
---|
1196 | InvalidateRect(CB_HWND(lphc), &lphc->buttonRect, TRUE);
|
---|
1197 | UpdateWindow(CB_HWND(lphc));
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 | static VOID COMBO_EditSetFocus(LPHEADCOMBO lphc)
|
---|
1201 | {
|
---|
1202 | if(!(lphc->wState & CBF_FOCUSED))
|
---|
1203 | {
|
---|
1204 | if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
|
---|
1205 | SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
|
---|
1206 |
|
---|
1207 | lphc->wState |= CBF_FOCUSED;
|
---|
1208 |
|
---|
1209 | if( !(lphc->wState & CBF_EDIT) )
|
---|
1210 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
|
---|
1211 |
|
---|
1212 | CB_NOTIFY( lphc, CBN_SETFOCUS );
|
---|
1213 | }
|
---|
1214 | }
|
---|
1215 |
|
---|
1216 | /***********************************************************************
|
---|
1217 | * COMBO_SetFocus
|
---|
1218 | */
|
---|
1219 | static LRESULT COMBO_SetFocus(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1220 | {
|
---|
1221 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1222 |
|
---|
1223 | if(lphc->wState & CBF_EDIT)
|
---|
1224 | SetFocus(lphc->hWndEdit);
|
---|
1225 | else
|
---|
1226 | COMBO_EditSetFocus(lphc);
|
---|
1227 |
|
---|
1228 | return 0;
|
---|
1229 | }
|
---|
1230 |
|
---|
1231 | static VOID COMBO_EditKillFocus(LPHEADCOMBO lphc)
|
---|
1232 | {
|
---|
1233 | if( lphc->wState & CBF_FOCUSED )
|
---|
1234 | {
|
---|
1235 | CBRollUp( lphc, FALSE, TRUE );
|
---|
1236 | if( IsWindow( lphc->hwndself ) )
|
---|
1237 | {
|
---|
1238 | if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
|
---|
1239 | SendMessageA( lphc->hWndLBox, LB_CARETOFF, 0, 0 );
|
---|
1240 |
|
---|
1241 | lphc->wState &= ~CBF_FOCUSED;
|
---|
1242 |
|
---|
1243 | /* redraw text */
|
---|
1244 | if( !(lphc->wState & CBF_EDIT) )
|
---|
1245 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
|
---|
1246 |
|
---|
1247 | CB_NOTIFY( lphc, CBN_KILLFOCUS );
|
---|
1248 | }
|
---|
1249 | }
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | /***********************************************************************
|
---|
1253 | * COMBO_KillFocus
|
---|
1254 | */
|
---|
1255 | static LRESULT COMBO_KillFocus(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1256 | {
|
---|
1257 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1258 |
|
---|
1259 | if(!wParam || (wParam != lphc->hWndEdit && wParam != lphc->hWndLBox ))
|
---|
1260 | {
|
---|
1261 | COMBO_EditKillFocus(lphc);
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | return 0;
|
---|
1265 | }
|
---|
1266 |
|
---|
1267 | /***********************************************************************
|
---|
1268 | * COMBO_Command
|
---|
1269 | */
|
---|
1270 | static LRESULT COMBO_Command(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1271 | {
|
---|
1272 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1273 |
|
---|
1274 | if ( lphc->wState & CBF_EDIT && lphc->hWndEdit == hwnd )
|
---|
1275 | {
|
---|
1276 | /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
|
---|
1277 |
|
---|
1278 | switch( HIWORD(wParam) >> 8 )
|
---|
1279 | {
|
---|
1280 | case (EN_SETFOCUS >> 8):
|
---|
1281 |
|
---|
1282 | //TRACE("[%04x]: edit [%04x] got focus\n",
|
---|
1283 | // CB_HWND(lphc), lphc->hWndEdit );
|
---|
1284 |
|
---|
1285 | COMBO_EditSetFocus(lphc);
|
---|
1286 | break;
|
---|
1287 |
|
---|
1288 | case (EN_KILLFOCUS >> 8):
|
---|
1289 |
|
---|
1290 | //TRACE("[%04x]: edit [%04x] lost focus\n",
|
---|
1291 | // CB_HWND(lphc), lphc->hWndEdit );
|
---|
1292 |
|
---|
1293 | /* NOTE: it seems that Windows' edit control sends an
|
---|
1294 | * undocumented message WM_USER + 0x1B instead of this
|
---|
1295 | * notification (only when it happens to be a part of
|
---|
1296 | * the combo). ?? - AK.
|
---|
1297 | */
|
---|
1298 |
|
---|
1299 | COMBO_EditKillFocus(lphc);
|
---|
1300 | break;
|
---|
1301 |
|
---|
1302 |
|
---|
1303 | case (EN_CHANGE >> 8):
|
---|
1304 | /*
|
---|
1305 | * In some circumstances (when the selection of the combobox
|
---|
1306 | * is changed for example) we don't wans the EN_CHANGE notification
|
---|
1307 | * to be forwarded to the parent of the combobox. This code
|
---|
1308 | * checks a flag that is set in these occasions and ignores the
|
---|
1309 | * notification.
|
---|
1310 | */
|
---|
1311 | if (lphc->wState & CBF_NOEDITNOTIFY)
|
---|
1312 | {
|
---|
1313 | lphc->wState &= ~CBF_NOEDITNOTIFY;
|
---|
1314 | }
|
---|
1315 | else
|
---|
1316 | {
|
---|
1317 | CB_NOTIFY( lphc, CBN_EDITCHANGE );
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | CBUpdateLBox( lphc );
|
---|
1321 | break;
|
---|
1322 |
|
---|
1323 | case (EN_UPDATE >> 8):
|
---|
1324 | CB_NOTIFY( lphc, CBN_EDITUPDATE );
|
---|
1325 | break;
|
---|
1326 |
|
---|
1327 | case (EN_ERRSPACE >> 8):
|
---|
1328 | CB_NOTIFY( lphc, CBN_ERRSPACE );
|
---|
1329 | }
|
---|
1330 | }
|
---|
1331 | else if( lphc->hWndLBox == hwnd )
|
---|
1332 | {
|
---|
1333 | switch( HIWORD(wParam) )
|
---|
1334 | {
|
---|
1335 | case LBN_ERRSPACE:
|
---|
1336 | CB_NOTIFY( lphc, CBN_ERRSPACE );
|
---|
1337 | break;
|
---|
1338 |
|
---|
1339 | case LBN_DBLCLK:
|
---|
1340 | CB_NOTIFY( lphc, CBN_DBLCLK );
|
---|
1341 | break;
|
---|
1342 |
|
---|
1343 | case LBN_SELCHANGE:
|
---|
1344 | case LBN_SELCANCEL:
|
---|
1345 |
|
---|
1346 | //TRACE("[%04x]: lbox selection change [%04x]\n",
|
---|
1347 | // CB_HWND(lphc), lphc->wState );
|
---|
1348 |
|
---|
1349 | /* do not roll up if selection is being tracked
|
---|
1350 | * by arrowkeys in the dropdown listbox */
|
---|
1351 |
|
---|
1352 | if( (lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP) )
|
---|
1353 | CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
|
---|
1354 | else lphc->wState &= ~CBF_NOROLLUP;
|
---|
1355 |
|
---|
1356 | if( lphc->wState & CBF_EDIT )
|
---|
1357 | {
|
---|
1358 | INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
|
---|
1359 | CBUpdateEdit( lphc, index );
|
---|
1360 | /* select text in edit, as Windows does */
|
---|
1361 | SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
|
---|
1362 | }
|
---|
1363 | else
|
---|
1364 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
|
---|
1365 |
|
---|
1366 | CB_NOTIFY( lphc, CBN_SELCHANGE );
|
---|
1367 | /* fall through */
|
---|
1368 |
|
---|
1369 | case LBN_SETFOCUS:
|
---|
1370 | case LBN_KILLFOCUS:
|
---|
1371 | /* nothing to do here since ComboLBox always resets the focus to its
|
---|
1372 | * combo/edit counterpart */
|
---|
1373 | break;
|
---|
1374 | }
|
---|
1375 | }
|
---|
1376 | return 0;
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | /***********************************************************************
|
---|
1380 | * COMBO_HandleItem
|
---|
1381 | *
|
---|
1382 | * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
|
---|
1383 | */
|
---|
1384 | static LRESULT COMBO_HandleItem(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
|
---|
1385 | {
|
---|
1386 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1387 |
|
---|
1388 | //TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
|
---|
1389 |
|
---|
1390 | #define lpIS ((LPDELETEITEMSTRUCT)lParam)
|
---|
1391 |
|
---|
1392 | /* two first items are the same in all 4 structs */
|
---|
1393 | lpIS->CtlType = ODT_COMBOBOX;
|
---|
1394 | lpIS->CtlID = GetWindowLongA(hwnd,GWL_ID);
|
---|
1395 |
|
---|
1396 | switch( msg ) /* patch window handle */
|
---|
1397 | {
|
---|
1398 | case WM_DELETEITEM:
|
---|
1399 | lpIS->hwndItem = hwnd;
|
---|
1400 | #undef lpIS
|
---|
1401 | break;
|
---|
1402 | case WM_DRAWITEM:
|
---|
1403 | #define lpIS ((LPDRAWITEMSTRUCT)lParam)
|
---|
1404 | lpIS->hwndItem = hwnd;
|
---|
1405 | #undef lpIS
|
---|
1406 | break;
|
---|
1407 | case WM_COMPAREITEM:
|
---|
1408 | #define lpIS ((LPCOMPAREITEMSTRUCT)lParam)
|
---|
1409 | lpIS->hwndItem = hwnd;
|
---|
1410 | #undef lpIS
|
---|
1411 | break;
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 | return SendMessageA( lphc->owner, msg, GetWindowLongA(hwnd,GWL_ID), lParam );
|
---|
1415 | }
|
---|
1416 |
|
---|
1417 | /***********************************************************************
|
---|
1418 | * COMBO_GetText
|
---|
1419 | */
|
---|
1420 | static LRESULT COMBO_GetText(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1421 | {
|
---|
1422 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1423 |
|
---|
1424 | if( lphc->wState & CBF_EDIT )
|
---|
1425 | return SendMessageA( lphc->hWndEdit, WM_GETTEXT,
|
---|
1426 | wParam,lParam);
|
---|
1427 |
|
---|
1428 | /* get it from the listbox */
|
---|
1429 |
|
---|
1430 | if( lphc->hWndLBox )
|
---|
1431 | {
|
---|
1432 | INT idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
|
---|
1433 | if( idx != LB_ERR )
|
---|
1434 | {
|
---|
1435 | LPSTR lpBuffer;
|
---|
1436 | INT length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN,
|
---|
1437 | (WPARAM)idx, 0 );
|
---|
1438 |
|
---|
1439 | /* 'length' is without the terminating character */
|
---|
1440 | if( length >= (UINT)wParam )
|
---|
1441 | lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 );
|
---|
1442 | else
|
---|
1443 | lpBuffer = (LPSTR)lParam;
|
---|
1444 |
|
---|
1445 | if( lpBuffer )
|
---|
1446 | {
|
---|
1447 | INT n = SendMessageA( lphc->hWndLBox, LB_GETTEXT,
|
---|
1448 | (WPARAM)idx, (LPARAM)lpBuffer );
|
---|
1449 |
|
---|
1450 | /* truncate if buffer is too short */
|
---|
1451 |
|
---|
1452 | if( length >= (UINT)wParam )
|
---|
1453 | {
|
---|
1454 | if ((UINT)wParam && lParam) {
|
---|
1455 | if( n != LB_ERR ) memcpy( (LPSTR)lParam, lpBuffer, ((UINT)wParam>n) ? n+1 : (UINT)wParam-1 );
|
---|
1456 | ((LPSTR)lParam)[(UINT)wParam - 1] = '\0';
|
---|
1457 | }
|
---|
1458 | HeapFree( GetProcessHeap(), 0, lpBuffer );
|
---|
1459 | }
|
---|
1460 | return (LRESULT)n;
|
---|
1461 | }
|
---|
1462 | }
|
---|
1463 | }
|
---|
1464 | return 0;
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 | static LRESULT COMBO_HandleText(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
|
---|
1468 | {
|
---|
1469 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1470 |
|
---|
1471 | if (lphc == NULL)
|
---|
1472 | {
|
---|
1473 | dprintf(("COMBO_HandleText Info Pointer NULL!\n"));
|
---|
1474 | return CB_ERR;
|
---|
1475 | }
|
---|
1476 |
|
---|
1477 | if ((message == WM_GETTEXTLENGTH) && !(lphc->wState & CBF_EDIT))
|
---|
1478 | {
|
---|
1479 | int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
|
---|
1480 |
|
---|
1481 | if (j == -1) return 0;
|
---|
1482 | return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
|
---|
1483 | } else if( lphc->wState & CBF_EDIT )
|
---|
1484 | {
|
---|
1485 | lphc->wState |= CBF_NOEDITNOTIFY;
|
---|
1486 |
|
---|
1487 | return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
|
---|
1488 | } else return CB_ERR;
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | /***********************************************************************
|
---|
1492 | * CBResetPos
|
---|
1493 | *
|
---|
1494 | * This function sets window positions according to the updated
|
---|
1495 | * component placement struct.
|
---|
1496 | */
|
---|
1497 | static void CBResetPos(
|
---|
1498 | LPHEADCOMBO lphc,
|
---|
1499 | LPRECT rectEdit,
|
---|
1500 | LPRECT rectLB,
|
---|
1501 | BOOL bRedraw)
|
---|
1502 | {
|
---|
1503 | BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
|
---|
1504 |
|
---|
1505 | /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
|
---|
1506 | * sizing messages */
|
---|
1507 |
|
---|
1508 | if( lphc->wState & CBF_EDIT )
|
---|
1509 | SetWindowPos( lphc->hWndEdit, 0,
|
---|
1510 | rectEdit->left, rectEdit->top,
|
---|
1511 | rectEdit->right - rectEdit->left,
|
---|
1512 | rectEdit->bottom - rectEdit->top,
|
---|
1513 | SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
|
---|
1514 |
|
---|
1515 | SetWindowPos( lphc->hWndLBox, 0,
|
---|
1516 | rectLB->left, rectLB->top,
|
---|
1517 | rectLB->right - rectLB->left,
|
---|
1518 | rectLB->bottom - rectLB->top,
|
---|
1519 | SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
|
---|
1520 |
|
---|
1521 | if( bDrop )
|
---|
1522 | {
|
---|
1523 | if( lphc->wState & CBF_DROPPED )
|
---|
1524 | {
|
---|
1525 | lphc->wState &= ~CBF_DROPPED;
|
---|
1526 | ShowWindow( lphc->hWndLBox, SW_HIDE );
|
---|
1527 | }
|
---|
1528 |
|
---|
1529 | if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
|
---|
1530 | RedrawWindow( lphc->hwndself, NULL, 0,
|
---|
1531 | RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
|
---|
1532 | }
|
---|
1533 | }
|
---|
1534 |
|
---|
1535 |
|
---|
1536 | /***********************************************************************
|
---|
1537 | * COMBO_Size
|
---|
1538 | */
|
---|
1539 | static LRESULT COMBO_Size(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1540 | {
|
---|
1541 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1542 |
|
---|
1543 | dprintf(("COMBO_Size"));
|
---|
1544 |
|
---|
1545 | if(lphc->hWndLBox && !(lphc->wState & CBF_NORESIZE))
|
---|
1546 | {
|
---|
1547 | CBCalcPlacement(hwnd,
|
---|
1548 | lphc,
|
---|
1549 | &lphc->textRect,
|
---|
1550 | &lphc->buttonRect,
|
---|
1551 | &lphc->droppedRect);
|
---|
1552 |
|
---|
1553 | CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
|
---|
1554 | }
|
---|
1555 |
|
---|
1556 | return 0;
|
---|
1557 | }
|
---|
1558 |
|
---|
1559 |
|
---|
1560 | /***********************************************************************
|
---|
1561 | * COMBO_Font
|
---|
1562 | */
|
---|
1563 | static LRESULT COMBO_SetFont(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1564 | {
|
---|
1565 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1566 |
|
---|
1567 | /*
|
---|
1568 | * Set the font
|
---|
1569 | */
|
---|
1570 | lphc->hFont = wParam;
|
---|
1571 |
|
---|
1572 | /*
|
---|
1573 | * Propagate to owned windows.
|
---|
1574 | */
|
---|
1575 | if( lphc->wState & CBF_EDIT )
|
---|
1576 | SendMessageA(lphc->hWndEdit,WM_SETFONT,wParam,lParam);
|
---|
1577 | SendMessageA(lphc->hWndLBox,WM_SETFONT,wParam,lParam);
|
---|
1578 |
|
---|
1579 | /*
|
---|
1580 | * Redo the layout of the control.
|
---|
1581 | */
|
---|
1582 | if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
|
---|
1583 | {
|
---|
1584 | CBCalcPlacement(hwnd,
|
---|
1585 | lphc,
|
---|
1586 | &lphc->textRect,
|
---|
1587 | &lphc->buttonRect,
|
---|
1588 | &lphc->droppedRect);
|
---|
1589 |
|
---|
1590 | CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
|
---|
1591 | }
|
---|
1592 | else
|
---|
1593 | {
|
---|
1594 | CBForceDummyResize(lphc);
|
---|
1595 | }
|
---|
1596 |
|
---|
1597 | return 0;
|
---|
1598 | }
|
---|
1599 |
|
---|
1600 | static LRESULT COMBO_GetFont(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1601 | {
|
---|
1602 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1603 |
|
---|
1604 | return lphc->hFont;
|
---|
1605 | }
|
---|
1606 |
|
---|
1607 |
|
---|
1608 | /***********************************************************************
|
---|
1609 | * COMBO_LButtonDown
|
---|
1610 | */
|
---|
1611 | static LRESULT COMBO_LButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1612 | {
|
---|
1613 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1614 | POINT pt;
|
---|
1615 | BOOL bButton;
|
---|
1616 |
|
---|
1617 | if(!(lphc->wState & CBF_FOCUSED)) SetFocus(hwnd);
|
---|
1618 | if(!(lphc->wState & CBF_FOCUSED)) return 0;
|
---|
1619 |
|
---|
1620 | pt.x = LOWORD(lParam);
|
---|
1621 | pt.y = HIWORD(lParam);
|
---|
1622 | bButton = PtInRect(&lphc->buttonRect, pt);
|
---|
1623 |
|
---|
1624 | if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
|
---|
1625 | (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
|
---|
1626 | {
|
---|
1627 | lphc->wState |= CBF_BUTTONDOWN;
|
---|
1628 | if( lphc->wState & CBF_DROPPED )
|
---|
1629 | {
|
---|
1630 | /* got a click to cancel selection */
|
---|
1631 |
|
---|
1632 | lphc->wState &= ~CBF_BUTTONDOWN;
|
---|
1633 | CBRollUp( lphc, TRUE, FALSE );
|
---|
1634 | if( !IsWindow( hwnd ) ) return 0;
|
---|
1635 |
|
---|
1636 | if( lphc->wState & CBF_CAPTURE )
|
---|
1637 | {
|
---|
1638 | lphc->wState &= ~CBF_CAPTURE;
|
---|
1639 | ReleaseCapture();
|
---|
1640 | }
|
---|
1641 | }
|
---|
1642 | else
|
---|
1643 | {
|
---|
1644 | /* drop down the listbox and start tracking */
|
---|
1645 |
|
---|
1646 | lphc->wState |= CBF_CAPTURE;
|
---|
1647 | CBDropDown( lphc );
|
---|
1648 | SetCapture( hwnd );
|
---|
1649 | }
|
---|
1650 | if( bButton ) CBRepaintButton( lphc );
|
---|
1651 | }
|
---|
1652 |
|
---|
1653 | return 0;
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 | /***********************************************************************
|
---|
1657 | * COMBO_LButtonUp
|
---|
1658 | *
|
---|
1659 | * Release capture and stop tracking if needed.
|
---|
1660 | */
|
---|
1661 | static LRESULT COMBO_LButtonUp(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1662 | {
|
---|
1663 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1664 |
|
---|
1665 | if( lphc->wState & CBF_CAPTURE )
|
---|
1666 | {
|
---|
1667 | lphc->wState &= ~CBF_CAPTURE;
|
---|
1668 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
|
---|
1669 | {
|
---|
1670 | INT index = CBUpdateLBox( lphc );
|
---|
1671 | CBUpdateEdit( lphc, index );
|
---|
1672 | }
|
---|
1673 | ReleaseCapture();
|
---|
1674 | //SvL: Don't set the capture here. Otherwise other controls don't respond the first time!
|
---|
1675 | // SetCapture(lphc->hWndLBox);
|
---|
1676 | }
|
---|
1677 |
|
---|
1678 | if( lphc->wState & CBF_BUTTONDOWN )
|
---|
1679 | {
|
---|
1680 | lphc->wState &= ~CBF_BUTTONDOWN;
|
---|
1681 | CBRepaintButton( lphc );
|
---|
1682 | }
|
---|
1683 |
|
---|
1684 | return 0;
|
---|
1685 | }
|
---|
1686 |
|
---|
1687 | /***********************************************************************
|
---|
1688 | * COMBO_MouseMove
|
---|
1689 | *
|
---|
1690 | * Two things to do - track combo button and release capture when
|
---|
1691 | * pointer goes into the listbox.
|
---|
1692 | */
|
---|
1693 | static LRESULT COMBO_MouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1694 | {
|
---|
1695 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1696 | POINT pt;
|
---|
1697 | RECT lbRect;
|
---|
1698 |
|
---|
1699 | if(!(lphc->wState & CBF_CAPTURE)) return 0;
|
---|
1700 |
|
---|
1701 | pt.x = LOWORD(lParam);
|
---|
1702 | pt.y = HIWORD(lParam);
|
---|
1703 |
|
---|
1704 | if( lphc->wState & CBF_BUTTONDOWN )
|
---|
1705 | {
|
---|
1706 | BOOL bButton;
|
---|
1707 |
|
---|
1708 | bButton = PtInRect(&lphc->buttonRect, pt);
|
---|
1709 |
|
---|
1710 | if( !bButton )
|
---|
1711 | {
|
---|
1712 | lphc->wState &= ~CBF_BUTTONDOWN;
|
---|
1713 | CBRepaintButton( lphc );
|
---|
1714 | }
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 | GetClientRect( lphc->hWndLBox, &lbRect );
|
---|
1718 | MapWindowPoints(hwnd, lphc->hWndLBox, &pt, 1 );
|
---|
1719 | if( PtInRect(&lbRect, pt) )
|
---|
1720 | {
|
---|
1721 | lphc->wState &= ~CBF_CAPTURE;
|
---|
1722 | ReleaseCapture();
|
---|
1723 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc );
|
---|
1724 |
|
---|
1725 | /* hand over pointer tracking */
|
---|
1726 | SendMessageA( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam );
|
---|
1727 | }
|
---|
1728 |
|
---|
1729 | return 0;
|
---|
1730 | }
|
---|
1731 |
|
---|
1732 | static LRESULT COMBO_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1733 | {
|
---|
1734 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1735 |
|
---|
1736 | if( lphc->wState & CBF_EDIT )
|
---|
1737 | EnableWindow( lphc->hWndEdit, (BOOL)wParam );
|
---|
1738 | EnableWindow( lphc->hWndLBox, (BOOL)wParam );
|
---|
1739 |
|
---|
1740 | /* Force the control to repaint when the enabled state changes. */
|
---|
1741 | InvalidateRect(CB_HWND(lphc), NULL, TRUE);
|
---|
1742 |
|
---|
1743 | return 0;
|
---|
1744 | }
|
---|
1745 |
|
---|
1746 | static LRESULT COMBO_SetRedraw(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1747 | {
|
---|
1748 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1749 |
|
---|
1750 | if( wParam )
|
---|
1751 | lphc->wState &= ~CBF_NOREDRAW;
|
---|
1752 | else
|
---|
1753 | lphc->wState |= CBF_NOREDRAW;
|
---|
1754 |
|
---|
1755 | if( lphc->wState & CBF_EDIT )
|
---|
1756 | SendMessageA( lphc->hWndEdit, WM_SETREDRAW, wParam, lParam );
|
---|
1757 | SendMessageA( lphc->hWndLBox, WM_SETREDRAW, wParam, lParam );
|
---|
1758 |
|
---|
1759 | return 0;
|
---|
1760 | }
|
---|
1761 |
|
---|
1762 | static LRESULT COMBO_SysKeyDown(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1763 | {
|
---|
1764 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1765 |
|
---|
1766 | if( KEYDATA_ALT & HIWORD(lParam) )
|
---|
1767 | if( wParam == VK_UP || wParam == VK_DOWN )
|
---|
1768 | COMBO_FlipListbox( lphc, TRUE );
|
---|
1769 |
|
---|
1770 | return DefWindowProcA(hwnd,WM_SYSKEYDOWN,wParam,lParam);
|
---|
1771 | }
|
---|
1772 |
|
---|
1773 | static LRESULT COMBO_HandleKey(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
|
---|
1774 | {
|
---|
1775 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1776 |
|
---|
1777 | if( lphc->wState & CBF_EDIT )
|
---|
1778 | return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
|
---|
1779 | else
|
---|
1780 | return SendMessageA( lphc->hWndLBox, message, wParam, lParam );
|
---|
1781 | }
|
---|
1782 |
|
---|
1783 | /* combobox messages */
|
---|
1784 |
|
---|
1785 | static LRESULT COMBO_AddString(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1786 | {
|
---|
1787 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1788 |
|
---|
1789 | return SendMessageA(lphc->hWndLBox,LB_ADDSTRING,0,lParam);
|
---|
1790 | }
|
---|
1791 |
|
---|
1792 | static LRESULT COMBO_InsertString(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1793 | {
|
---|
1794 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1795 |
|
---|
1796 | return SendMessageA(lphc->hWndLBox,LB_INSERTSTRING,wParam,lParam);
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 | static LRESULT COMBO_DeleteString(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1800 | {
|
---|
1801 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1802 |
|
---|
1803 | return SendMessageA(lphc->hWndLBox,LB_DELETESTRING,wParam,0);
|
---|
1804 | }
|
---|
1805 |
|
---|
1806 | /***********************************************************************
|
---|
1807 | * COMBO_SelectString
|
---|
1808 | */
|
---|
1809 | static LRESULT COMBO_SelectString(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1810 | {
|
---|
1811 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1812 | INT index = SendMessageA(lphc->hWndLBox,LB_SELECTSTRING,wParam,lParam);
|
---|
1813 |
|
---|
1814 | if( index >= 0 )
|
---|
1815 | {
|
---|
1816 | if( lphc->wState & CBF_EDIT )
|
---|
1817 | CBUpdateEdit( lphc, index );
|
---|
1818 | else
|
---|
1819 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
|
---|
1820 | }
|
---|
1821 |
|
---|
1822 | return (LRESULT)index;
|
---|
1823 | }
|
---|
1824 |
|
---|
1825 | static LRESULT COMBO_FindString(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1826 | {
|
---|
1827 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1828 |
|
---|
1829 | return SendMessageA(lphc->hWndLBox,LB_FINDSTRING,wParam,lParam);
|
---|
1830 | }
|
---|
1831 |
|
---|
1832 | static LRESULT COMBO_FindStringExact(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1833 | {
|
---|
1834 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1835 |
|
---|
1836 | return SendMessageA(lphc->hWndLBox,LB_FINDSTRINGEXACT,wParam,lParam);
|
---|
1837 | }
|
---|
1838 |
|
---|
1839 | /***********************************************************************
|
---|
1840 | * COMBO_SetItemHeight
|
---|
1841 | */
|
---|
1842 | static LRESULT COMBO_SetItemHeight(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1843 | {
|
---|
1844 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1845 | LRESULT lRet = CB_ERR;
|
---|
1846 |
|
---|
1847 | if( wParam == -1 ) /* set text field height */
|
---|
1848 | {
|
---|
1849 | if( lParam < 32768 )
|
---|
1850 | {
|
---|
1851 | lphc->editHeight = lParam;
|
---|
1852 |
|
---|
1853 | /*
|
---|
1854 | * Redo the layout of the control.
|
---|
1855 | */
|
---|
1856 | if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
|
---|
1857 | {
|
---|
1858 | CBCalcPlacement(hwnd,
|
---|
1859 | lphc,
|
---|
1860 | &lphc->textRect,
|
---|
1861 | &lphc->buttonRect,
|
---|
1862 | &lphc->droppedRect);
|
---|
1863 |
|
---|
1864 | CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
|
---|
1865 | }
|
---|
1866 | else
|
---|
1867 | {
|
---|
1868 | CBForceDummyResize(lphc);
|
---|
1869 | }
|
---|
1870 |
|
---|
1871 | lRet = lParam;
|
---|
1872 | }
|
---|
1873 | }
|
---|
1874 | else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
|
---|
1875 | lRet = SendMessageA( lphc->hWndLBox, LB_SETITEMHEIGHT,
|
---|
1876 | wParam,lParam);
|
---|
1877 | return lRet;
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 | static LRESULT COMBO_GetItemHeight(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1881 | {
|
---|
1882 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1883 |
|
---|
1884 | if( (INT)wParam >= 0 ) /* listbox item */
|
---|
1885 | return SendMessageA( lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0);
|
---|
1886 |
|
---|
1887 | return CBGetTextAreaHeight(hwnd, lphc);
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 | static LRESULT COMBO_ResetContent(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1891 | {
|
---|
1892 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1893 |
|
---|
1894 | SendMessageA( lphc->hWndLBox, LB_RESETCONTENT, 0, 0 );
|
---|
1895 | InvalidateRect(CB_HWND(lphc), NULL, TRUE);
|
---|
1896 |
|
---|
1897 | return TRUE;
|
---|
1898 | }
|
---|
1899 |
|
---|
1900 | static LRESULT COMBO_InitStorage(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1901 | {
|
---|
1902 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1903 |
|
---|
1904 | return SendMessageA( lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam);
|
---|
1905 | }
|
---|
1906 |
|
---|
1907 | static LRESULT COMBO_GetHorizontalExtent(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1908 | {
|
---|
1909 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1910 |
|
---|
1911 | return SendMessageA( lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0);
|
---|
1912 | }
|
---|
1913 |
|
---|
1914 | static LRESULT COMBO_SetHorizontalExtent(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1915 | {
|
---|
1916 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1917 |
|
---|
1918 | return SendMessageA( lphc->hWndLBox, LB_SETHORIZONTALEXTENT, wParam, 0);
|
---|
1919 | }
|
---|
1920 |
|
---|
1921 | static LRESULT COMBO_GetTopIndex(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1922 | {
|
---|
1923 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1924 |
|
---|
1925 | return SendMessageA( lphc->hWndLBox, LB_GETTOPINDEX, 0, 0);
|
---|
1926 | }
|
---|
1927 |
|
---|
1928 | static LRESULT COMBO_GetLocale(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1929 | {
|
---|
1930 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1931 |
|
---|
1932 | return SendMessageA( lphc->hWndLBox, LB_GETLOCALE, 0, 0);
|
---|
1933 | }
|
---|
1934 |
|
---|
1935 | static LRESULT COMBO_SetLocale(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1936 | {
|
---|
1937 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1938 |
|
---|
1939 | return SendMessageA( lphc->hWndLBox, LB_SETLOCALE, wParam, 0);
|
---|
1940 | }
|
---|
1941 |
|
---|
1942 | static LRESULT COMBO_GetDroppedWidth(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1943 | {
|
---|
1944 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1945 |
|
---|
1946 | if( lphc->droppedWidth )
|
---|
1947 | return lphc->droppedWidth;
|
---|
1948 |
|
---|
1949 | return lphc->droppedRect.right - lphc->droppedRect.left;
|
---|
1950 | }
|
---|
1951 |
|
---|
1952 | static LRESULT COMBO_SetDroppedWidth(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1953 | {
|
---|
1954 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1955 |
|
---|
1956 | if( (CB_GETTYPE(lphc) != CBS_SIMPLE) &&
|
---|
1957 | (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam;
|
---|
1958 |
|
---|
1959 | return CB_ERR;
|
---|
1960 | }
|
---|
1961 |
|
---|
1962 | static LRESULT COMBO_GetDroppedControlRect(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1963 | {
|
---|
1964 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1965 |
|
---|
1966 | if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam );
|
---|
1967 |
|
---|
1968 | return CB_OKAY;
|
---|
1969 | }
|
---|
1970 |
|
---|
1971 | static LRESULT COMBO_GetDroppedState(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1972 | {
|
---|
1973 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1974 |
|
---|
1975 | return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE;
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | static LRESULT COMBO_Dir(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1979 | {
|
---|
1980 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1981 |
|
---|
1982 | return COMBO_Directory( lphc, (UINT)wParam,
|
---|
1983 | (LPSTR)lParam,TRUE);
|
---|
1984 | }
|
---|
1985 |
|
---|
1986 | static LRESULT COMBO_ShowDropDown(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
1987 | {
|
---|
1988 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
1989 |
|
---|
1990 | if( CB_GETTYPE(lphc) != CBS_SIMPLE )
|
---|
1991 | {
|
---|
1992 | if( wParam )
|
---|
1993 | {
|
---|
1994 | if( !(lphc->wState & CBF_DROPPED) )
|
---|
1995 | CBDropDown( lphc );
|
---|
1996 | }
|
---|
1997 | else
|
---|
1998 | if( lphc->wState & CBF_DROPPED )
|
---|
1999 | CBRollUp( lphc, FALSE, TRUE );
|
---|
2000 | }
|
---|
2001 |
|
---|
2002 | return TRUE;
|
---|
2003 | }
|
---|
2004 |
|
---|
2005 | static LRESULT COMBO_GetCount(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2006 | {
|
---|
2007 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2008 |
|
---|
2009 | return SendMessageA( lphc->hWndLBox, LB_GETCOUNT, 0, 0);
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | static LRESULT COMBO_GetCurSel(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2013 | {
|
---|
2014 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2015 |
|
---|
2016 | return SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0);
|
---|
2017 | }
|
---|
2018 |
|
---|
2019 | static LRESULT COMBO_SetCurSel(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2020 | {
|
---|
2021 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2022 |
|
---|
2023 | lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0);
|
---|
2024 | if( lphc->wState & CBF_SELCHANGE )
|
---|
2025 | {
|
---|
2026 | /* no LBN_SELCHANGE in this case, update manually */
|
---|
2027 | if( lphc->wState & CBF_EDIT )
|
---|
2028 | CBUpdateEdit( lphc, (INT)wParam );
|
---|
2029 | else
|
---|
2030 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
|
---|
2031 |
|
---|
2032 | lphc->wState &= ~CBF_SELCHANGE;
|
---|
2033 | }
|
---|
2034 |
|
---|
2035 | return lParam;
|
---|
2036 | }
|
---|
2037 |
|
---|
2038 | static LRESULT COMBO_GetLBText(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2039 | {
|
---|
2040 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2041 |
|
---|
2042 | return SendMessageA( lphc->hWndLBox, LB_GETTEXT, wParam, lParam);
|
---|
2043 | }
|
---|
2044 |
|
---|
2045 | static LRESULT COMBO_GetLBTextLen(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2046 | {
|
---|
2047 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2048 |
|
---|
2049 | return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
|
---|
2050 | }
|
---|
2051 |
|
---|
2052 | static LRESULT COMBO_GetItemData(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2053 | {
|
---|
2054 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2055 |
|
---|
2056 | return SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, wParam, 0);
|
---|
2057 | }
|
---|
2058 |
|
---|
2059 | static LRESULT COMBO_SetItemData(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2060 | {
|
---|
2061 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2062 |
|
---|
2063 | return SendMessageA( lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam);
|
---|
2064 | }
|
---|
2065 |
|
---|
2066 | static LRESULT COMBO_GetEditSel(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2067 | {
|
---|
2068 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2069 |
|
---|
2070 | if( lphc->wState & CBF_EDIT )
|
---|
2071 | {
|
---|
2072 | INT a, b;
|
---|
2073 |
|
---|
2074 | return SendMessageA( lphc->hWndEdit, EM_GETSEL,
|
---|
2075 | (wParam) ? wParam : (WPARAM)&a,
|
---|
2076 | (lParam) ? lParam : (LPARAM)&b );
|
---|
2077 | }
|
---|
2078 |
|
---|
2079 | return CB_ERR;
|
---|
2080 | }
|
---|
2081 |
|
---|
2082 | static LRESULT COMBO_SetEditSel(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2083 | {
|
---|
2084 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2085 |
|
---|
2086 | if( lphc->wState & CBF_EDIT )
|
---|
2087 | return SendMessageA( lphc->hWndEdit, EM_SETSEL,
|
---|
2088 | (INT)(INT16)LOWORD(lParam), (INT)(INT16)HIWORD(lParam) );
|
---|
2089 |
|
---|
2090 | return CB_ERR;
|
---|
2091 | }
|
---|
2092 |
|
---|
2093 | static LRESULT COMBO_SetExtendedUI(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2094 | {
|
---|
2095 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2096 |
|
---|
2097 | if( CB_GETTYPE(lphc) == CBS_SIMPLE )
|
---|
2098 | return CB_ERR;
|
---|
2099 | if( wParam )
|
---|
2100 | lphc->wState |= CBF_EUI;
|
---|
2101 | else lphc->wState &= ~CBF_EUI;
|
---|
2102 | return CB_OKAY;
|
---|
2103 | }
|
---|
2104 |
|
---|
2105 | static LRESULT COMBO_GetExtendedUI(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
2106 | {
|
---|
2107 | LPHEADCOMBO lphc = (LPHEADCOMBO)GetInfoPtr(hwnd);
|
---|
2108 |
|
---|
2109 | return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
|
---|
2110 | }
|
---|
2111 |
|
---|
2112 | /***********************************************************************
|
---|
2113 | * ComboWndProc
|
---|
2114 | *
|
---|
2115 | * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
|
---|
2116 | */
|
---|
2117 | LRESULT WINAPI ComboWndProc( HWND hwnd, UINT message,
|
---|
2118 | WPARAM wParam, LPARAM lParam )
|
---|
2119 | {
|
---|
2120 | // dprintf(("ComboWndProc hwnd: %04x, msg %s, wp %08x lp %08lx\n",
|
---|
2121 | // hwnd, GetMsgText(message), wParam, lParam));
|
---|
2122 |
|
---|
2123 | switch(message)
|
---|
2124 | {
|
---|
2125 |
|
---|
2126 | /* System messages */
|
---|
2127 |
|
---|
2128 | case WM_NCCREATE:
|
---|
2129 | return COMBO_NCCreate(hwnd,wParam,lParam);
|
---|
2130 |
|
---|
2131 | case WM_NCDESTROY:
|
---|
2132 | return COMBO_NCDestroy(hwnd,wParam,lParam);
|
---|
2133 |
|
---|
2134 | case WM_CREATE:
|
---|
2135 | return COMBO_Create(hwnd,wParam,lParam);
|
---|
2136 |
|
---|
2137 | case WM_PRINTCLIENT:
|
---|
2138 | return COMBO_PrintClient(hwnd,wParam,lParam);
|
---|
2139 |
|
---|
2140 | case WM_PAINT:
|
---|
2141 | return COMBO_Paint(hwnd,wParam,lParam);
|
---|
2142 |
|
---|
2143 | case WM_ERASEBKGND:
|
---|
2144 | return COMBO_EraseBackground(hwnd,wParam,lParam);
|
---|
2145 |
|
---|
2146 | case WM_GETDLGCODE:
|
---|
2147 | return COMBO_GetDlgCode(hwnd,wParam,lParam);
|
---|
2148 |
|
---|
2149 | case WM_WINDOWPOSCHANGING:
|
---|
2150 | return COMBO_WindowPosChanging(hwnd,wParam,lParam);
|
---|
2151 |
|
---|
2152 | case WM_SIZE:
|
---|
2153 | return COMBO_Size(hwnd,wParam,lParam);
|
---|
2154 |
|
---|
2155 | case WM_SETFONT:
|
---|
2156 | return COMBO_SetFont(hwnd,wParam,lParam);
|
---|
2157 |
|
---|
2158 | case WM_GETFONT:
|
---|
2159 | return COMBO_GetFont(hwnd,wParam,lParam);
|
---|
2160 |
|
---|
2161 | case WM_SETFOCUS:
|
---|
2162 | return COMBO_SetFocus(hwnd,wParam,lParam);
|
---|
2163 |
|
---|
2164 | case WM_KILLFOCUS:
|
---|
2165 | return COMBO_KillFocus(hwnd,wParam,lParam);
|
---|
2166 |
|
---|
2167 | case WM_COMMAND:
|
---|
2168 | return COMBO_Command(hwnd,wParam,lParam);
|
---|
2169 |
|
---|
2170 | case WM_GETTEXT:
|
---|
2171 | return COMBO_GetText(hwnd,wParam,lParam);
|
---|
2172 |
|
---|
2173 | case WM_SETTEXT:
|
---|
2174 | case WM_GETTEXTLENGTH:
|
---|
2175 | case WM_CLEAR:
|
---|
2176 | case WM_CUT:
|
---|
2177 | case WM_PASTE:
|
---|
2178 | case WM_COPY:
|
---|
2179 | return COMBO_HandleText(hwnd,message,wParam,lParam);
|
---|
2180 |
|
---|
2181 | case WM_DRAWITEM:
|
---|
2182 | case WM_DELETEITEM:
|
---|
2183 | case WM_COMPAREITEM:
|
---|
2184 | case WM_MEASUREITEM:
|
---|
2185 | return COMBO_HandleItem(hwnd,message,wParam,lParam);
|
---|
2186 |
|
---|
2187 | case WM_ENABLE:
|
---|
2188 | return COMBO_Enable(hwnd,wParam,lParam);
|
---|
2189 |
|
---|
2190 | case WM_SETREDRAW:
|
---|
2191 | return COMBO_SetRedraw(hwnd,wParam,lParam);
|
---|
2192 |
|
---|
2193 | case WM_SYSKEYDOWN:
|
---|
2194 | return COMBO_SysKeyDown(hwnd,wParam,lParam);
|
---|
2195 |
|
---|
2196 | case WM_CHAR:
|
---|
2197 | case WM_KEYDOWN:
|
---|
2198 | return COMBO_HandleKey(hwnd,message,wParam,lParam);
|
---|
2199 |
|
---|
2200 | case WM_LBUTTONDOWN:
|
---|
2201 | return COMBO_LButtonDown(hwnd,wParam,lParam);
|
---|
2202 |
|
---|
2203 | case WM_LBUTTONUP:
|
---|
2204 | return COMBO_LButtonUp(hwnd,wParam,lParam);
|
---|
2205 |
|
---|
2206 | case WM_MOUSEMOVE:
|
---|
2207 | return COMBO_MouseMove(hwnd,wParam,lParam);
|
---|
2208 |
|
---|
2209 | /* Combo messages */
|
---|
2210 |
|
---|
2211 | case CB_ADDSTRING:
|
---|
2212 | return COMBO_AddString(hwnd,wParam,lParam);
|
---|
2213 |
|
---|
2214 | case CB_INSERTSTRING:
|
---|
2215 | return COMBO_InsertString(hwnd,wParam,lParam);
|
---|
2216 |
|
---|
2217 | case CB_DELETESTRING:
|
---|
2218 | return COMBO_DeleteString(hwnd,wParam,lParam);
|
---|
2219 |
|
---|
2220 | case CB_SELECTSTRING:
|
---|
2221 | return COMBO_SelectString(hwnd,wParam,lParam);
|
---|
2222 |
|
---|
2223 | case CB_FINDSTRING:
|
---|
2224 | return COMBO_FindString(hwnd,wParam,lParam);
|
---|
2225 |
|
---|
2226 | case CB_FINDSTRINGEXACT:
|
---|
2227 | return COMBO_FindStringExact(hwnd,wParam,lParam);
|
---|
2228 |
|
---|
2229 | case CB_SETITEMHEIGHT:
|
---|
2230 | return COMBO_SetItemHeight(hwnd,wParam,lParam);
|
---|
2231 |
|
---|
2232 | case CB_GETITEMHEIGHT:
|
---|
2233 | return COMBO_GetItemHeight(hwnd,wParam,lParam);
|
---|
2234 |
|
---|
2235 | case CB_RESETCONTENT:
|
---|
2236 | return COMBO_ResetContent(hwnd,wParam,lParam);
|
---|
2237 |
|
---|
2238 | case CB_INITSTORAGE:
|
---|
2239 | return COMBO_InitStorage(hwnd,wParam,lParam);
|
---|
2240 |
|
---|
2241 | case CB_GETHORIZONTALEXTENT:
|
---|
2242 | return COMBO_GetHorizontalExtent(hwnd,wParam,lParam);
|
---|
2243 |
|
---|
2244 | case CB_SETHORIZONTALEXTENT:
|
---|
2245 | return COMBO_SetHorizontalExtent(hwnd,wParam,lParam);
|
---|
2246 |
|
---|
2247 | case CB_GETTOPINDEX:
|
---|
2248 | return COMBO_GetTopIndex(hwnd,wParam,lParam);
|
---|
2249 |
|
---|
2250 | case CB_GETLOCALE:
|
---|
2251 | return COMBO_GetLocale(hwnd,wParam,lParam);
|
---|
2252 |
|
---|
2253 | case CB_SETLOCALE:
|
---|
2254 | return COMBO_SetLocale(hwnd,wParam,lParam);
|
---|
2255 |
|
---|
2256 | case CB_GETDROPPEDWIDTH:
|
---|
2257 | return COMBO_GetDroppedWidth(hwnd,wParam,lParam);
|
---|
2258 |
|
---|
2259 | case CB_SETDROPPEDWIDTH:
|
---|
2260 | return COMBO_SetDroppedWidth(hwnd,wParam,lParam);
|
---|
2261 |
|
---|
2262 | case CB_GETDROPPEDCONTROLRECT:
|
---|
2263 | return COMBO_GetDroppedControlRect(hwnd,wParam,lParam);
|
---|
2264 |
|
---|
2265 | case CB_GETDROPPEDSTATE:
|
---|
2266 | return COMBO_GetDroppedState(hwnd,wParam,lParam);
|
---|
2267 |
|
---|
2268 | case CB_DIR:
|
---|
2269 | return COMBO_Dir(hwnd,wParam,lParam);
|
---|
2270 |
|
---|
2271 | case CB_SHOWDROPDOWN:
|
---|
2272 | return COMBO_ShowDropDown(hwnd,wParam,lParam);
|
---|
2273 |
|
---|
2274 | case CB_GETCOUNT:
|
---|
2275 | return COMBO_GetCount(hwnd,wParam,lParam);
|
---|
2276 |
|
---|
2277 | case CB_GETCURSEL:
|
---|
2278 | return COMBO_GetCurSel(hwnd,wParam,lParam);
|
---|
2279 |
|
---|
2280 | case CB_SETCURSEL:
|
---|
2281 | return COMBO_SetCurSel(hwnd,wParam,lParam);
|
---|
2282 |
|
---|
2283 | case CB_GETLBTEXT:
|
---|
2284 | return COMBO_GetLBText(hwnd,wParam,lParam);
|
---|
2285 |
|
---|
2286 | case CB_GETLBTEXTLEN:
|
---|
2287 | return COMBO_GetLBTextLen(hwnd,wParam,lParam);
|
---|
2288 |
|
---|
2289 | case CB_GETITEMDATA:
|
---|
2290 | return COMBO_GetItemData(hwnd,wParam,lParam);
|
---|
2291 |
|
---|
2292 | case CB_SETITEMDATA:
|
---|
2293 | return COMBO_SetItemData(hwnd,wParam,lParam);
|
---|
2294 |
|
---|
2295 | case CB_GETEDITSEL:
|
---|
2296 | return COMBO_GetEditSel(hwnd,wParam,lParam);
|
---|
2297 |
|
---|
2298 | case CB_SETEDITSEL:
|
---|
2299 | return COMBO_SetEditSel(hwnd,wParam,lParam);
|
---|
2300 |
|
---|
2301 | case CB_SETEXTENDEDUI:
|
---|
2302 | return COMBO_SetExtendedUI(hwnd,wParam,lParam);
|
---|
2303 |
|
---|
2304 | case CB_GETEXTENDEDUI:
|
---|
2305 | return COMBO_GetExtendedUI(hwnd,wParam,lParam);
|
---|
2306 |
|
---|
2307 | //case (WM_USER + 0x1B):
|
---|
2308 | // WARN("[%04x]: undocumented msg!\n", hwnd );
|
---|
2309 | }
|
---|
2310 | return DefWindowProcA(hwnd, message, wParam, lParam);
|
---|
2311 | }
|
---|
2312 |
|
---|
2313 | BOOL COMBOBOX_Register()
|
---|
2314 | {
|
---|
2315 | WNDCLASSA wndClass;
|
---|
2316 |
|
---|
2317 | //SvL: Don't check this now
|
---|
2318 | // if (GlobalFindAtomA(COMBOBOXCLASSNAME)) return FALSE;
|
---|
2319 |
|
---|
2320 | ZeroMemory(&wndClass,sizeof(WNDCLASSA));
|
---|
2321 | wndClass.style = CS_GLOBALCLASS | CS_PARENTDC;
|
---|
2322 | wndClass.lpfnWndProc = (WNDPROC)ComboWndProc;
|
---|
2323 | wndClass.cbClsExtra = 0;
|
---|
2324 | wndClass.cbWndExtra = sizeof(VOID*);
|
---|
2325 | wndClass.hCursor = LoadCursorA(0,IDC_ARROWA);
|
---|
2326 | wndClass.hbrBackground = (HBRUSH)0;
|
---|
2327 | wndClass.lpszClassName = COMBOBOXCLASSNAME;
|
---|
2328 |
|
---|
2329 | return RegisterClassA(&wndClass);
|
---|
2330 | }
|
---|
2331 |
|
---|
2332 | BOOL COMBOBOX_Unregister()
|
---|
2333 | {
|
---|
2334 | if (GlobalFindAtomA(COMBOBOXCLASSNAME))
|
---|
2335 | return UnregisterClassA(COMBOBOXCLASSNAME,(HINSTANCE)NULL);
|
---|
2336 | else return FALSE;
|
---|
2337 | }
|
---|
2338 |
|
---|