1 |
673 |
markom |
/*--------------------------------------------------------------------------
|
2 |
|
|
** ComboBox.c Twin From: Twin/controls
|
3 |
|
|
**
|
4 |
|
|
**
|
5 |
|
|
**------------------------- < License Information > ------------------------
|
6 |
|
|
**
|
7 |
|
|
** This file was originally a part of Willows TWIN. Willows
|
8 |
|
|
** TWIN was released under a Library GPL (LGPL). This permits
|
9 |
|
|
** redistribution of this source code, provided that the full
|
10 |
|
|
** TWIN license is in effect, and provided that all modifications
|
11 |
|
|
** to this source code are made publicly available.
|
12 |
|
|
** Please refer to Willows software (www.willows.com) or
|
13 |
|
|
** LICENSE for full information.
|
14 |
|
|
**
|
15 |
|
|
** Under Twine, this file is also protected by an LGPL. Please
|
16 |
|
|
** see LICENSE for full details on this license.
|
17 |
|
|
**
|
18 |
|
|
**
|
19 |
|
|
** Copyright 1997 Willows Software, Inc.
|
20 |
|
|
**------------------------ < File Content Description > --------------------
|
21 |
|
|
**
|
22 |
|
|
** Module: controls/ComboBox.c
|
23 |
|
|
**
|
24 |
|
|
** Description:
|
25 |
|
|
**
|
26 |
|
|
**
|
27 |
|
|
** Functions defined:
|
28 |
|
|
**
|
29 |
|
|
**------------------------- < Revision Information > -----------------------
|
30 |
|
|
**
|
31 |
|
|
** Full Revision history at bottom of file
|
32 |
|
|
**
|
33 |
|
|
**--------------------------------------------------------------------------*/
|
34 |
|
|
#include <stdio.h>
|
35 |
|
|
#include <stdlib.h>
|
36 |
|
|
#include <string.h>
|
37 |
|
|
#include "windows.h"
|
38 |
|
|
#include "windowsx.h"
|
39 |
|
|
|
40 |
|
|
#define WinMalloc(n) malloc((n))
|
41 |
|
|
#define WinFree(p) free(p)
|
42 |
|
|
|
43 |
|
|
#define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
|
44 |
|
|
#define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
|
45 |
|
|
#define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
|
46 |
|
|
#define GET_WM_COMMAND_MPS(id, hwnd, cmd) \
|
47 |
|
|
(WPARAM)MAKELONG(id, cmd), (LONG)(hwnd)
|
48 |
|
|
#define LOSHORT(x) (short int)LOWORD(x)
|
49 |
|
|
#define Edit_SetSel(hwndCtl, ichStart, ichEnd) ((void)SendMessage((hwndCtl), EM_SETSEL, (ichStart), (ichEnd)))
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
typedef struct {
|
53 |
|
|
HFONT hFont; /* hFont used */
|
54 |
|
|
HWND hWndParent; /* parent window */
|
55 |
|
|
UINT nID; /* control ID */
|
56 |
|
|
WORD wStateFlags; /* combobox state flags */
|
57 |
|
|
UINT wStyle; /* this is a copy of LOWORD(style) */
|
58 |
|
|
BOOL bExtended; /* extended UI flag */
|
59 |
|
|
BOOL bRedraw; /* MiD - redraw flag, draw only if it's 1 */
|
60 |
|
|
HWND EditControl; /* edit/static control hWnd */
|
61 |
|
|
HWND ListBoxControl; /* listbox control hWnd */
|
62 |
|
|
RECT ButtonRect; /* local button rect (client) */
|
63 |
|
|
RECT ListBoxRect; /* listbox rect (screen) */
|
64 |
|
|
UINT uHeight; /* height of the normal state */
|
65 |
|
|
WNDPROC lpfnOldStatic; /* previous static wndproc */
|
66 |
|
|
UINT nListItems; /* ecw */
|
67 |
|
|
} COMBOBOX;
|
68 |
|
|
|
69 |
|
|
#define CWD_LPCBDATA 0
|
70 |
|
|
#define CBC_EDITID 1
|
71 |
|
|
|
72 |
|
|
#define CSF_CAPTUREACTIVE 0x0001
|
73 |
|
|
#define CSF_LOCALBUTTONDOWN 0x0002
|
74 |
|
|
#define CSF_BUTTONDOWN 0x0004
|
75 |
|
|
#define CSF_LBOXBUTTONDOWN 0x0008
|
76 |
|
|
#define CSF_FOCUS 0x0010 /* MiD */
|
77 |
|
|
#define CSF_HASDROPPED 0x0020 /* weav */
|
78 |
|
|
|
79 |
|
|
#define SET_STATE(lp, wMask) (lp->wStateFlags |= (wMask))
|
80 |
|
|
#define CLEAR_STATE(lp, wMask) (lp->wStateFlags &= ~(wMask))
|
81 |
|
|
#define IS_SET(lp, wMask) (lp->wStateFlags & (wMask))
|
82 |
|
|
|
83 |
|
|
#define BOWNERDRAW(l) ((l)->wStyle & (CBS_OWNERDRAWFIXED|CBS_OWNERDRAWVARIABLE))
|
84 |
|
|
|
85 |
|
|
/**********************************************
|
86 |
|
|
Styles:
|
87 |
|
|
|
88 |
|
|
CBS_AUTOHSCROLL passed to the edit control
|
89 |
|
|
CBS_DISABLENOSCROLL passed to the listbox control
|
90 |
|
|
CBS_DROPDOWN
|
91 |
|
|
CBS_DROPDOWNLIST
|
92 |
|
|
CBS_HASSTRINGS passed to the listbox control
|
93 |
|
|
CBS_NOINTEGRALHEIGHT passed to the listbox control
|
94 |
|
|
CBS_OEMCONVERT passed to the edit control
|
95 |
|
|
CBS_OWNERDRAWFIXED passed to the listbox control
|
96 |
|
|
CBS_OWNERDRAWVARIABLE passed to the listbox control
|
97 |
|
|
CBS_SIMPLE TODO
|
98 |
|
|
CBS_SORT passed to the listbox control
|
99 |
|
|
|
100 |
|
|
WS_VSCROLL passed to the listbox control
|
101 |
|
|
|
102 |
|
|
*********************************************/
|
103 |
|
|
|
104 |
|
|
/**********************************************
|
105 |
|
|
CBN_xxx messages to be added
|
106 |
|
|
|
107 |
|
|
from mouse tracking...
|
108 |
|
|
CBN_SELENDCANCEL TODO
|
109 |
|
|
CBN_SELENDOK TODO
|
110 |
|
|
|
111 |
|
|
*********************************************/
|
112 |
|
|
|
113 |
|
|
/* imported stuff */
|
114 |
|
|
#if 1
|
115 |
|
|
void
|
116 |
|
|
Draw3DButtonRect(HDC hDC, HPEN hPenHigh, HPEN hPenShadow,
|
117 |
|
|
RECT rc, BOOL fClicked)
|
118 |
|
|
{
|
119 |
|
|
HPEN hPenOld;
|
120 |
|
|
POINT lpt[6];
|
121 |
|
|
|
122 |
|
|
POINT p3[3];
|
123 |
|
|
int shrink=1;
|
124 |
|
|
|
125 |
|
|
hPenOld = SelectObject(hDC, hPenShadow);
|
126 |
|
|
if (fClicked) {
|
127 |
|
|
lpt[0].x = lpt[1].x = rc.left;
|
128 |
|
|
lpt[1].y = lpt[2].y = rc.top;
|
129 |
|
|
lpt[2].x = rc.right-1;
|
130 |
|
|
lpt[0].y = rc.bottom-1;
|
131 |
|
|
Polyline(hDC,lpt,3);
|
132 |
|
|
}
|
133 |
|
|
else {
|
134 |
|
|
lpt[0].x = lpt[1].x = rc.right-1;
|
135 |
|
|
lpt[0].y = rc.top;
|
136 |
|
|
lpt[1].y = lpt[2].y = rc.bottom-1;
|
137 |
|
|
lpt[2].x = rc.left;
|
138 |
|
|
lpt[3].x = rc.left+1;
|
139 |
|
|
lpt[3].y = lpt[4].y = rc.bottom-2;
|
140 |
|
|
lpt[4].x = lpt[5].x = rc.right-2;
|
141 |
|
|
lpt[5].y = rc.top+1;
|
142 |
|
|
Polyline(hDC,lpt,6);
|
143 |
|
|
|
144 |
|
|
SelectObject(hDC, hPenHigh);
|
145 |
|
|
lpt[0].x = rc.right-1;
|
146 |
|
|
lpt[0].y = lpt[1].y = rc.top;
|
147 |
|
|
lpt[1].x = lpt[2].x = rc.left;
|
148 |
|
|
lpt[2].y = rc.bottom-1;
|
149 |
|
|
lpt[3].x = lpt[4].x = rc.left+1;
|
150 |
|
|
lpt[3].y = rc.bottom-2;
|
151 |
|
|
lpt[4].y = lpt[5].y = rc.top+1;
|
152 |
|
|
lpt[5].x = rc.right-2;
|
153 |
|
|
Polyline(hDC,lpt,6);
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
SelectObject(hDC,GetStockObject(BLACK_BRUSH));
|
157 |
|
|
/* down */
|
158 |
|
|
p3[0].x= rc.left + ((rc.right-rc.left)/2) - 1;
|
159 |
|
|
p3[0].y= rc.bottom - 4 - shrink;
|
160 |
|
|
p3[1].x= rc.left + 2 + shrink - 1;
|
161 |
|
|
p3[1].y= rc.bottom-(rc.bottom-rc.top) + 2 + shrink;
|
162 |
|
|
p3[2].x= rc.left + ((rc.right-rc.left)-4) - shrink;
|
163 |
|
|
p3[2].y= rc.bottom-(rc.bottom-rc.top) + 2 + shrink;
|
164 |
|
|
Polygon(hDC,p3,3);
|
165 |
|
|
|
166 |
|
|
SelectObject(hDC,hPenOld);
|
167 |
|
|
}
|
168 |
|
|
#endif
|
169 |
|
|
|
170 |
|
|
#if 0 /* jmt: fix: no COMBOLBOX */
|
171 |
|
|
extern LRESULT DefLISTBOXProc(HWND, UINT, WPARAM, LPARAM);
|
172 |
|
|
extern LRESULT ListboxCtrlProc(HWND, UINT, WPARAM, LPARAM);
|
173 |
|
|
#endif
|
174 |
|
|
|
175 |
|
|
#if 0
|
176 |
|
|
static HPEN GetSysColorPen(int color)
|
177 |
|
|
{
|
178 |
|
|
return NULL;
|
179 |
|
|
}
|
180 |
|
|
static HBRUSH GetSysColorBrush(int color)
|
181 |
|
|
{
|
182 |
|
|
return NULL;
|
183 |
|
|
}
|
184 |
|
|
#endif
|
185 |
|
|
|
186 |
|
|
typedef HWND HWND32;
|
187 |
|
|
|
188 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
189 |
|
|
typedef HANDLE HCLASS32;
|
190 |
|
|
static HCLASS32 FindClass(LPCSTR str, HINSTANCE hInstance)
|
191 |
|
|
{
|
192 |
|
|
return NULL;
|
193 |
|
|
}
|
194 |
|
|
#endif
|
195 |
|
|
|
196 |
|
|
#if 0 /* jmt: fix: no scrollbar */
|
197 |
|
|
static HWND TWIN_ConvertToSysScroll(HWND hwnd, BOOL status, LPPOINT pp)
|
198 |
|
|
{
|
199 |
|
|
return NULL;
|
200 |
|
|
}
|
201 |
|
|
#endif
|
202 |
|
|
extern HWND listwp;
|
203 |
|
|
static HWND WindowFromPoint(POINT pt)
|
204 |
|
|
{
|
205 |
|
|
HWND wp,wp1;
|
206 |
|
|
int dx,dy,dx1,dy1;
|
207 |
|
|
#if 0
|
208 |
|
|
return NULL; /* fix!! */
|
209 |
|
|
#else
|
210 |
|
|
wp1=NULL;
|
211 |
|
|
switch(sizeof(dx))
|
212 |
|
|
{
|
213 |
|
|
case 4:
|
214 |
|
|
dx=0x7fffffff;
|
215 |
|
|
dy=0x7fffffff;
|
216 |
|
|
break;
|
217 |
|
|
case 2:
|
218 |
|
|
dx=0x7fff;
|
219 |
|
|
dy=0x7fff;
|
220 |
|
|
break;
|
221 |
|
|
}
|
222 |
|
|
for(wp=listwp; wp; wp=wp->next)
|
223 |
|
|
{
|
224 |
|
|
if (wp->winrect.left <= pt.x && pt.x <= wp->winrect.right)
|
225 |
|
|
{
|
226 |
|
|
dx1=(wp->winrect.right-pt.x);
|
227 |
|
|
if (dx1<dx)
|
228 |
|
|
{
|
229 |
|
|
wp1=wp;
|
230 |
|
|
dx=dx1;
|
231 |
|
|
}
|
232 |
|
|
dx1=(pt.x-wp->winrect.left);
|
233 |
|
|
if (dx1<dx)
|
234 |
|
|
{
|
235 |
|
|
wp1=wp;
|
236 |
|
|
dx=dx1;
|
237 |
|
|
}
|
238 |
|
|
}
|
239 |
|
|
if (wp->winrect.top <= pt.y && pt.y <= wp->winrect.bottom)
|
240 |
|
|
{
|
241 |
|
|
dy1=(wp->winrect.bottom-pt.y);
|
242 |
|
|
if (dy1<dy)
|
243 |
|
|
{
|
244 |
|
|
wp1=wp;
|
245 |
|
|
dy=dy1;
|
246 |
|
|
}
|
247 |
|
|
dy1=(pt.y-wp->winrect.top);
|
248 |
|
|
if (dy1<dy)
|
249 |
|
|
{
|
250 |
|
|
wp1=wp;
|
251 |
|
|
dy=dy1;
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
#endif
|
256 |
|
|
return wp1;
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
/* internal stuff */
|
260 |
|
|
static void CBoxDrawButton(HWND,UINT,COMBOBOX *);
|
261 |
|
|
static void CBoxSendMouseToLBox(COMBOBOX *, UINT, WPARAM, POINT);
|
262 |
|
|
static void CBoxCapture(HWND, WORD);
|
263 |
|
|
static void CBoxDrawEdit(COMBOBOX *, HWND, UINT);
|
264 |
|
|
static void CBoxDrawStatic(COMBOBOX *, HWND, UINT); /* MiD */
|
265 |
|
|
|
266 |
|
|
/* handle specific CB messages */
|
267 |
|
|
static LRESULT DefCBProc(HWND , UINT , WPARAM , LPARAM );
|
268 |
|
|
|
269 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
270 |
|
|
static WNDPROC lpComboBinToNat = 0;
|
271 |
|
|
#endif
|
272 |
|
|
|
273 |
|
|
static LRESULT CALLBACK
|
274 |
|
|
DefComboboxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
275 |
|
|
|
276 |
|
|
int WINAPI MwRegisterComboboxControl(HINSTANCE hInstance)
|
277 |
|
|
{
|
278 |
|
|
WNDCLASS wc;
|
279 |
|
|
|
280 |
|
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_GLOBALCLASS;
|
281 |
|
|
wc.lpfnWndProc = (WNDPROC)DefComboboxProc;
|
282 |
|
|
wc.cbClsExtra = 0;
|
283 |
|
|
wc.cbWndExtra = 0;
|
284 |
|
|
wc.hInstance = hInstance;
|
285 |
|
|
wc.hIcon = NULL;
|
286 |
|
|
wc.hCursor = 0;
|
287 |
|
|
wc.hbrBackground= GetStockObject(WHITE_BRUSH);
|
288 |
|
|
wc.lpszMenuName = NULL;
|
289 |
|
|
wc.lpszClassName= "COMBOBOX";
|
290 |
|
|
|
291 |
|
|
return RegisterClass(&wc);
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
static LRESULT CALLBACK
|
295 |
|
|
DefComboboxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
296 |
|
|
{
|
297 |
|
|
PAINTSTRUCT ps;
|
298 |
|
|
HDC hDC;
|
299 |
|
|
TEXTMETRIC tm;
|
300 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
301 |
|
|
MEASUREITEMSTRUCT mis;
|
302 |
|
|
#endif
|
303 |
|
|
COMBOBOX *lp = (COMBOBOX *)NULL;
|
304 |
|
|
LRESULT rc;
|
305 |
|
|
HINSTANCE hInst;
|
306 |
|
|
POINT cp,cpScreen,pp;
|
307 |
|
|
UINT uiKey;
|
308 |
|
|
LPCREATESTRUCT lpcs;
|
309 |
|
|
#if 1 /* jmt: fix: no WM_WINDOWPOSCHANGING */
|
310 |
|
|
LPWINDOWPOS lpwp;
|
311 |
|
|
#endif
|
312 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
313 |
|
|
HCLASS32 hComboClass32;
|
314 |
|
|
LPMEASUREITEMSTRUCT lpmis;
|
315 |
|
|
LPDRAWITEMSTRUCT lpdis;
|
316 |
|
|
LPDELETEITEMSTRUCT lpdlis;
|
317 |
|
|
#endif
|
318 |
|
|
DWORD dwStyle,dwExStyle;
|
319 |
|
|
WORD wEditWidth = 0,wEditHeight;
|
320 |
|
|
WORD wCBN;
|
321 |
|
|
#if 0 /* jmt: fix: no WM_SETFONT/WM_GETFONT */
|
322 |
|
|
RECT rcClient;
|
323 |
|
|
#endif
|
324 |
|
|
|
325 |
|
|
rc = CB_OKAY;
|
326 |
|
|
if ((uMsg != WM_CREATE/*WM_NCCREATE*/) && /*(uMsg != WM_CONVERT) &&*/
|
327 |
|
|
!(lp = (COMBOBOX *)hWnd->userdata/*GetWindowLong(hWnd,CWD_LPCBDATA)*/))
|
328 |
|
|
return rc;
|
329 |
|
|
|
330 |
|
|
switch(uMsg) {
|
331 |
|
|
#if 0
|
332 |
|
|
case WM_SIZE:
|
333 |
|
|
case WM_ENABLE:
|
334 |
|
|
case WM_LBUTTONDBLCLK:
|
335 |
|
|
case WM_COMPAREITEM:
|
336 |
|
|
case WM_CUT:
|
337 |
|
|
case WM_CLEAR:
|
338 |
|
|
#endif
|
339 |
|
|
|
340 |
|
|
case WM_SETFOCUS:
|
341 |
|
|
SET_STATE(lp, CSF_FOCUS);
|
342 |
|
|
if ((lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
|
343 |
|
|
{
|
344 |
|
|
uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
|
345 |
|
|
CBoxDrawStatic(lp, hWnd, uiKey);
|
346 |
|
|
}
|
347 |
|
|
if (lp->EditControl)
|
348 |
|
|
{
|
349 |
|
|
SetFocus(lp->EditControl);
|
350 |
|
|
}
|
351 |
|
|
break;
|
352 |
|
|
|
353 |
|
|
case WM_KILLFOCUS:
|
354 |
|
|
CLEAR_STATE(lp, CSF_FOCUS);
|
355 |
|
|
if ((lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
|
356 |
|
|
{
|
357 |
|
|
uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
|
358 |
|
|
CBoxDrawStatic(lp, hWnd, uiKey);
|
359 |
|
|
}
|
360 |
|
|
/*
|
361 |
|
|
** Hide listbox when loosing focus to window other than
|
362 |
|
|
** our own listbox... When wParam == 0 we "loose" the focus
|
363 |
|
|
** to the scrollbar in a listbox!
|
364 |
|
|
*/
|
365 |
|
|
if ((lp->wStyle & 0x0F) != CBS_SIMPLE && wParam != (WPARAM)lp->ListBoxControl && wParam != 0)
|
366 |
|
|
SendMessage(hWnd, CB_SHOWDROPDOWN, 0, 0L);
|
367 |
|
|
fprintf(stderr," 385: WM_KILLFOCUS\n");
|
368 |
|
|
break;
|
369 |
|
|
|
370 |
|
|
#if 0 /* jmt: fix: no WM_KEYDOWN */
|
371 |
|
|
case WM_KEYDOWN: /* MiD 08/14/95 */
|
372 |
|
|
/*
|
373 |
|
|
** We have to process this message in order to show
|
374 |
|
|
** current selection in a static control for certain
|
375 |
|
|
** keys. This doesn't affect combobox with an edit
|
376 |
|
|
** control, since the edit traps all key messages.
|
377 |
|
|
*/
|
378 |
|
|
{
|
379 |
|
|
int nCur = SendMessage(lp->ListBoxControl, LB_GETCURSEL,0, 0L);
|
380 |
|
|
int nPrevCur = nCur;
|
381 |
|
|
int nCount = SendMessage(lp->ListBoxControl, LB_GETCOUNT, 0, 0L);
|
382 |
|
|
|
383 |
|
|
if (nCount == 0)
|
384 |
|
|
break;
|
385 |
|
|
|
386 |
|
|
switch(wParam)
|
387 |
|
|
{
|
388 |
|
|
case VK_HOME:
|
389 |
|
|
nCur = 0;
|
390 |
|
|
break;
|
391 |
|
|
|
392 |
|
|
case VK_END:
|
393 |
|
|
nCur = nCount - 1;
|
394 |
|
|
break;
|
395 |
|
|
|
396 |
|
|
case VK_UP:
|
397 |
|
|
nCur--;
|
398 |
|
|
break;
|
399 |
|
|
|
400 |
|
|
case VK_DOWN:
|
401 |
|
|
nCur++;
|
402 |
|
|
break;
|
403 |
|
|
|
404 |
|
|
default:
|
405 |
|
|
return 0L;
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
if (nCur >= nCount)
|
409 |
|
|
nCur = nCount - 1;
|
410 |
|
|
if (nCur < 0)
|
411 |
|
|
nCur = 0;
|
412 |
|
|
|
413 |
|
|
SendMessage(lp->ListBoxControl, LB_SETCURSEL, nCur, 0L);
|
414 |
|
|
SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELCHANGE));
|
415 |
|
|
if (nCur != nPrevCur)
|
416 |
|
|
/* ecw */ SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELENDOK));
|
417 |
|
|
InvalidateRect(hWnd, NULL, 1);
|
418 |
|
|
break;
|
419 |
|
|
}
|
420 |
|
|
#endif /* WM_KEYDOWN */
|
421 |
|
|
|
422 |
|
|
case WM_CHAR:
|
423 |
|
|
{
|
424 |
|
|
int nNewCur;
|
425 |
|
|
int nOldCur;
|
426 |
|
|
|
427 |
|
|
if (lp->EditControl)
|
428 |
|
|
{
|
429 |
|
|
SendMessage(lp->EditControl, uMsg, wParam, lParam);
|
430 |
|
|
}
|
431 |
|
|
else {
|
432 |
|
|
nOldCur = SendMessage(lp->ListBoxControl, LB_GETCURSEL,0, 0L);
|
433 |
|
|
SendMessage(lp->ListBoxControl, uMsg, wParam, lParam);
|
434 |
|
|
nNewCur = SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
|
435 |
|
|
if (nNewCur != nOldCur)
|
436 |
|
|
{
|
437 |
|
|
SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELCHANGE));
|
438 |
|
|
InvalidateRect(hWnd, NULL, 1);
|
439 |
|
|
}
|
440 |
|
|
}
|
441 |
|
|
break;
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
#if 0 /* jmt: fix: no WM_SETREDRAW */
|
445 |
|
|
case WM_SETREDRAW:
|
446 |
|
|
lp->bRedraw = wParam;
|
447 |
|
|
if (lp->EditControl)
|
448 |
|
|
SendMessage(lp->EditControl, WM_SETREDRAW, wParam, lParam);
|
449 |
|
|
if (lp->ListBoxControl)
|
450 |
|
|
SendMessage(lp->ListBoxControl, WM_SETREDRAW, wParam, lParam);
|
451 |
|
|
break;
|
452 |
|
|
#endif
|
453 |
|
|
case WM_CREATE: /*WM_NCCREATE:*/
|
454 |
|
|
lp = (COMBOBOX *)WinMalloc(sizeof(COMBOBOX));
|
455 |
|
|
memset((LPSTR)lp,'\0',sizeof(COMBOBOX));
|
456 |
|
|
|
457 |
|
|
/* save ptr to internal structure */
|
458 |
|
|
hWnd->userdata=(DWORD)lp; /* -SetWindowLong(hWnd, CWD_LPCBDATA, (LONG) lp); */
|
459 |
|
|
|
460 |
|
|
/* this is for CreateWindow calls */
|
461 |
|
|
hInst = NULL; /* -GetWindowInstance(hWnd); */
|
462 |
|
|
|
463 |
|
|
/* fill in the internal structure */
|
464 |
|
|
lpcs = (LPCREATESTRUCT)lParam;
|
465 |
|
|
lp->bRedraw = 1;
|
466 |
|
|
lp->wStateFlags = 0;
|
467 |
|
|
lp->wStyle = (UINT)LOWORD(lpcs->style);
|
468 |
|
|
if (!BOWNERDRAW(lp))
|
469 |
|
|
lp->wStyle |= CBS_HASSTRINGS;
|
470 |
|
|
lp->bExtended = TRUE;
|
471 |
|
|
lp->hFont = 0;
|
472 |
|
|
lp->hWndParent = lpcs->hwndParent;
|
473 |
|
|
lp->nID = (UINT)lpcs->hMenu;
|
474 |
|
|
|
475 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
476 |
|
|
/* calc the height of the edit/static control */
|
477 |
|
|
if (0) /* (BOWNERDRAW(lp)) */
|
478 |
|
|
{
|
479 |
|
|
mis.CtlType = ODT_COMBOBOX;
|
480 |
|
|
mis.CtlID = (UINT)lpcs->hMenu;
|
481 |
|
|
mis.itemID = (UINT)-1;
|
482 |
|
|
mis.itemData = 0L;
|
483 |
|
|
SendMessage(lpcs->hwndParent, WM_MEASUREITEM, (WPARAM)lpcs->hMenu, (LPARAM)&mis);
|
484 |
|
|
/*** wEditHeight = (WORD)mis.itemHeight + 2; ***/
|
485 |
|
|
}
|
486 |
|
|
#endif /* ownerdraw */
|
487 |
|
|
|
488 |
|
|
/* get system font dimensions */
|
489 |
|
|
hDC = GetDC((HWND)0);
|
490 |
|
|
GetTextMetrics(hDC,&tm);
|
491 |
|
|
ReleaseDC((HWND)0,hDC);
|
492 |
|
|
|
493 |
|
|
/* allow different fonts to fit, don't hard code */
|
494 |
|
|
/* otherwise big fonts won't fit. */
|
495 |
|
|
/*****wEditHeight = ((tm.tmHeight - tm.tmInternalLeading)*7)/4;*****/
|
496 |
|
|
wEditHeight = tm.tmHeight + tm.tmInternalLeading * 3;
|
497 |
|
|
|
498 |
|
|
lp->uHeight = (UINT)wEditHeight;
|
499 |
|
|
|
500 |
|
|
if ((lp->wStyle & 0x0F) != CBS_SIMPLE)
|
501 |
|
|
{
|
502 |
|
|
lp->ButtonRect.top = 0;
|
503 |
|
|
lp->ButtonRect.left = lpcs->cx - 1 - GetSystemMetrics(SM_CXVSCROLL);
|
504 |
|
|
lp->ButtonRect.right = lpcs->cx;
|
505 |
|
|
lp->ButtonRect.bottom = wEditHeight;
|
506 |
|
|
/* for CBS_DROPDOWN/DROPDOWNLIST resize the window */
|
507 |
|
|
SetWindowPos(hWnd, 0,
|
508 |
|
|
0, 0, lpcs->cx, (int)wEditHeight,
|
509 |
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
|
510 |
|
|
}
|
511 |
|
|
else SetRectEmpty(&lp->ButtonRect);
|
512 |
|
|
|
513 |
|
|
if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
|
514 |
|
|
{ /* EDIT field - calc edit control style */
|
515 |
|
|
dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER;
|
516 |
|
|
if (lp->wStyle & CBS_AUTOHSCROLL)
|
517 |
|
|
dwStyle |= ES_AUTOHSCROLL;
|
518 |
|
|
if (lp->wStyle & CBS_OEMCONVERT)
|
519 |
|
|
dwStyle |= ES_OEMCONVERT;
|
520 |
|
|
|
521 |
|
|
if ((lp->wStyle & 0x0F) == CBS_SIMPLE)
|
522 |
|
|
{
|
523 |
|
|
fprintf(stderr," 528: wEditWidth = lpcs->cx=%d\n",lpcs->cx);
|
524 |
|
|
wEditWidth = lpcs->cx;
|
525 |
|
|
}
|
526 |
|
|
else /* ?if ((lp->wStyle & 0xf) == CBS_DROPDOWN) */
|
527 |
|
|
{
|
528 |
|
|
fprintf(stderr," 533: wEditWidth = lp->ButtonRect.left - 5=%d;\n",lp->ButtonRect.left - 5);
|
529 |
|
|
wEditWidth = lp->ButtonRect.left - 5;
|
530 |
|
|
}
|
531 |
|
|
/* create edit control */
|
532 |
|
|
lp->EditControl = CreateWindow("EDIT", NULL, dwStyle,
|
533 |
|
|
0, 0, wEditWidth, wEditHeight,
|
534 |
|
|
hWnd, (HMENU)CBC_EDITID,
|
535 |
|
|
hInst,(LPVOID)NULL);
|
536 |
|
|
}
|
537 |
|
|
else /* CBS_DROPDOWN -- static instead of edit */
|
538 |
|
|
lp->EditControl = 0;
|
539 |
|
|
|
540 |
|
|
/* listbox style */
|
541 |
|
|
/* jmt: fix: no WS_EX_SAVEBITS, WS_EX_NOCAPTURE, WS_EX_POPUPMENU */
|
542 |
|
|
dwExStyle = 0L; /* WS_EX_SAVEBITS | WS_EX_NOCAPTURE | WS_EX_POPUPMENU; */
|
543 |
|
|
dwStyle = WS_BORDER | LBS_NOTIFY ; /* | LBS_COMBOLBOX; */
|
544 |
|
|
if ((lp->wStyle & 0xf) == CBS_SIMPLE)
|
545 |
|
|
dwStyle |= WS_VISIBLE | WS_CHILD;
|
546 |
|
|
else
|
547 |
|
|
dwStyle |= WS_POPUP;
|
548 |
|
|
#if 0
|
549 |
|
|
if (lp->wStyle & CBS_DISABLENOSCROLL)
|
550 |
|
|
dwStyle |= LBS_DISABLENOSCROLL;
|
551 |
|
|
#endif
|
552 |
|
|
if (lp->wStyle & CBS_HASSTRINGS)
|
553 |
|
|
dwStyle |= LBS_HASSTRINGS;
|
554 |
|
|
if (lp->wStyle & CBS_NOINTEGRALHEIGHT)
|
555 |
|
|
dwStyle |= LBS_NOINTEGRALHEIGHT;
|
556 |
|
|
if (lp->wStyle & CBS_OWNERDRAWFIXED)
|
557 |
|
|
dwStyle |= LBS_OWNERDRAWFIXED;
|
558 |
|
|
if (lp->wStyle & CBS_OWNERDRAWVARIABLE)
|
559 |
|
|
dwStyle |= LBS_OWNERDRAWVARIABLE;
|
560 |
|
|
if (lp->wStyle & CBS_SORT)
|
561 |
|
|
dwStyle |= LBS_SORT;
|
562 |
|
|
if (lpcs->style & WS_VSCROLL)
|
563 |
|
|
dwStyle |= WS_VSCROLL;
|
564 |
|
|
|
565 |
|
|
/* calc listbox dimensions and position */
|
566 |
|
|
if ((lp->wStyle & 0xf) == CBS_SIMPLE) {
|
567 |
|
|
lp->ListBoxRect.left = 5;
|
568 |
|
|
lp->ListBoxRect.top = wEditHeight - 1;
|
569 |
|
|
lp->ListBoxRect.right = lpcs->cx;
|
570 |
|
|
lp->ListBoxRect.bottom = lpcs->cy - 2;
|
571 |
|
|
} else {
|
572 |
|
|
lp->ListBoxRect.left = lpcs->x;
|
573 |
|
|
lp->ListBoxRect.right = lp->ListBoxRect.left + lpcs->cx - 1;
|
574 |
|
|
lp->ListBoxRect.top = lpcs->y + wEditHeight - 1;
|
575 |
|
|
lp->ListBoxRect.bottom = lp->ListBoxRect.top + lpcs->cy + 1;
|
576 |
|
|
if ((lp->wStyle & 0x0F) == CBS_DROPDOWN) {
|
577 |
|
|
lp->ListBoxRect.left += 5;
|
578 |
|
|
}
|
579 |
|
|
}
|
580 |
|
|
#ifdef LATER
|
581 |
|
|
cp.x = ((lp->wStyle & 0xf) == CBS_DROPDOWNLIST)?0:5;
|
582 |
|
|
cp.y = wEditHeight - 1;
|
583 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
584 |
|
|
ClientToScreen(hWnd,&cp);
|
585 |
|
|
lp->ListBoxRect.left = cp.x;
|
586 |
|
|
lp->ListBoxRect.top = cp.y;
|
587 |
|
|
lp->ListBoxRect.right = cp.x + lpcs->cx;
|
588 |
|
|
if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
|
589 |
|
|
lp->ListBoxRect.right -= 5;
|
590 |
|
|
lp->ListBoxRect.bottom = lp->ListBoxRect.top + lpcs->cy -
|
591 |
|
|
wEditHeight + 1;
|
592 |
|
|
#endif
|
593 |
|
|
|
594 |
|
|
lp->ListBoxControl = CreateWindowEx(dwExStyle,"LISTBOX",/*"COMBOLBOX",*/
|
595 |
|
|
NULL, dwStyle,
|
596 |
|
|
lp->ListBoxRect.left, lp->ListBoxRect.top,
|
597 |
|
|
lp->ListBoxRect.right - lp->ListBoxRect.left,
|
598 |
|
|
lp->ListBoxRect.bottom - lp->ListBoxRect.top,
|
599 |
|
|
hWnd, 0,
|
600 |
|
|
hInst,(LPVOID)NULL);
|
601 |
|
|
#if MWCLIENT
|
602 |
|
|
#if 0
|
603 |
|
|
GrLowerWindow(lp->ListBoxControl->wid);
|
604 |
|
|
#endif
|
605 |
|
|
MwLowerWindow(lp->ListBoxControl);
|
606 |
|
|
#endif
|
607 |
|
|
#ifdef LATER
|
608 |
|
|
/* Microsoft Word 6.0 wants to see COMBOLBOX on top */
|
609 |
|
|
/* of Z-order... */
|
610 |
|
|
if (dwStyle & WS_POPUP)
|
611 |
|
|
{
|
612 |
|
|
SetWindowPos(lp->ListBoxControl, HWND_TOP,
|
613 |
|
|
0, 0, 0, 0,
|
614 |
|
|
SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
|
615 |
|
|
}
|
616 |
|
|
#endif
|
617 |
|
|
|
618 |
|
|
#if 0 /* jmt: fix: no HWND32(LPWININFO) */
|
619 |
|
|
/* physically expand client window,
|
620 |
|
|
if there is a scroll style
|
621 |
|
|
*/
|
622 |
|
|
if (lpcs->style & WS_VSCROLL)
|
623 |
|
|
{
|
624 |
|
|
HWND32 hWnd32 = GETHWND32(hWnd);
|
625 |
|
|
|
626 |
|
|
SetRectEmpty(&hWnd32->rcNC);
|
627 |
|
|
|
628 |
|
|
hWnd32->wWidth = (WORD) hWnd32->rWnd.right-hWnd32->rWnd.left;
|
629 |
|
|
hWnd32->wHeight = (WORD)hWnd32->rWnd.bottom-hWnd32->rWnd.top;
|
630 |
|
|
RELEASEWININFO(hWnd32);
|
631 |
|
|
}
|
632 |
|
|
#endif
|
633 |
|
|
/*
|
634 |
|
|
** Finally turn off border drawing and WM_?SCROLL styles to prevent creation
|
635 |
|
|
** of system scrollbars.
|
636 |
|
|
*/
|
637 |
|
|
dwStyle = GetWindowLong(hWnd, GWL_STYLE);
|
638 |
|
|
dwStyle &= ~(WS_VSCROLL | WS_HSCROLL | WS_BORDER | WS_DLGFRAME | WS_THICKFRAME);
|
639 |
|
|
SetWindowLong(hWnd, GWL_STYLE, dwStyle);
|
640 |
|
|
lp->nListItems = 0;
|
641 |
|
|
return TRUE;
|
642 |
|
|
|
643 |
|
|
case WM_DESTROY: /*WM_NCDESTROY:*/
|
644 |
|
|
if (IsWindow(lp->ListBoxControl))
|
645 |
|
|
DestroyWindow(lp->ListBoxControl);
|
646 |
|
|
if (IsWindow(lp->EditControl))
|
647 |
|
|
DestroyWindow(lp->EditControl);
|
648 |
|
|
WinFree((LPSTR)lp);
|
649 |
|
|
return 0L;
|
650 |
|
|
|
651 |
|
|
case WM_GETDLGCODE:
|
652 |
|
|
return (LRESULT)(DLGC_WANTCHARS|DLGC_WANTARROWS);
|
653 |
|
|
|
654 |
|
|
/* jmt: twine->mwin bug fixed: */
|
655 |
|
|
case WM_NCLBUTTONDOWN: /* jmt: a must */
|
656 |
|
|
#if 0 /* twine->mw buggy */
|
657 |
|
|
case WM_LBUTTONDOWN:
|
658 |
|
|
#endif
|
659 |
|
|
if ((lp->wStyle & 0xf) == CBS_SIMPLE)
|
660 |
|
|
break;
|
661 |
|
|
|
662 |
|
|
cp.x = (int)(short)LOWORD(lParam);
|
663 |
|
|
cp.y = (int)(short)HIWORD(lParam);
|
664 |
|
|
#if 1 /* WM_NCLBUTTONDOWM: */
|
665 |
|
|
ScreenToClient(hWnd, &cp); /* jmt: a must */
|
666 |
|
|
#endif
|
667 |
|
|
if (!IS_SET(lp, CSF_CAPTUREACTIVE)) /* no listbox yet */
|
668 |
|
|
{
|
669 |
|
|
/* click on a button or anywhere if it's dropdown combo */
|
670 |
|
|
if (PtInRect(&lp->ButtonRect, cp) ||
|
671 |
|
|
(lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
|
672 |
|
|
{
|
673 |
|
|
if (PtInRect(&lp->ButtonRect, cp))
|
674 |
|
|
CBoxDrawButton(hWnd, 1, lp);
|
675 |
|
|
|
676 |
|
|
cp.x = ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST) ? 5 : 0;
|
677 |
|
|
cp.y = lp->uHeight - 1;
|
678 |
|
|
|
679 |
|
|
ClientToScreen(hWnd, &cp);
|
680 |
|
|
|
681 |
|
|
fprintf(stderr," (1)lp->ListBoxRect:(%d,%d,%d,%d)\n",
|
682 |
|
|
lp->ListBoxRect.left,
|
683 |
|
|
lp->ListBoxRect.top,
|
684 |
|
|
lp->ListBoxRect.right,
|
685 |
|
|
lp->ListBoxRect.bottom);
|
686 |
|
|
|
687 |
|
|
OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
|
688 |
|
|
|
689 |
|
|
fprintf(stderr," (2)lp->ListBoxRect:(%d,%d,%d,%d)\n",
|
690 |
|
|
lp->ListBoxRect.left,
|
691 |
|
|
lp->ListBoxRect.top,
|
692 |
|
|
lp->ListBoxRect.right,
|
693 |
|
|
lp->ListBoxRect.bottom);
|
694 |
|
|
|
695 |
|
|
SetWindowPos(lp->ListBoxControl, HWND_TOP, /*0,*/
|
696 |
|
|
cp.x, cp.y, 0, 0,
|
697 |
|
|
SWP_NOSIZE | /*SWP_NOZORDER |*/ SWP_NOACTIVATE);
|
698 |
|
|
|
699 |
|
|
SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_DROPDOWN));
|
700 |
|
|
/* ECW added following conditional... 4/4/96 */
|
701 |
|
|
/* JMT following conditional is a must for microwindows 8/14/2k */
|
702 |
|
|
if (1) /* -(!IS_SET(lp, CSF_HASDROPPED)) jmt: a must */
|
703 |
|
|
{
|
704 |
|
|
/* ??first time it drops down, size it to hold all items?? */
|
705 |
|
|
|
706 |
|
|
int nitems = SendMessage(lp->ListBoxControl,LB_GETCOUNT,0,0L);
|
707 |
|
|
#if 0
|
708 |
|
|
/* resize if too small, in this case, also do too long */
|
709 |
|
|
if (lp->ListBoxRect.bottom - lp->ListBoxRect.top <
|
710 |
|
|
((lp->uHeight-2) * nitems))
|
711 |
|
|
{
|
712 |
|
|
#endif
|
713 |
|
|
nitems = (nitems > 12 ? 12 : nitems); /* a dozen, max */
|
714 |
|
|
|
715 |
|
|
#if 0 /* twine->mw buggy? */
|
716 |
|
|
lp->ListBoxRect.bottom =
|
717 |
|
|
lp->ListBoxRect.top + ((lp->uHeight-2) * nitems);
|
718 |
|
|
#endif
|
719 |
|
|
fprintf(stderr," (2.5)lp->ListBoxRect:(%d,%d,%d,%d)\n",
|
720 |
|
|
lp->ListBoxRect.left,
|
721 |
|
|
lp->ListBoxRect.top,
|
722 |
|
|
lp->ListBoxRect.right,
|
723 |
|
|
lp->ListBoxRect.bottom);
|
724 |
|
|
|
725 |
|
|
/* jmt: twine->mwin bug fixed: */
|
726 |
|
|
fprintf(stderr," 706: fixed: SetWindowPos(lp->ListBoxControl,,%d,%d,...)\n",cp.x,cp.y);
|
727 |
|
|
#if 0 /* twine->mwin bug */
|
728 |
|
|
SetWindowPos(lp->ListBoxControl,HWND_TOP,0,0,
|
729 |
|
|
lp->ListBoxRect.right - lp->ListBoxRect.left,
|
730 |
|
|
lp->ListBoxRect.bottom - lp->ListBoxRect.top,
|
731 |
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
732 |
|
|
#else /* jmt: twine->mwin bug fixed: */
|
733 |
|
|
SetWindowPos(lp->ListBoxControl,HWND_TOP,cp.x,cp.y,
|
734 |
|
|
lp->ListBoxRect.right - lp->ListBoxRect.left,
|
735 |
|
|
lp->ListBoxRect.bottom - lp->ListBoxRect.top,
|
736 |
|
|
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
|
737 |
|
|
#endif
|
738 |
|
|
|
739 |
|
|
#if 0
|
740 |
|
|
}
|
741 |
|
|
#endif
|
742 |
|
|
SET_STATE(lp, CSF_HASDROPPED);
|
743 |
|
|
}
|
744 |
|
|
/* End of addition */
|
745 |
|
|
ShowWindow(lp->ListBoxControl, SW_SHOW);
|
746 |
|
|
#if 0 /* orig(twine) */
|
747 |
|
|
SetFocus(lp->ListBoxControl);
|
748 |
|
|
#else /* jmt: mwclient */
|
749 |
|
|
SetForegroundWindow(lp->ListBoxControl);
|
750 |
|
|
#endif
|
751 |
|
|
CBoxCapture(hWnd, 1);
|
752 |
|
|
SET_STATE(lp, CSF_CAPTUREACTIVE);
|
753 |
|
|
SET_STATE(lp, CSF_BUTTONDOWN);
|
754 |
|
|
}
|
755 |
|
|
}
|
756 |
|
|
else
|
757 |
|
|
{ /* there is a listbox visible */
|
758 |
|
|
HWND hwndNewFocus = 0;
|
759 |
|
|
|
760 |
|
|
cpScreen = cp;
|
761 |
|
|
|
762 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
763 |
|
|
{
|
764 |
|
|
ClientToScreen(hWnd, &cpScreen);
|
765 |
|
|
hwndNewFocus = WindowFromPoint(cpScreen);
|
766 |
|
|
}
|
767 |
|
|
|
768 |
|
|
fprintf(stderr," (3)lp->ListBoxRect:(%d,%d,%d,%d)\n",
|
769 |
|
|
lp->ListBoxRect.left,
|
770 |
|
|
lp->ListBoxRect.top,
|
771 |
|
|
lp->ListBoxRect.right,
|
772 |
|
|
lp->ListBoxRect.bottom);
|
773 |
|
|
|
774 |
|
|
if (PtInRect(&lp->ListBoxRect, cpScreen))
|
775 |
|
|
{
|
776 |
|
|
CBoxSendMouseToLBox(lp, WM_LBUTTONDOWN, wParam, cpScreen);
|
777 |
|
|
}
|
778 |
|
|
else
|
779 |
|
|
{
|
780 |
|
|
if (PtInRect(&lp->ButtonRect, cp))
|
781 |
|
|
CBoxDrawButton(hWnd, 0, lp);
|
782 |
|
|
if ((lp->wStyle & 0x0F) == CBS_DROPDOWN && hwndNewFocus == lp->EditControl)
|
783 |
|
|
/* don't close listbox */;
|
784 |
|
|
else {
|
785 |
|
|
SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
|
786 |
|
|
|
787 |
|
|
fprintf(stderr," 802: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
|
788 |
|
|
|
789 |
|
|
SetWindowPos(lp->ListBoxControl, 0,
|
790 |
|
|
0, 0, 0, 0,
|
791 |
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
|
792 |
|
|
#if MWCLIENT
|
793 |
|
|
MwLowerWindow(lp->ListBoxControl);
|
794 |
|
|
#endif
|
795 |
|
|
CBoxCapture(hWnd, 0);
|
796 |
|
|
CLEAR_STATE(lp, CSF_BUTTONDOWN);
|
797 |
|
|
}
|
798 |
|
|
CLEAR_STATE(lp, CSF_CAPTUREACTIVE);
|
799 |
|
|
|
800 |
|
|
if (hwndNewFocus && hwndNewFocus != hWnd)
|
801 |
|
|
{
|
802 |
|
|
ScreenToClient(hwndNewFocus, &cpScreen);
|
803 |
|
|
SetFocus(hwndNewFocus);
|
804 |
|
|
|
805 |
|
|
SendMessage(hwndNewFocus, WM_LBUTTONDOWN, wParam, MAKELONG(cpScreen.x, cpScreen.y));
|
806 |
|
|
}
|
807 |
|
|
} /* !(PtInRect(&lp->ListBoxRect, cpScreen)) */
|
808 |
|
|
}
|
809 |
|
|
break;
|
810 |
|
|
|
811 |
|
|
/* jmt: twine->mwin bug fixed: */
|
812 |
|
|
case WM_NCMOUSEMOVE:
|
813 |
|
|
#if 0 /* jmt: twine->mw buggy */
|
814 |
|
|
case WM_MOUSEMOVE:
|
815 |
|
|
#endif
|
816 |
|
|
if (!IS_SET(lp,CSF_BUTTONDOWN) && ((lp->wStyle & 0xf) == CBS_SIMPLE))
|
817 |
|
|
break;
|
818 |
|
|
|
819 |
|
|
cp.x = (int)(short)LOWORD(lParam);
|
820 |
|
|
cp.y = (int)(short)HIWORD(lParam);
|
821 |
|
|
#if 1 /* WM_NCMOUSEMOVE: */
|
822 |
|
|
ScreenToClient(hWnd, &cp); /* jmt: a must */
|
823 |
|
|
#endif
|
824 |
|
|
|
825 |
|
|
if (IS_SET(lp, CSF_CAPTUREACTIVE))
|
826 |
|
|
{
|
827 |
|
|
if (PtInRect(&lp->ButtonRect,cp))
|
828 |
|
|
{
|
829 |
|
|
if (!IS_SET(lp, CSF_LOCALBUTTONDOWN))
|
830 |
|
|
CBoxDrawButton(hWnd, 1, lp);
|
831 |
|
|
break;
|
832 |
|
|
}
|
833 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
834 |
|
|
ClientToScreen(hWnd,&cp);
|
835 |
|
|
if (PtInRect(&lp->ListBoxRect,cp))
|
836 |
|
|
{
|
837 |
|
|
CBoxSendMouseToLBox(lp,WM_MOUSEMOVE,wParam,cp);
|
838 |
|
|
}
|
839 |
|
|
if (IS_SET(lp,CSF_LOCALBUTTONDOWN) && ((lp->wStyle & 0xf) != CBS_SIMPLE))
|
840 |
|
|
CBoxDrawButton(hWnd,0,lp);
|
841 |
|
|
}
|
842 |
|
|
break;
|
843 |
|
|
|
844 |
|
|
/* jmt: twine->mwin bug fixed: */
|
845 |
|
|
case WM_NCLBUTTONUP:
|
846 |
|
|
#if 0 /* twine->mw buggy */
|
847 |
|
|
case WM_LBUTTONUP:
|
848 |
|
|
#endif
|
849 |
|
|
if (!IS_SET(lp, CSF_CAPTUREACTIVE))
|
850 |
|
|
break;
|
851 |
|
|
|
852 |
|
|
cp.x = (int)(short)LOWORD(lParam);
|
853 |
|
|
cp.y = (int)(short)HIWORD(lParam);
|
854 |
|
|
#if 1 /* WM_NCLBUTTONUP */
|
855 |
|
|
ScreenToClient(hWnd, &cp); /* jmt: a must */
|
856 |
|
|
#endif
|
857 |
|
|
|
858 |
|
|
CLEAR_STATE(lp,CSF_BUTTONDOWN);
|
859 |
|
|
|
860 |
|
|
if (PtInRect(&lp->ButtonRect, cp))
|
861 |
|
|
/*(lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)*/
|
862 |
|
|
{
|
863 |
|
|
if (PtInRect(&lp->ButtonRect, cp))
|
864 |
|
|
CBoxDrawButton(hWnd, 0, lp);
|
865 |
|
|
if (IS_SET(lp, CSF_LBOXBUTTONDOWN))
|
866 |
|
|
{
|
867 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
868 |
|
|
ClientToScreen(hWnd, &cp);
|
869 |
|
|
CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
|
870 |
|
|
CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
|
871 |
|
|
}
|
872 |
|
|
break;
|
873 |
|
|
}
|
874 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
875 |
|
|
ClientToScreen(hWnd, &cp);
|
876 |
|
|
|
877 |
|
|
if (PtInRect(&lp->ListBoxRect, cp))
|
878 |
|
|
{
|
879 |
|
|
uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
|
880 |
|
|
if (uiKey != (UINT)LB_ERR)
|
881 |
|
|
{
|
882 |
|
|
if (lp->EditControl)
|
883 |
|
|
{
|
884 |
|
|
SetFocus(lp->EditControl);
|
885 |
|
|
|
886 |
|
|
CBoxDrawEdit(lp, hWnd, uiKey);
|
887 |
|
|
}
|
888 |
|
|
else {
|
889 |
|
|
SetFocus(hWnd);
|
890 |
|
|
|
891 |
|
|
CBoxDrawStatic(lp, hWnd, uiKey);
|
892 |
|
|
}
|
893 |
|
|
|
894 |
|
|
/* LATER check the WS_EX_NOPARENTNOTIFY bit in ext style.*/
|
895 |
|
|
/* ecw */ SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_SELENDOK));
|
896 |
|
|
SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
|
897 |
|
|
|
898 |
|
|
fprintf(stderr," 844: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
|
899 |
|
|
|
900 |
|
|
SetWindowPos(lp->ListBoxControl, 0,
|
901 |
|
|
0, 0, 0, 0,
|
902 |
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
|
903 |
|
|
|
904 |
|
|
CBoxCapture(hWnd, 0);
|
905 |
|
|
CLEAR_STATE(lp,CSF_CAPTUREACTIVE);
|
906 |
|
|
} /* uiKey ok */
|
907 |
|
|
|
908 |
|
|
CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
|
909 |
|
|
CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
|
910 |
|
|
#if MWCLIENT
|
911 |
|
|
#if 0
|
912 |
|
|
GrLowerWindow(lp->ListBoxControl->wid);
|
913 |
|
|
#endif
|
914 |
|
|
MwLowerWindow(lp->ListBoxControl);
|
915 |
|
|
#endif
|
916 |
|
|
}
|
917 |
|
|
else /* clicked somewhere outside button or listbox -
|
918 |
|
|
** the listbox should stay intact... MiD
|
919 |
|
|
*/
|
920 |
|
|
if (IS_SET(lp, CSF_LBOXBUTTONDOWN))
|
921 |
|
|
{
|
922 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
923 |
|
|
ClientToScreen(hWnd, &cp);
|
924 |
|
|
CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
|
925 |
|
|
CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
|
926 |
|
|
}
|
927 |
|
|
break;
|
928 |
|
|
|
929 |
|
|
case WM_ERASEBKGND:
|
930 |
|
|
return 1L;
|
931 |
|
|
|
932 |
|
|
case WM_PAINT:
|
933 |
|
|
BeginPaint(hWnd,&ps);
|
934 |
|
|
EndPaint(hWnd,&ps);
|
935 |
|
|
|
936 |
|
|
if (!IsWindowVisible(hWnd) || !lp->bRedraw)
|
937 |
|
|
return 0L;
|
938 |
|
|
|
939 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
940 |
|
|
CBoxDrawButton(hWnd, IS_SET(lp,CSF_LOCALBUTTONDOWN), lp);
|
941 |
|
|
uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
|
942 |
|
|
if (lp->EditControl)
|
943 |
|
|
CBoxDrawEdit(lp, hWnd, uiKey);
|
944 |
|
|
else CBoxDrawStatic(lp, hWnd, uiKey);
|
945 |
|
|
return 0L;
|
946 |
|
|
|
947 |
|
|
case WM_COMMAND:
|
948 |
|
|
if (GET_WM_COMMAND_ID(wParam,lParam) == CBC_EDITID) {
|
949 |
|
|
/* edit/static control notifications */
|
950 |
|
|
switch((short)GET_WM_COMMAND_CMD(wParam,lParam)) {
|
951 |
|
|
case EN_SETFOCUS:
|
952 |
|
|
#ifdef LATER
|
953 |
|
|
wCBN = CBN_SETFOCUS;
|
954 |
|
|
#else
|
955 |
|
|
wCBN = 0;
|
956 |
|
|
#endif
|
957 |
|
|
break;
|
958 |
|
|
case EN_KILLFOCUS:
|
959 |
|
|
wCBN = CBN_KILLFOCUS;
|
960 |
|
|
break;
|
961 |
|
|
case EN_CHANGE:
|
962 |
|
|
{
|
963 |
|
|
int index = 0;
|
964 |
|
|
char sz[128];
|
965 |
|
|
/*
|
966 |
|
|
** Advance listbox
|
967 |
|
|
** selection until there is string match. One first mismatch
|
968 |
|
|
** listbox advances to its first item.
|
969 |
|
|
*/
|
970 |
|
|
SendMessage(lp->EditControl, WM_GETTEXT, sizeof(sz)-1, (LPARAM)sz);
|
971 |
|
|
if (/*l*/strlen(sz) > 0/*L*/)
|
972 |
|
|
index = (int)SendMessage(lp->ListBoxControl, LB_FINDSTRING, -1, (LPARAM)sz);
|
973 |
|
|
if (index == LB_ERR)
|
974 |
|
|
index = 0;
|
975 |
|
|
SendMessage(lp->ListBoxControl, LB_SETTOPINDEX, index, 0L);
|
976 |
|
|
wCBN = CBN_EDITCHANGE;
|
977 |
|
|
break;
|
978 |
|
|
}
|
979 |
|
|
case EN_UPDATE:
|
980 |
|
|
wCBN = CBN_EDITUPDATE;
|
981 |
|
|
break;
|
982 |
|
|
case EN_ERRSPACE:
|
983 |
|
|
wCBN = CBN_ERRSPACE;
|
984 |
|
|
break;
|
985 |
|
|
default:
|
986 |
|
|
wCBN = 0;
|
987 |
|
|
break;
|
988 |
|
|
}
|
989 |
|
|
if (wCBN)
|
990 |
|
|
return SendMessage(lp->hWndParent,WM_COMMAND,
|
991 |
|
|
GET_WM_COMMAND_MPS(lp->nID,hWnd,wCBN));
|
992 |
|
|
else
|
993 |
|
|
return rc;
|
994 |
|
|
}
|
995 |
|
|
if (GET_WM_COMMAND_ID(wParam,lParam) == 0) {
|
996 |
|
|
/* listbox notifications */
|
997 |
|
|
switch ((short)GET_WM_COMMAND_CMD(wParam,lParam)) {
|
998 |
|
|
case LBN_ERRSPACE:
|
999 |
|
|
wCBN = CBN_ERRSPACE;
|
1000 |
|
|
break;
|
1001 |
|
|
case LBN_SELCHANGE:
|
1002 |
|
|
if ((lp->wStyle & 0xf) == CBS_SIMPLE)
|
1003 |
|
|
{
|
1004 |
|
|
uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
|
1005 |
|
|
if (uiKey != (UINT)LB_ERR)
|
1006 |
|
|
if (lp->EditControl)
|
1007 |
|
|
{
|
1008 |
|
|
CBoxDrawEdit(lp, hWnd, uiKey);
|
1009 |
|
|
}
|
1010 |
|
|
}
|
1011 |
|
|
wCBN = CBN_SELCHANGE;
|
1012 |
|
|
break;
|
1013 |
|
|
case LBN_DBLCLK:
|
1014 |
|
|
wCBN = CBN_DBLCLK;
|
1015 |
|
|
break;
|
1016 |
|
|
case LBN_SELCANCEL: /* TODO */
|
1017 |
|
|
wCBN = 0;
|
1018 |
|
|
break;
|
1019 |
|
|
case LBN_SETFOCUS:
|
1020 |
|
|
wCBN = CBN_SETFOCUS;
|
1021 |
|
|
break;
|
1022 |
|
|
case LBN_KILLFOCUS:
|
1023 |
|
|
wCBN = CBN_KILLFOCUS;
|
1024 |
|
|
break;
|
1025 |
|
|
default:
|
1026 |
|
|
wCBN = 0;
|
1027 |
|
|
break;
|
1028 |
|
|
}
|
1029 |
|
|
if (wCBN)
|
1030 |
|
|
return SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,wCBN));
|
1031 |
|
|
else
|
1032 |
|
|
return rc;
|
1033 |
|
|
}
|
1034 |
|
|
break;
|
1035 |
|
|
|
1036 |
|
|
case WM_GETTEXT:
|
1037 |
|
|
if ( lp->EditControl )
|
1038 |
|
|
return SendMessage(lp->EditControl,uMsg,wParam,lParam);
|
1039 |
|
|
else if ( lp->ListBoxControl ) {
|
1040 |
|
|
WPARAM sel, len;
|
1041 |
|
|
|
1042 |
|
|
sel = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
|
1043 |
|
|
if ( sel != (WPARAM)LB_ERR ) {
|
1044 |
|
|
len = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, 0, 0);
|
1045 |
|
|
if ( len <= wParam )
|
1046 |
|
|
return SendMessage(lp->ListBoxControl, LB_GETTEXT, sel, lParam);
|
1047 |
|
|
}
|
1048 |
|
|
}
|
1049 |
|
|
return CB_ERR;
|
1050 |
|
|
|
1051 |
|
|
case WM_GETTEXTLENGTH:
|
1052 |
|
|
if ( lp->EditControl )
|
1053 |
|
|
return SendMessage(lp->EditControl,uMsg,wParam,lParam);
|
1054 |
|
|
else if ( lp->ListBoxControl ) {
|
1055 |
|
|
WPARAM sel;
|
1056 |
|
|
|
1057 |
|
|
sel = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
|
1058 |
|
|
if ( sel != (WPARAM)LB_ERR )
|
1059 |
|
|
return SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, sel, 0);
|
1060 |
|
|
}
|
1061 |
|
|
return CB_ERR;
|
1062 |
|
|
|
1063 |
|
|
case WM_SETTEXT:
|
1064 |
|
|
if ( lp->EditControl )
|
1065 |
|
|
return SendMessage(lp->EditControl,uMsg,wParam,lParam);
|
1066 |
|
|
return CB_ERR;
|
1067 |
|
|
|
1068 |
|
|
#if 0 /* jmt: fix: no WM_SETFONT/WM_GETFONT */
|
1069 |
|
|
case WM_SETFONT:
|
1070 |
|
|
lp->hFont = (HFONT)wParam;
|
1071 |
|
|
|
1072 |
|
|
hDC = GetDC(hWnd);
|
1073 |
|
|
SelectObject(hDC,lp->hFont);
|
1074 |
|
|
GetTextMetrics(hDC,&tm);
|
1075 |
|
|
ReleaseDC(hWnd,hDC);
|
1076 |
|
|
wEditHeight = tm.tmHeight + 3 * tm.tmInternalLeading;
|
1077 |
|
|
|
1078 |
|
|
if (wEditHeight == lp->uHeight)
|
1079 |
|
|
return 0L;
|
1080 |
|
|
|
1081 |
|
|
lp->uHeight = (UINT)wEditHeight;
|
1082 |
|
|
lp->ButtonRect.bottom = wEditHeight;
|
1083 |
|
|
/*
|
1084 |
|
|
** The following SetWindowPos causes WM_WINDOWPOSCHANGING message
|
1085 |
|
|
** where child windows are resized and/or moved.
|
1086 |
|
|
*/
|
1087 |
|
|
ShowWindow(hWnd, SW_HIDE);
|
1088 |
|
|
GetClientRect(hWnd,&rcClient);
|
1089 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
1090 |
|
|
SetWindowPos(hWnd, 0,
|
1091 |
|
|
0, 0, rcClient.right, (int)wEditHeight,
|
1092 |
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
|
1093 |
|
|
else SetWindowPos(hWnd, 0,
|
1094 |
|
|
0, 0, rcClient.right, (int)wEditHeight + lp->ListBoxRect.bottom - lp->ListBoxRect.top + 1,
|
1095 |
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
|
1096 |
|
|
ShowWindow(hWnd, SW_SHOWNA);
|
1097 |
|
|
|
1098 |
|
|
if (lp->EditControl)
|
1099 |
|
|
SendMessage(lp->EditControl, WM_SETFONT, wParam,lParam);
|
1100 |
|
|
SendMessage(lp->ListBoxControl, WM_SETFONT, wParam,lParam);
|
1101 |
|
|
|
1102 |
|
|
if(LOWORD(lParam))
|
1103 |
|
|
RedrawWindow(hWnd,(const RECT *)0,(HRGN)0,
|
1104 |
|
|
RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
|
1105 |
|
|
return (LRESULT)0;
|
1106 |
|
|
|
1107 |
|
|
case WM_GETFONT:
|
1108 |
|
|
return lp->hFont;
|
1109 |
|
|
#endif /* WM_SETFONT/WM_GETFONT */
|
1110 |
|
|
|
1111 |
|
|
case WM_MOVE: /*WM_WINDOWPOSCHANGING:*/
|
1112 |
|
|
#if 0
|
1113 |
|
|
lpwp = (LPWINDOWPOS)lParam;
|
1114 |
|
|
#else
|
1115 |
|
|
pp.x=LOWORD(lParam);
|
1116 |
|
|
pp.y=HIWORD(lParam);
|
1117 |
|
|
#endif
|
1118 |
|
|
if (1)/*(lpwp)*/ {
|
1119 |
|
|
if (1)/*(!(lpwp->flags & SWP_NOSIZE))*/ {
|
1120 |
|
|
lp->ButtonRect.right = (hWnd->winrect.right-hWnd->winrect.left); /* lpwp->cx; */
|
1121 |
|
|
if ((lp->wStyle & 0xf) == CBS_SIMPLE)
|
1122 |
|
|
lp->ButtonRect.left = lp->ButtonRect.right;
|
1123 |
|
|
else lp->ButtonRect.left = (hWnd->winrect.right-hWnd->winrect.left)/*lpwp->cx*/ - 1 -
|
1124 |
|
|
GetSystemMetrics(SM_CXVSCROLL);
|
1125 |
|
|
|
1126 |
|
|
if (lp->EditControl)
|
1127 |
|
|
{
|
1128 |
|
|
wEditWidth = lp->ButtonRect.left + 1;
|
1129 |
|
|
if ((lp->wStyle & 0xf) == CBS_SIMPLE)
|
1130 |
|
|
wEditWidth --;
|
1131 |
|
|
if ((lp->wStyle & 0xf) == CBS_DROPDOWN)
|
1132 |
|
|
wEditWidth -= 5;
|
1133 |
|
|
SetWindowPos(lp->EditControl,(HWND)0,
|
1134 |
|
|
0,0,
|
1135 |
|
|
wEditWidth, lp->uHeight,
|
1136 |
|
|
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
|
1137 |
|
|
}
|
1138 |
|
|
if (lp->ListBoxControl)
|
1139 |
|
|
{
|
1140 |
|
|
if ((lp->wStyle & 0x0F) == CBS_SIMPLE)
|
1141 |
|
|
{
|
1142 |
|
|
lp->ListBoxRect.left = 5;
|
1143 |
|
|
lp->ListBoxRect.top = lp->uHeight - 1;
|
1144 |
|
|
lp->ListBoxRect.right = (hWnd->winrect.right-hWnd->winrect.left); /* lpwp->cx; */
|
1145 |
|
|
lp->ListBoxRect.bottom = (hWnd->winrect.bottom-hWnd->winrect.top)/*lpwp->cy*/ - 2;
|
1146 |
|
|
}
|
1147 |
|
|
else {
|
1148 |
|
|
POINT cp;
|
1149 |
|
|
cp.x = 0;
|
1150 |
|
|
cp.y = lp->uHeight - 1;
|
1151 |
|
|
ClientToScreen(hWnd, &cp);
|
1152 |
|
|
OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
|
1153 |
|
|
|
1154 |
|
|
lp->ListBoxRect.right = lp->ListBoxRect.left + (hWnd->winrect.right-hWnd->winrect.left)/*lpwp->cx*/;
|
1155 |
|
|
if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
|
1156 |
|
|
lp->ListBoxRect.right -= 5;
|
1157 |
|
|
}
|
1158 |
|
|
|
1159 |
|
|
SetWindowPos(lp->ListBoxControl,(HWND)0,
|
1160 |
|
|
lp->ListBoxRect.left, lp->ListBoxRect.top,
|
1161 |
|
|
lp->ListBoxRect.right - lp->ListBoxRect.left,
|
1162 |
|
|
lp->ListBoxRect.bottom - lp->ListBoxRect.top,
|
1163 |
|
|
SWP_NOACTIVATE|SWP_NOZORDER);
|
1164 |
|
|
}
|
1165 |
|
|
#if 0 /* jmt: fix: no WM_WINDOWPOSCHANGING */
|
1166 |
|
|
/* the height of the normal state stays the same */
|
1167 |
|
|
if ((lp->wStyle & 0xf) != CBS_SIMPLE)
|
1168 |
|
|
lpwp->cy = (int)lp->uHeight;
|
1169 |
|
|
#endif
|
1170 |
|
|
}
|
1171 |
|
|
}
|
1172 |
|
|
return (LRESULT)0;
|
1173 |
|
|
|
1174 |
|
|
case WM_WINDOWPOSCHANGED:
|
1175 |
|
|
DefWindowProc(hWnd,uMsg,wParam,lParam);
|
1176 |
|
|
lpwp = (LPWINDOWPOS)lParam;
|
1177 |
|
|
if (lpwp) {
|
1178 |
|
|
if (!(lpwp->flags & SWP_NOSIZE)) /* TODO */
|
1179 |
|
|
#if 0
|
1180 |
|
|
RedrawWindow(hWnd,(const RECT *)0,(HRGN)0,
|
1181 |
|
|
RDW_INVALIDATE|RDW_ERASE);
|
1182 |
|
|
#else
|
1183 |
|
|
InvalidateRect(hWnd,NULL,TRUE);
|
1184 |
|
|
#endif
|
1185 |
|
|
}
|
1186 |
|
|
return (LRESULT)0;
|
1187 |
|
|
|
1188 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
1189 |
|
|
/*********************************************/
|
1190 |
|
|
/* ownerdraw stuff */
|
1191 |
|
|
/*********************************************/
|
1192 |
|
|
case WM_DRAWITEM:
|
1193 |
|
|
lpdis = (LPDRAWITEMSTRUCT)lParam;
|
1194 |
|
|
lpdis->CtlType = ODT_COMBOBOX;
|
1195 |
|
|
lpdis->CtlID = lp->nID;
|
1196 |
|
|
lpdis->hwndItem = hWnd;
|
1197 |
|
|
return SendMessage(lp->hWndParent,WM_DRAWITEM,
|
1198 |
|
|
(WPARAM)lp->nID,lParam);
|
1199 |
|
|
|
1200 |
|
|
case WM_MEASUREITEM:
|
1201 |
|
|
lpmis = (LPMEASUREITEMSTRUCT)lParam;
|
1202 |
|
|
lpmis->CtlType = ODT_COMBOBOX;
|
1203 |
|
|
lpmis->CtlID = lp->nID;
|
1204 |
|
|
return SendMessage(lp->hWndParent,WM_MEASUREITEM,
|
1205 |
|
|
(WPARAM)lp->nID,lParam);
|
1206 |
|
|
|
1207 |
|
|
case WM_DELETEITEM:
|
1208 |
|
|
lpdlis = (LPDELETEITEMSTRUCT)lParam;
|
1209 |
|
|
lpdlis->CtlType = ODT_COMBOBOX;
|
1210 |
|
|
lpdlis->CtlID = lp->nID;
|
1211 |
|
|
lpdlis->hwndItem = hWnd;
|
1212 |
|
|
return SendMessage(lp->hWndParent,WM_DELETEITEM,
|
1213 |
|
|
(WPARAM)lp->nID,lParam);
|
1214 |
|
|
|
1215 |
|
|
case WM_CONVERT:
|
1216 |
|
|
if (!lpComboBinToNat) {
|
1217 |
|
|
hComboClass32 = FindClass("COMBOBOX",0);
|
1218 |
|
|
lpComboBinToNat = (WNDPROC)GetClassHandleLong(
|
1219 |
|
|
hComboClass32,GCL_BINTONAT);
|
1220 |
|
|
}
|
1221 |
|
|
if (lpComboBinToNat)
|
1222 |
|
|
return lpComboBinToNat(hWnd, uMsg, wParam, lParam);
|
1223 |
|
|
else
|
1224 |
|
|
return (LRESULT)0;
|
1225 |
|
|
#endif /* ownerdraw */
|
1226 |
|
|
|
1227 |
|
|
default:
|
1228 |
|
|
return DefCBProc( hWnd, uMsg, wParam, lParam);
|
1229 |
|
|
}
|
1230 |
|
|
return rc;
|
1231 |
|
|
}
|
1232 |
|
|
|
1233 |
|
|
/************************************************************************
|
1234 |
|
|
**
|
1235 |
|
|
************************************************************************/
|
1236 |
|
|
static LRESULT DefCBProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
1237 |
|
|
{
|
1238 |
|
|
int len,index;
|
1239 |
|
|
COMBOBOX *lp;
|
1240 |
|
|
char *selection;
|
1241 |
|
|
int rc;
|
1242 |
|
|
POINT cp;
|
1243 |
|
|
|
1244 |
|
|
lp = (COMBOBOX *) hWnd->userdata/*GetWindowLong(hWnd,CWD_LPCBDATA)*/;
|
1245 |
|
|
switch(uMsg) {
|
1246 |
|
|
/*********************************************/
|
1247 |
|
|
/* messages specific to the list box control */
|
1248 |
|
|
/*********************************************/
|
1249 |
|
|
case CB_ADDSTRING:
|
1250 |
|
|
lp->nListItems++; /* shd. test for successful return */
|
1251 |
|
|
return SendMessage(lp->ListBoxControl,LB_ADDSTRING,
|
1252 |
|
|
wParam,lParam);
|
1253 |
|
|
|
1254 |
|
|
case CB_DELETESTRING:
|
1255 |
|
|
if (lp->nListItems)
|
1256 |
|
|
lp->nListItems--;
|
1257 |
|
|
return SendMessage(lp->ListBoxControl,LB_DELETESTRING,
|
1258 |
|
|
wParam,lParam);
|
1259 |
|
|
|
1260 |
|
|
case CB_DIR:
|
1261 |
|
|
return SendMessage(lp->ListBoxControl,LB_DIR,
|
1262 |
|
|
wParam,lParam);
|
1263 |
|
|
|
1264 |
|
|
case CB_FINDSTRING:
|
1265 |
|
|
return SendMessage(lp->ListBoxControl,LB_FINDSTRING,
|
1266 |
|
|
wParam,lParam);
|
1267 |
|
|
|
1268 |
|
|
case CB_FINDSTRINGEXACT:
|
1269 |
|
|
return SendMessage(lp->ListBoxControl,LB_FINDSTRINGEXACT,
|
1270 |
|
|
wParam,lParam);
|
1271 |
|
|
|
1272 |
|
|
case CB_GETCOUNT:
|
1273 |
|
|
return SendMessage(lp->ListBoxControl,LB_GETCOUNT,
|
1274 |
|
|
wParam,lParam);
|
1275 |
|
|
|
1276 |
|
|
case CB_GETCURSEL:
|
1277 |
|
|
return SendMessage(lp->ListBoxControl,LB_GETCURSEL,
|
1278 |
|
|
wParam,lParam);
|
1279 |
|
|
|
1280 |
|
|
case CB_GETITEMDATA:
|
1281 |
|
|
return SendMessage(lp->ListBoxControl,LB_GETITEMDATA,
|
1282 |
|
|
wParam,lParam);
|
1283 |
|
|
|
1284 |
|
|
case CB_GETITEMHEIGHT:
|
1285 |
|
|
return SendMessage(lp->ListBoxControl,LB_GETITEMHEIGHT,
|
1286 |
|
|
wParam,lParam);
|
1287 |
|
|
|
1288 |
|
|
case CB_GETLBTEXT:
|
1289 |
|
|
return SendMessage(lp->ListBoxControl,LB_GETTEXT,
|
1290 |
|
|
wParam,lParam);
|
1291 |
|
|
|
1292 |
|
|
case CB_GETLBTEXTLEN:
|
1293 |
|
|
return SendMessage(lp->ListBoxControl,LB_GETTEXTLEN,
|
1294 |
|
|
wParam,lParam);
|
1295 |
|
|
|
1296 |
|
|
case CB_INSERTSTRING:
|
1297 |
|
|
return SendMessage(lp->ListBoxControl,LB_INSERTSTRING,
|
1298 |
|
|
wParam,lParam);
|
1299 |
|
|
|
1300 |
|
|
case CB_SETITEMDATA:
|
1301 |
|
|
return SendMessage(lp->ListBoxControl,LB_SETITEMDATA,
|
1302 |
|
|
wParam,lParam);
|
1303 |
|
|
|
1304 |
|
|
/*********************************************/
|
1305 |
|
|
/* messages specific to the edit control */
|
1306 |
|
|
/*********************************************/
|
1307 |
|
|
case CB_GETEDITSEL:
|
1308 |
|
|
return SendMessage(lp->EditControl,EM_GETSEL,0,0);
|
1309 |
|
|
|
1310 |
|
|
case CB_LIMITTEXT:
|
1311 |
|
|
return SendMessage(lp->EditControl,EM_LIMITTEXT,
|
1312 |
|
|
wParam,lParam);
|
1313 |
|
|
|
1314 |
|
|
case CB_SETEDITSEL:
|
1315 |
|
|
return SendMessage(lp->EditControl,EM_SETSEL,
|
1316 |
|
|
wParam,lParam);
|
1317 |
|
|
|
1318 |
|
|
/*********************************************/
|
1319 |
|
|
/* messages handled by the combobox */
|
1320 |
|
|
/*********************************************/
|
1321 |
|
|
case CB_GETDROPPEDCONTROLRECT:
|
1322 |
|
|
CopyRect((LPRECT)lParam,&lp->ListBoxRect);
|
1323 |
|
|
break;
|
1324 |
|
|
case CB_GETDROPPEDSTATE:
|
1325 |
|
|
return IS_SET(lp,CSF_CAPTUREACTIVE);
|
1326 |
|
|
|
1327 |
|
|
case CB_GETEXTENDEDUI:
|
1328 |
|
|
return (LRESULT)lp->bExtended;
|
1329 |
|
|
|
1330 |
|
|
case CB_RESETCONTENT:
|
1331 |
|
|
SendMessage(lp->ListBoxControl,LB_RESETCONTENT,0,0);
|
1332 |
|
|
if (lp->EditControl)
|
1333 |
|
|
SendMessage(lp->EditControl,WM_SETTEXT,0,(LPARAM)(LPSTR)"");
|
1334 |
|
|
break;
|
1335 |
|
|
|
1336 |
|
|
case CB_SELECTSTRING:
|
1337 |
|
|
index = (int)SendMessage(lp->ListBoxControl, LB_SELECTSTRING, wParam, lParam);
|
1338 |
|
|
if (index == LB_ERR)
|
1339 |
|
|
return CB_ERR;
|
1340 |
|
|
|
1341 |
|
|
len = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, index, 0);
|
1342 |
|
|
if (len <= 0)
|
1343 |
|
|
return CB_ERR;
|
1344 |
|
|
|
1345 |
|
|
selection = (LPSTR)WinMalloc((UINT)len+1);
|
1346 |
|
|
rc = (int)SendMessage(lp->ListBoxControl, LB_GETTEXT, (WPARAM)index, (LPARAM)selection);
|
1347 |
|
|
if (lp->EditControl)
|
1348 |
|
|
rc = (int)SendMessage(lp->EditControl, WM_SETTEXT, 0, (LPARAM)selection);
|
1349 |
|
|
else CBoxDrawStatic(lp, hWnd, index);
|
1350 |
|
|
WinFree(selection);
|
1351 |
|
|
break;
|
1352 |
|
|
|
1353 |
|
|
case CB_SETCURSEL:
|
1354 |
|
|
rc = (int)SendMessage(lp->ListBoxControl, LB_SETCURSEL, wParam, lParam);
|
1355 |
|
|
if (rc == LB_ERR)
|
1356 |
|
|
return CB_ERR;
|
1357 |
|
|
len = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, wParam, 0);
|
1358 |
|
|
if (len <= 0)
|
1359 |
|
|
return CB_ERR;
|
1360 |
|
|
|
1361 |
|
|
selection = (LPSTR)WinMalloc((UINT)len+1);
|
1362 |
|
|
rc = (int)SendMessage(lp->ListBoxControl, LB_GETTEXT, wParam, (LPARAM)selection);
|
1363 |
|
|
if (lp->EditControl)
|
1364 |
|
|
rc = (int)SendMessage(lp->EditControl, WM_SETTEXT, 0, (LPARAM)selection);
|
1365 |
|
|
else CBoxDrawStatic(lp, hWnd, wParam);
|
1366 |
|
|
WinFree(selection);
|
1367 |
|
|
return (LRESULT)wParam;
|
1368 |
|
|
|
1369 |
|
|
case CB_SETEXTENDEDUI:
|
1370 |
|
|
lp->bExtended = (BOOL)wParam;
|
1371 |
|
|
break;
|
1372 |
|
|
|
1373 |
|
|
case CB_SETITEMHEIGHT: /* TODO */
|
1374 |
|
|
break;
|
1375 |
|
|
|
1376 |
|
|
case CB_SHOWDROPDOWN:
|
1377 |
|
|
if ((lp->wStyle & 0xf) == CBS_SIMPLE)
|
1378 |
|
|
return 1L;
|
1379 |
|
|
if (wParam)
|
1380 |
|
|
{
|
1381 |
|
|
if (IS_SET(lp,CSF_CAPTUREACTIVE))
|
1382 |
|
|
return 1L;
|
1383 |
|
|
|
1384 |
|
|
cp.x = ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST) ? 5 : 0;
|
1385 |
|
|
cp.y = lp->uHeight -1;
|
1386 |
|
|
|
1387 |
|
|
ClientToScreen(hWnd, &cp);
|
1388 |
|
|
OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
|
1389 |
|
|
|
1390 |
|
|
SetWindowPos(lp->ListBoxControl, 0,
|
1391 |
|
|
cp.x, cp.y, 0, 0,
|
1392 |
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
1393 |
|
|
|
1394 |
|
|
SendMessage(lp->hWndParent,WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_DROPDOWN));
|
1395 |
|
|
|
1396 |
|
|
fprintf(stderr," 1330: SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
|
1397 |
|
|
|
1398 |
|
|
SetWindowPos(lp->ListBoxControl, HWND_TOP,
|
1399 |
|
|
0, 0, 0, 0,
|
1400 |
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
|
1401 |
|
|
|
1402 |
|
|
CBoxCapture(hWnd, 1);
|
1403 |
|
|
SET_STATE(lp,CSF_CAPTUREACTIVE);
|
1404 |
|
|
}
|
1405 |
|
|
else
|
1406 |
|
|
{
|
1407 |
|
|
if (!IS_SET(lp,CSF_CAPTUREACTIVE))
|
1408 |
|
|
return 1L;
|
1409 |
|
|
|
1410 |
|
|
SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
|
1411 |
|
|
/* test: */
|
1412 |
|
|
fprintf(stderr," 1343: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
|
1413 |
|
|
|
1414 |
|
|
SetWindowPos(lp->ListBoxControl, 0,
|
1415 |
|
|
0, 0, 0, 0,
|
1416 |
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
|
1417 |
|
|
|
1418 |
|
|
CBoxCapture(hWnd, 0);
|
1419 |
|
|
CLEAR_STATE(lp, CSF_CAPTUREACTIVE);
|
1420 |
|
|
}
|
1421 |
|
|
return 1L;
|
1422 |
|
|
|
1423 |
|
|
/*********************************************/
|
1424 |
|
|
/* messages handled by the defwindowproc.... */
|
1425 |
|
|
/*********************************************/
|
1426 |
|
|
default:
|
1427 |
|
|
return DefWindowProc( hWnd, uMsg, wParam, lParam);
|
1428 |
|
|
}
|
1429 |
|
|
return CB_OKAY;
|
1430 |
|
|
}
|
1431 |
|
|
|
1432 |
|
|
|
1433 |
|
|
static void
|
1434 |
|
|
CBoxDrawButton(HWND hWnd,UINT wState,COMBOBOX *lp)
|
1435 |
|
|
{
|
1436 |
|
|
HDC hDC;
|
1437 |
|
|
int x,y;
|
1438 |
|
|
int dx,dy;
|
1439 |
|
|
#if 0 /* jmt: fix: no LoadBitmap() */
|
1440 |
|
|
int cx,cy;
|
1441 |
|
|
static int nWidth,nHeight;
|
1442 |
|
|
BITMAP bmpCombo;
|
1443 |
|
|
static HBITMAP hbmpCombo = 0;
|
1444 |
|
|
HBITMAP hbmpOld = 0;
|
1445 |
|
|
HDC hdcSrc;
|
1446 |
|
|
COLORREF rgbText, rgbBk;
|
1447 |
|
|
#endif
|
1448 |
|
|
HBRUSH hBrush;
|
1449 |
|
|
HPEN hPenHigh,hPenShadow;
|
1450 |
|
|
RECT rc;
|
1451 |
|
|
|
1452 |
|
|
hDC = GetDC(hWnd);
|
1453 |
|
|
|
1454 |
|
|
CopyRect(&rc,&lp->ButtonRect);
|
1455 |
|
|
x = rc.left;
|
1456 |
|
|
y = rc.top;
|
1457 |
|
|
dx = rc.right;
|
1458 |
|
|
dy = rc.bottom;
|
1459 |
|
|
|
1460 |
|
|
hPenHigh = GetStockObject(WHITE_PEN);
|
1461 |
|
|
#if 0
|
1462 |
|
|
hPenShadow = GetSysColorPen(COLOR_BTNSHADOW);
|
1463 |
|
|
#else
|
1464 |
|
|
hPenShadow = CreatePen(PS_SOLID,1,GetSysColor(COLOR_BTNSHADOW));
|
1465 |
|
|
#endif
|
1466 |
|
|
#if 0
|
1467 |
|
|
hBrush = GetSysColorBrush(COLOR_BTNFACE);
|
1468 |
|
|
#else
|
1469 |
|
|
hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
|
1470 |
|
|
#endif
|
1471 |
|
|
FillRect(hDC, &rc, hBrush);
|
1472 |
|
|
#if 0
|
1473 |
|
|
hBrush = GetStockObject(BLACK_BRUSH);
|
1474 |
|
|
FillRect/*FrameRect*/(hDC, &lp->ButtonRect, hBrush);
|
1475 |
|
|
#else
|
1476 |
|
|
SelectObject(hDC,GetStockObject(BLACK_PEN));
|
1477 |
|
|
Rectangle(hDC,lp->ButtonRect.left,lp->ButtonRect.top,lp->ButtonRect.right,lp->ButtonRect.bottom);
|
1478 |
|
|
#endif
|
1479 |
|
|
rc.left += 1; rc.right -= 1;
|
1480 |
|
|
rc.top += 1; rc.bottom -= 1;
|
1481 |
|
|
|
1482 |
|
|
Draw3DButtonRect(hDC,hPenHigh,hPenShadow,rc,wState);
|
1483 |
|
|
|
1484 |
|
|
#if 0 /* jmt: fix: no LoadBitmap(),GetObject() */
|
1485 |
|
|
if (hbmpCombo == 0)
|
1486 |
|
|
{
|
1487 |
|
|
hbmpCombo = LoadBitmap(0,(LPSTR)OBM_COMBO);
|
1488 |
|
|
GetObject(hbmpCombo, sizeof(BITMAP), (LPVOID)&bmpCombo);
|
1489 |
|
|
nWidth = bmpCombo.bmWidth;
|
1490 |
|
|
nHeight = bmpCombo.bmHeight;
|
1491 |
|
|
}
|
1492 |
|
|
/*
|
1493 |
|
|
** MiD 08/15/95 changed to mono bitmap as it is in Windows. Convert
|
1494 |
|
|
** it to colors on the fly
|
1495 |
|
|
*/
|
1496 |
|
|
hdcSrc = CreateCompatibleDC(hDC);
|
1497 |
|
|
hbmpOld = SelectObject(hdcSrc, hbmpCombo);
|
1498 |
|
|
/*
|
1499 |
|
|
** Source hdc ok. Prepare the target hdc, then BitBlt to it.
|
1500 |
|
|
*/
|
1501 |
|
|
rgbText = SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT));
|
1502 |
|
|
rgbBk = SetBkColor(hDC,GetSysColor(COLOR_BTNFACE));
|
1503 |
|
|
|
1504 |
|
|
cx = (dx - x - nWidth)/2;
|
1505 |
|
|
cy = (dy - y - nHeight)/2;
|
1506 |
|
|
if (wState)
|
1507 |
|
|
{ cx++; cy++; }
|
1508 |
|
|
BitBlt(hDC, x+cx, y+cy, nWidth, nHeight, hdcSrc, 0, 0, SRCCOPY);
|
1509 |
|
|
|
1510 |
|
|
SetTextColor(hDC, rgbText);
|
1511 |
|
|
SetBkColor(hDC, rgbBk);
|
1512 |
|
|
SelectObject(hdcSrc,hbmpOld);
|
1513 |
|
|
DeleteDC(hdcSrc);
|
1514 |
|
|
#endif /* BitBlt Bitmap */
|
1515 |
|
|
#if 1
|
1516 |
|
|
DeleteObject(hBrush);
|
1517 |
|
|
DeleteObject(hPenShadow);
|
1518 |
|
|
#endif
|
1519 |
|
|
ReleaseDC(hWnd,hDC);
|
1520 |
|
|
|
1521 |
|
|
if (wState)
|
1522 |
|
|
SET_STATE(lp,CSF_LOCALBUTTONDOWN);
|
1523 |
|
|
else
|
1524 |
|
|
CLEAR_STATE(lp,CSF_LOCALBUTTONDOWN);
|
1525 |
|
|
}
|
1526 |
|
|
|
1527 |
|
|
#if 0 /* jmt: fix: no COMBOLBOX */
|
1528 |
|
|
/************************************************************************
|
1529 |
|
|
**
|
1530 |
|
|
************************************************************************/
|
1531 |
|
|
LRESULT DefCOMBOLBOXProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
1532 |
|
|
{
|
1533 |
|
|
#if 0
|
1534 |
|
|
return DefLISTBOXProc(hWnd, msg, wParam,lParam);
|
1535 |
|
|
#endif
|
1536 |
|
|
return ListboxCtrlProc(hWnd, msg, wParam,lParam);
|
1537 |
|
|
}
|
1538 |
|
|
#endif
|
1539 |
|
|
|
1540 |
|
|
/************************************************************************
|
1541 |
|
|
**
|
1542 |
|
|
************************************************************************/
|
1543 |
|
|
static void CBoxSendMouseToLBox(COMBOBOX *lp, UINT uiMsg, WPARAM wParam, POINT ptScreen)
|
1544 |
|
|
{
|
1545 |
|
|
POINT pt;
|
1546 |
|
|
int nNCHit;
|
1547 |
|
|
#if 0 /* jmt: fix: no scrollbar */
|
1548 |
|
|
HWND hWndScroll;
|
1549 |
|
|
#endif
|
1550 |
|
|
pt = ptScreen;
|
1551 |
|
|
ScreenToClient(lp->ListBoxControl,&pt);
|
1552 |
|
|
|
1553 |
|
|
nNCHit = LOSHORT(SendMessage(lp->ListBoxControl, WM_NCHITTEST, 0, MAKELPARAM(ptScreen.x,ptScreen.y)));
|
1554 |
|
|
|
1555 |
|
|
switch (nNCHit)
|
1556 |
|
|
{
|
1557 |
|
|
case HTCLIENT:
|
1558 |
|
|
if (uiMsg == WM_MOUSEMOVE && !IS_SET(lp,CSF_LBOXBUTTONDOWN))
|
1559 |
|
|
{
|
1560 |
|
|
SendMessage(lp->ListBoxControl, WM_LBUTTONDOWN, 0, MAKELONG((WORD)pt.x,(WORD)pt.y));
|
1561 |
|
|
|
1562 |
|
|
SET_STATE(lp, CSF_BUTTONDOWN | CSF_LBOXBUTTONDOWN);
|
1563 |
|
|
}
|
1564 |
|
|
SendMessage(lp->ListBoxControl, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
|
1565 |
|
|
break;
|
1566 |
|
|
|
1567 |
|
|
#if 0 /* jmt: fix: no scrollbar */
|
1568 |
|
|
case HTVSCROLL:
|
1569 |
|
|
if (0 != (hWndScroll = TWIN_ConvertToSysScroll(lp->ListBoxControl, TRUE /* vertical */, &pt)))
|
1570 |
|
|
SendMessage(hWndScroll, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
|
1571 |
|
|
break;
|
1572 |
|
|
#endif
|
1573 |
|
|
default:
|
1574 |
|
|
break;
|
1575 |
|
|
}
|
1576 |
|
|
}
|
1577 |
|
|
|
1578 |
|
|
/************************************************************************
|
1579 |
|
|
**
|
1580 |
|
|
************************************************************************/
|
1581 |
|
|
static void CBoxCapture(HWND hWnd, WORD wFunc)
|
1582 |
|
|
{
|
1583 |
|
|
static HWND hWndCapture = (HWND)0;
|
1584 |
|
|
|
1585 |
|
|
if (wFunc)
|
1586 |
|
|
{
|
1587 |
|
|
hWndCapture = SetCapture(hWnd);
|
1588 |
|
|
|
1589 |
|
|
SetFocus(hWnd);
|
1590 |
|
|
}
|
1591 |
|
|
else {
|
1592 |
|
|
if (!hWndCapture)
|
1593 |
|
|
ReleaseCapture();
|
1594 |
|
|
else {
|
1595 |
|
|
#ifdef LATER
|
1596 |
|
|
SetCapture(hWndCapture);
|
1597 |
|
|
#else
|
1598 |
|
|
ReleaseCapture();
|
1599 |
|
|
#endif
|
1600 |
|
|
hWndCapture = (HWND)0;
|
1601 |
|
|
}
|
1602 |
|
|
}
|
1603 |
|
|
}
|
1604 |
|
|
|
1605 |
|
|
/************************************************************************
|
1606 |
|
|
**
|
1607 |
|
|
************************************************************************/
|
1608 |
|
|
static void CBoxDrawEdit(COMBOBOX *lp, HWND hWnd, UINT uiKey)
|
1609 |
|
|
{
|
1610 |
|
|
int nLen;
|
1611 |
|
|
LPVOID lpData;
|
1612 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
1613 |
|
|
HRGN hRgn;
|
1614 |
|
|
DRAWITEMSTRUCT dis;
|
1615 |
|
|
#endif
|
1616 |
|
|
/*
|
1617 |
|
|
if (uiKey == (UINT)LB_ERR)
|
1618 |
|
|
return;
|
1619 |
|
|
|
1620 |
|
|
if (!BOWNERDRAW(lp))
|
1621 |
|
|
*/
|
1622 |
|
|
if (lp->wStyle & CBS_HASSTRINGS)
|
1623 |
|
|
{
|
1624 |
|
|
if (uiKey == (UINT)LB_ERR)
|
1625 |
|
|
return;
|
1626 |
|
|
nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, uiKey, 0L);
|
1627 |
|
|
if (nLen <= 0)
|
1628 |
|
|
return;
|
1629 |
|
|
lpData = (LPVOID)WinMalloc(nLen+1);
|
1630 |
|
|
SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
|
1631 |
|
|
SendMessage(lp->EditControl, WM_SETTEXT, strlen(lpData), (LPARAM)lpData);
|
1632 |
|
|
Edit_SetSel(lp->EditControl, 0, -1);
|
1633 |
|
|
WinFree((LPSTR)lpData);
|
1634 |
|
|
}
|
1635 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
1636 |
|
|
else {
|
1637 |
|
|
dis.CtlType = ODT_COMBOBOX;
|
1638 |
|
|
dis.CtlID = (UINT)lp->nID;
|
1639 |
|
|
dis.itemID = -1; /* used to be uiKey */
|
1640 |
|
|
dis.itemAction = ODA_DRAWENTIRE;
|
1641 |
|
|
dis.itemState = ODS_FOCUS;
|
1642 |
|
|
dis.hwndItem = hWnd;
|
1643 |
|
|
dis.itemData = 0;
|
1644 |
|
|
GetClientRect(lp->EditControl,&dis.rcItem);
|
1645 |
|
|
dis.rcItem.left += 3;
|
1646 |
|
|
dis.rcItem.right -= 3;
|
1647 |
|
|
dis.rcItem.top += 2;
|
1648 |
|
|
dis.rcItem.bottom -= 2;
|
1649 |
|
|
|
1650 |
|
|
dis.hDC = GetDC(lp->EditControl);
|
1651 |
|
|
hRgn = CreateRectRgnIndirect(&dis.rcItem);
|
1652 |
|
|
SelectClipRgn(dis.hDC,hRgn);
|
1653 |
|
|
SelectObject(dis.hDC, lp->hFont);
|
1654 |
|
|
SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
|
1655 |
|
|
ReleaseDC(lp->EditControl,dis.hDC);
|
1656 |
|
|
DeleteObject(hRgn);
|
1657 |
|
|
}
|
1658 |
|
|
#endif /* ownerdraw */
|
1659 |
|
|
}
|
1660 |
|
|
|
1661 |
|
|
/************************************************************************
|
1662 |
|
|
**
|
1663 |
|
|
************************************************************************/
|
1664 |
|
|
static void CBoxDrawStatic(COMBOBOX *lp, HWND hWnd, UINT uiKey)
|
1665 |
|
|
{
|
1666 |
|
|
int nLen;
|
1667 |
|
|
HDC hdc;
|
1668 |
|
|
LPVOID lpData;
|
1669 |
|
|
RECT rcClient;
|
1670 |
|
|
HFONT hfonOld = 0;
|
1671 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
1672 |
|
|
HRGN hRgn;
|
1673 |
|
|
DRAWITEMSTRUCT dis;
|
1674 |
|
|
#endif
|
1675 |
|
|
HBRUSH hbrStatic, hbrOld;
|
1676 |
|
|
|
1677 |
|
|
/* Draw rectangle regardless of ownerdraw style...
|
1678 |
|
|
*/
|
1679 |
|
|
hdc = GetDC(hWnd);
|
1680 |
|
|
rcClient.left = 0;
|
1681 |
|
|
rcClient.top = 0;
|
1682 |
|
|
rcClient.right = lp->ButtonRect.left+1;
|
1683 |
|
|
rcClient.bottom = lp->uHeight;
|
1684 |
|
|
hbrStatic = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
|
1685 |
|
|
hbrOld = SelectObject(hdc, hbrStatic);
|
1686 |
|
|
SelectObject(hdc, GetStockObject(BLACK_PEN));/* ??? COLOR_WINDOWFRAME */
|
1687 |
|
|
Rectangle(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
|
1688 |
|
|
SelectObject(hdc, hbrOld);
|
1689 |
|
|
DeleteObject(hbrStatic);
|
1690 |
|
|
ReleaseDC(hWnd, hdc);
|
1691 |
|
|
|
1692 |
|
|
if (uiKey == (UINT)LB_ERR)
|
1693 |
|
|
return;
|
1694 |
|
|
|
1695 |
|
|
/* jmt: no ownerdraw */
|
1696 |
|
|
if (1) /* (!BOWNERDRAW(lp)) */
|
1697 |
|
|
{
|
1698 |
|
|
/* if necessary, draw text */
|
1699 |
|
|
hdc = GetDC(hWnd);
|
1700 |
|
|
nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, (WPARAM)uiKey, 0L);
|
1701 |
|
|
if (nLen > 0)
|
1702 |
|
|
{
|
1703 |
|
|
lpData = (LPVOID)WinMalloc(nLen+1);
|
1704 |
|
|
SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
|
1705 |
|
|
SetBkMode(hdc, TRANSPARENT);
|
1706 |
|
|
if (!IS_SET(lp, CSF_FOCUS))
|
1707 |
|
|
{
|
1708 |
|
|
SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
1709 |
|
|
rcClient.left += 2;
|
1710 |
|
|
}
|
1711 |
|
|
else {
|
1712 |
|
|
InflateRect(&rcClient, -2, -2);
|
1713 |
|
|
hbrStatic = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
|
1714 |
|
|
hbrOld = SelectObject(hdc, hbrStatic);
|
1715 |
|
|
FillRect(hdc, &rcClient, hbrStatic);
|
1716 |
|
|
#if 0 /* jmt: fix: no DrawFocusRect() */
|
1717 |
|
|
DrawFocusRect(hdc, &rcClient);
|
1718 |
|
|
#endif
|
1719 |
|
|
SelectObject(hdc, hbrOld);
|
1720 |
|
|
DeleteObject(hbrStatic);
|
1721 |
|
|
SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
1722 |
|
|
}
|
1723 |
|
|
if (lp->hFont)
|
1724 |
|
|
hfonOld = SelectObject(hdc, lp->hFont);
|
1725 |
|
|
DrawText(hdc, (LPSTR)lpData, nLen, &rcClient, DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
|
1726 |
|
|
if (lp->hFont)
|
1727 |
|
|
SelectObject(hdc, hfonOld);
|
1728 |
|
|
WinFree((LPVOID)lpData);
|
1729 |
|
|
}
|
1730 |
|
|
ReleaseDC(hWnd, hdc);
|
1731 |
|
|
}
|
1732 |
|
|
#if 0 /* jmt: fix: no ownerdraw */
|
1733 |
|
|
else { /* fill OWNERDRAWSTRUCT and send WM_DRAWITEM message */
|
1734 |
|
|
dis.CtlType = ODT_COMBOBOX;
|
1735 |
|
|
dis.CtlID = (UINT)lp->nID;
|
1736 |
|
|
dis.itemID = uiKey;
|
1737 |
|
|
dis.itemAction = ODA_DRAWENTIRE;
|
1738 |
|
|
dis.itemState = ODS_FOCUS;
|
1739 |
|
|
dis.hwndItem = hWnd;
|
1740 |
|
|
dis.itemData = SendMessage(lp->ListBoxControl, LB_GETITEMDATA, uiKey, 0L);
|
1741 |
|
|
GetClientRect(hWnd, &dis.rcItem);
|
1742 |
|
|
dis.rcItem.left += 3;
|
1743 |
|
|
dis.rcItem.right = lp->ButtonRect.left - 2; /* do not touch button */
|
1744 |
|
|
dis.rcItem.top += 2;
|
1745 |
|
|
dis.rcItem.bottom -= 2;
|
1746 |
|
|
|
1747 |
|
|
dis.hDC = GetDC(hWnd);
|
1748 |
|
|
hRgn = CreateRectRgnIndirect(&dis.rcItem);
|
1749 |
|
|
SelectClipRgn(dis.hDC, hRgn);
|
1750 |
|
|
SelectObject(dis.hDC, lp->hFont);
|
1751 |
|
|
SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
|
1752 |
|
|
ReleaseDC(hWnd, dis.hDC);
|
1753 |
|
|
DeleteObject(hRgn);
|
1754 |
|
|
}
|
1755 |
|
|
#endif /* ownerdraw */
|
1756 |
|
|
|
1757 |
|
|
}
|
1758 |
|
|
|
1759 |
|
|
|
1760 |
|
|
/*------------------------- < Full Revision History > ----------------------
|
1761 |
|
|
** Revision 1.2 2001/11/06 23:35:46 greg
|
1762 |
|
|
**
|
1763 |
|
|
** Revision 1.1.1.1 2001/06/21 06:32:42 greg
|
1764 |
|
|
** Microwindows pre8 with patches
|
1765 |
|
|
**
|
1766 |
|
|
** Revision 1.1.1.1 2001/06/05 03:44:01 root
|
1767 |
|
|
** First import of 5/5/2001 Microwindows to CVS
|
1768 |
|
|
**
|
1769 |
|
|
** Revision 1.8 2000/08/14 jmt
|
1770 |
|
|
** ported to microwin(non-client/server mode)
|
1771 |
|
|
**
|
1772 |
|
|
** Revision 1.7 2000/06/28 jmt
|
1773 |
|
|
** porting to microwin
|
1774 |
|
|
**
|
1775 |
|
|
** Revision 1.6 2000/01/21 02:48:47 robf
|
1776 |
|
|
** remove dead code
|
1777 |
|
|
**
|
1778 |
|
|
** Revision 1.5 1999/11/29 05:07:54 robf
|
1779 |
|
|
** removed extraneous call CreateCompatibleDC
|
1780 |
|
|
**
|
1781 |
|
|
** Revision 1.4 1999/07/08 18:52:50 mwalsh
|
1782 |
|
|
** Updated Comments
|
1783 |
|
|
**
|
1784 |
|
|
**-------------------------------------------------------------------------*/
|
1785 |
|
|
|