1 | /* $Id: static.cpp,v 1.28 2002-11-22 12:57:34 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Static control
|
---|
4 | *
|
---|
5 | * Copyright 1999 Christoph Bratschi
|
---|
6 | *
|
---|
7 | * Copyright David W. Metcalfe, 1993
|
---|
8 | *
|
---|
9 | * Corel version: 20000317
|
---|
10 | * (WINE version: 990923)
|
---|
11 | *
|
---|
12 | * SvL:
|
---|
13 | * SS_REALSIZEIMAGE is supposed to prevent control resizing, but that doesn't
|
---|
14 | * appear to happen in NT (although the SDK docs are very clear about this)
|
---|
15 | * Need to figure out why. (not resizing messes up the bitmap control in
|
---|
16 | * the Microsoft Visual C++ 4.2 install program)
|
---|
17 | * Same thing happens with a very simply test app, so the installer
|
---|
18 | * does nothing special.
|
---|
19 | *
|
---|
20 | *
|
---|
21 | * Status: complete
|
---|
22 | * Version: 5.00
|
---|
23 | */
|
---|
24 |
|
---|
25 | #include <stdlib.h>
|
---|
26 | #include <string.h>
|
---|
27 | #include <os2win.h>
|
---|
28 | #include "controls.h"
|
---|
29 | #include "static.h"
|
---|
30 |
|
---|
31 | #define DBG_LOCALLOG DBG_static
|
---|
32 | #include "dbglocal.h"
|
---|
33 |
|
---|
34 | //Prototypes
|
---|
35 |
|
---|
36 | static void STATIC_PaintTextfn( HWND hwnd, HDC hdc );
|
---|
37 | static void STATIC_PaintRectfn( HWND hwnd, HDC hdc );
|
---|
38 | static void STATIC_PaintIconfn( HWND hwnd, HDC hdc );
|
---|
39 | static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc );
|
---|
40 | static void STATIC_PaintMetafilefn(HWND hwnd,HDC hdc);
|
---|
41 | static void STATIC_PaintOwnerDrawfn(HWND hwnd,HDC hdc);
|
---|
42 | static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc );
|
---|
43 |
|
---|
44 | static COLORREF color_windowframe, color_background, color_window;
|
---|
45 |
|
---|
46 |
|
---|
47 | typedef void (*pfPaint)( HWND, HDC );
|
---|
48 |
|
---|
49 | static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
|
---|
50 | {
|
---|
51 | STATIC_PaintTextfn, /* SS_LEFT */
|
---|
52 | STATIC_PaintTextfn, /* SS_CENTER */
|
---|
53 | STATIC_PaintTextfn, /* SS_RIGHT */
|
---|
54 | STATIC_PaintIconfn, /* SS_ICON */
|
---|
55 | STATIC_PaintRectfn, /* SS_BLACKRECT */
|
---|
56 | STATIC_PaintRectfn, /* SS_GRAYRECT */
|
---|
57 | STATIC_PaintRectfn, /* SS_WHITERECT */
|
---|
58 | STATIC_PaintRectfn, /* SS_BLACKFRAME */
|
---|
59 | STATIC_PaintRectfn, /* SS_GRAYFRAME */
|
---|
60 | STATIC_PaintRectfn, /* SS_WHITEFRAME */
|
---|
61 | NULL, /* SS_USERITEM */
|
---|
62 | STATIC_PaintTextfn, /* SS_SIMPLE */
|
---|
63 | STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
|
---|
64 | STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
|
---|
65 | STATIC_PaintBitmapfn, /* SS_BITMAP */
|
---|
66 | STATIC_PaintMetafilefn, /* SS_ENHMETAFILE */
|
---|
67 | STATIC_PaintEtchedfn, /* SS_ETCHEDHORIZ */
|
---|
68 | STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
|
---|
69 | STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
|
---|
70 | };
|
---|
71 |
|
---|
72 | static void STATIC_ResizeWindow(HWND hwnd,DWORD dwStyle,INT w,INT h)
|
---|
73 | {
|
---|
74 | if (dwStyle & SS_RIGHTJUST)
|
---|
75 | {
|
---|
76 | RECT rect;
|
---|
77 |
|
---|
78 | GetWindowRect(hwnd,&rect);
|
---|
79 | SetWindowPos(hwnd,0,rect.right-w,rect.bottom-h,w,h,SWP_NOACTIVATE | SWP_NOZORDER);
|
---|
80 | } else SetWindowPos(hwnd,0,0,0,w,h,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
---|
81 | }
|
---|
82 |
|
---|
83 | /***********************************************************************
|
---|
84 | * STATIC_SetIcon
|
---|
85 | *
|
---|
86 | * Set the icon for an SS_ICON control.
|
---|
87 | */
|
---|
88 | static HICON STATIC_SetIcon( HWND hwnd, HICON hicon )
|
---|
89 | {
|
---|
90 | HICON prevIcon;
|
---|
91 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
|
---|
92 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
93 | ICONINFO ii;
|
---|
94 | BITMAP bmp;
|
---|
95 |
|
---|
96 | if (infoPtr == NULL)
|
---|
97 | return 0;
|
---|
98 |
|
---|
99 | if ((dwStyle & SS_TYPEMASK) != SS_ICON) return 0;
|
---|
100 |
|
---|
101 | prevIcon = infoPtr->hIcon;
|
---|
102 | infoPtr->hIcon = hicon;
|
---|
103 |
|
---|
104 | if (!GetIconInfo(hicon,&ii)) return prevIcon;
|
---|
105 | if (ii.hbmColor)
|
---|
106 | GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
|
---|
107 | else
|
---|
108 | {
|
---|
109 | GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp);
|
---|
110 | bmp.bmHeight /= 2;
|
---|
111 | }
|
---|
112 |
|
---|
113 | #if 1
|
---|
114 | //SvL: Breaks MS Visual C++ install dialogs with static controls (no resize)
|
---|
115 | if (!(dwStyle & (SS_CENTERIMAGE))) STATIC_ResizeWindow(hwnd,dwStyle,bmp.bmWidth,bmp.bmHeight);
|
---|
116 | #else
|
---|
117 | if (!(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE))) STATIC_ResizeWindow(hwnd,dwStyle,bmp.bmWidth,bmp.bmHeight);
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | if (ii.hbmColor) DeleteObject(ii.hbmColor);
|
---|
121 | if (ii.hbmMask) DeleteObject(ii.hbmMask);
|
---|
122 |
|
---|
123 | return prevIcon;
|
---|
124 | }
|
---|
125 |
|
---|
126 | /***********************************************************************
|
---|
127 | * STATIC_SetBitmap
|
---|
128 | *
|
---|
129 | * Set the bitmap for an SS_BITMAP control.
|
---|
130 | */
|
---|
131 | static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap )
|
---|
132 | {
|
---|
133 | HBITMAP hOldBitmap;
|
---|
134 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
|
---|
135 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
136 |
|
---|
137 | if (infoPtr == NULL)
|
---|
138 | return 0;
|
---|
139 |
|
---|
140 | if ((dwStyle & SS_TYPEMASK) != SS_BITMAP) return 0;
|
---|
141 |
|
---|
142 | if (hBitmap && (GetObjectType(hBitmap) != OBJ_BITMAP)) {
|
---|
143 | //ERR("huh? hBitmap!=0, but not bitmap\n");
|
---|
144 | return 0;
|
---|
145 | }
|
---|
146 | hOldBitmap = infoPtr->hIcon;
|
---|
147 | infoPtr->hIcon = hBitmap;
|
---|
148 | #if 1
|
---|
149 | //SvL: Breaks MS Visual C++ install dialogs with static controls (no resize)
|
---|
150 | if (hBitmap && !(dwStyle & (SS_CENTERIMAGE)))
|
---|
151 | #else
|
---|
152 | if (hBitmap && !(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE)))
|
---|
153 | #endif
|
---|
154 | {
|
---|
155 | BITMAP bm;
|
---|
156 |
|
---|
157 | GetObjectA(hBitmap,sizeof(bm),&bm);
|
---|
158 | STATIC_ResizeWindow(hwnd,dwStyle,bm.bmWidth,bm.bmHeight);
|
---|
159 | }
|
---|
160 |
|
---|
161 | return hOldBitmap;
|
---|
162 | }
|
---|
163 |
|
---|
164 | static HENHMETAFILE STATIC_SetMetafile(HWND hwnd,HENHMETAFILE hMetafile)
|
---|
165 | {
|
---|
166 | HENHMETAFILE hOldMetafile;
|
---|
167 |
|
---|
168 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
|
---|
169 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
170 |
|
---|
171 | if ((dwStyle & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
|
---|
172 |
|
---|
173 | hOldMetafile = infoPtr->hIcon;
|
---|
174 | infoPtr->hIcon = hMetafile;
|
---|
175 |
|
---|
176 | return hOldMetafile;
|
---|
177 | }
|
---|
178 |
|
---|
179 | /***********************************************************************
|
---|
180 | * STATIC_LoadIcon
|
---|
181 | *
|
---|
182 | * Load the icon for an SS_ICON control.
|
---|
183 | */
|
---|
184 | static HICON STATIC_LoadIcon( HWND hwnd, LPCSTR name )
|
---|
185 | {
|
---|
186 | HICON hicon;
|
---|
187 |
|
---|
188 | hicon = LoadIconA(GetWindowLongA(hwnd,GWL_HINSTANCE),name);
|
---|
189 |
|
---|
190 | if (!hicon)
|
---|
191 | hicon = LoadIconA(0, name);
|
---|
192 |
|
---|
193 | return hicon;
|
---|
194 | }
|
---|
195 |
|
---|
196 | /***********************************************************************
|
---|
197 | * STATIC_LoadBitmap
|
---|
198 | *
|
---|
199 | * Load the bitmap for an SS_BITMAP control.
|
---|
200 | */
|
---|
201 | static HBITMAP STATIC_LoadBitmap( HWND hwnd, LPCSTR name )
|
---|
202 | {
|
---|
203 | HBITMAP hbitmap;
|
---|
204 |
|
---|
205 | hbitmap = LoadBitmapA(GetWindowLongA(hwnd,GWL_HINSTANCE),name);
|
---|
206 |
|
---|
207 | if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */
|
---|
208 | hbitmap = LoadBitmapA(0,name);
|
---|
209 |
|
---|
210 | return hbitmap;
|
---|
211 | }
|
---|
212 |
|
---|
213 | static HBITMAP STATIC_LoadMetafile(HWND hwnd,LPCSTR name)
|
---|
214 | {
|
---|
215 | HENHMETAFILE hMetafile;
|
---|
216 |
|
---|
217 | hMetafile = GetEnhMetaFileA(name); //CB: right?
|
---|
218 |
|
---|
219 | return hMetafile;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /* message handler */
|
---|
223 |
|
---|
224 | LRESULT STATIC_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
225 | {
|
---|
226 | CREATESTRUCTA *cs = (CREATESTRUCTA*)lParam;
|
---|
227 | STATICINFO* infoPtr;
|
---|
228 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
229 | DWORD style = dwStyle & SS_TYPEMASK;
|
---|
230 | DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE);
|
---|
231 |
|
---|
232 | infoPtr = (STATICINFO*)malloc(sizeof(STATICINFO));
|
---|
233 | infoPtr->hFont = 0;
|
---|
234 | infoPtr->dummy = 0;
|
---|
235 | infoPtr->hIcon = 0;
|
---|
236 | SetInfoPtr(hwnd,(DWORD)infoPtr);
|
---|
237 |
|
---|
238 | if (dwStyle & SS_SUNKEN)
|
---|
239 | {
|
---|
240 | dwExStyle |= WS_EX_STATICEDGE;
|
---|
241 | SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle);
|
---|
242 | }
|
---|
243 |
|
---|
244 | if (style == SS_ICON)
|
---|
245 | {
|
---|
246 | if (cs->lpszName) //CB: is 0 a valid icon id? winhlp32: lpszName = NULL
|
---|
247 | {
|
---|
248 | if (!HIWORD(cs->lpszName) || cs->lpszName[0])
|
---|
249 | STATIC_SetIcon(hwnd,STATIC_LoadIcon(hwnd,cs->lpszName));
|
---|
250 | }
|
---|
251 | return TRUE;
|
---|
252 | }
|
---|
253 | if (style == SS_BITMAP)
|
---|
254 | {
|
---|
255 | if (cs->lpszName)
|
---|
256 | STATIC_SetBitmap(hwnd,STATIC_LoadBitmap(hwnd,cs->lpszName));
|
---|
257 | return TRUE;
|
---|
258 | }
|
---|
259 | if (style == SS_ENHMETAFILE)
|
---|
260 | {
|
---|
261 | if (cs->lpszName) STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,cs->lpszName));
|
---|
262 | return TRUE;
|
---|
263 | }
|
---|
264 | if (!HIWORD(cs->lpszName) && (cs->lpszName)) return TRUE;
|
---|
265 |
|
---|
266 | return DefWindowProcA(hwnd,WM_NCCREATE,wParam,lParam);
|
---|
267 | }
|
---|
268 |
|
---|
269 | LRESULT STATIC_Create(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
270 | {
|
---|
271 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
272 |
|
---|
273 | if ((style < 0L) || (style > SS_TYPEMASK))
|
---|
274 | {
|
---|
275 | //Unknown style
|
---|
276 | return (LRESULT)-1;
|
---|
277 | }
|
---|
278 |
|
---|
279 | /* initialise colours */
|
---|
280 | color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
|
---|
281 | color_background = GetSysColor(COLOR_BACKGROUND);
|
---|
282 | color_window = GetSysColor(COLOR_WINDOW);
|
---|
283 |
|
---|
284 | return 0;
|
---|
285 | }
|
---|
286 |
|
---|
287 | LRESULT STATIC_NCDestroy(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
288 | {
|
---|
289 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
|
---|
290 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
291 |
|
---|
292 | if ((style == SS_ICON) && infoPtr->hIcon)
|
---|
293 | {
|
---|
294 | DestroyIcon(infoPtr->hIcon);
|
---|
295 | } else if ((style == SS_BITMAP) && infoPtr->hIcon)
|
---|
296 | {
|
---|
297 | DeleteObject(infoPtr->hIcon);
|
---|
298 | } else if ((style == SS_ENHMETAFILE) && infoPtr->hIcon)
|
---|
299 | {
|
---|
300 | DeleteEnhMetaFile((HENHMETAFILE)infoPtr->hIcon);
|
---|
301 | }
|
---|
302 |
|
---|
303 | free(infoPtr);
|
---|
304 |
|
---|
305 | return DefWindowProcA(hwnd,WM_NCDESTROY,wParam,lParam);
|
---|
306 | }
|
---|
307 |
|
---|
308 | LRESULT STATIC_Paint(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
309 | {
|
---|
310 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
311 | PAINTSTRUCT ps;
|
---|
312 |
|
---|
313 | BeginPaint(hwnd,&ps);
|
---|
314 | if (staticPaintFunc[style]) (staticPaintFunc[style])(hwnd,ps.hdc);
|
---|
315 | EndPaint(hwnd,&ps);
|
---|
316 |
|
---|
317 | return 0;
|
---|
318 | }
|
---|
319 |
|
---|
320 | LRESULT STATIC_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
321 | {
|
---|
322 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
323 |
|
---|
324 | if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),wParam ? STN_ENABLE:STN_DISABLE),hwnd);
|
---|
325 |
|
---|
326 | InvalidateRect(hwnd,NULL,FALSE);
|
---|
327 |
|
---|
328 | return 0;
|
---|
329 | }
|
---|
330 |
|
---|
331 | LRESULT STATIC_SysColorChange(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
332 | {
|
---|
333 | color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
|
---|
334 | color_background = GetSysColor(COLOR_BACKGROUND);
|
---|
335 | color_window = GetSysColor(COLOR_WINDOW);
|
---|
336 |
|
---|
337 | InvalidateRect(hwnd,NULL,TRUE);
|
---|
338 |
|
---|
339 | return 0;
|
---|
340 | }
|
---|
341 |
|
---|
342 | /***********************************************************************
|
---|
343 | * STATIC_TryPaintFcn
|
---|
344 | *
|
---|
345 | * Try to immediately paint the control.
|
---|
346 | */
|
---|
347 | static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
|
---|
348 | {
|
---|
349 | LONG style = full_style & SS_TYPEMASK;
|
---|
350 | RECT rc;
|
---|
351 |
|
---|
352 | GetClientRect( hwnd, &rc );
|
---|
353 | if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style])
|
---|
354 | {
|
---|
355 | HDC hdc;
|
---|
356 | hdc = GetDC( hwnd );
|
---|
357 | (staticPaintFunc[style])( hwnd, hdc );
|
---|
358 | ReleaseDC( hwnd, hdc );
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 | LRESULT STATIC_SetText(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
363 | {
|
---|
364 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
365 |
|
---|
366 | switch (style) {
|
---|
367 | case SS_ICON:
|
---|
368 | {
|
---|
369 | HICON hIcon;
|
---|
370 | hIcon = STATIC_LoadIcon(hwnd, (LPCSTR)lParam);
|
---|
371 | /* FIXME : should we also return the previous hIcon here ??? */
|
---|
372 | STATIC_SetIcon(hwnd, hIcon);
|
---|
373 | break;
|
---|
374 | }
|
---|
375 | case SS_BITMAP:
|
---|
376 | {
|
---|
377 | HBITMAP hBitmap;
|
---|
378 | hBitmap = STATIC_LoadBitmap(hwnd, (LPCSTR)lParam);
|
---|
379 | STATIC_SetBitmap(hwnd, hBitmap);
|
---|
380 | break;
|
---|
381 | }
|
---|
382 | case SS_ENHMETAFILE:
|
---|
383 | STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,(LPCSTR)lParam));
|
---|
384 | break;
|
---|
385 |
|
---|
386 | case SS_LEFT:
|
---|
387 | case SS_CENTER:
|
---|
388 | case SS_RIGHT:
|
---|
389 | case SS_SIMPLE:
|
---|
390 | case SS_LEFTNOWORDWRAP:
|
---|
391 | {
|
---|
392 | if (HIWORD(lParam))
|
---|
393 | {
|
---|
394 | DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
|
---|
395 | }
|
---|
396 | STATIC_TryPaintFcn( hwnd, style );
|
---|
397 | break;
|
---|
398 | }
|
---|
399 | default:
|
---|
400 | if (HIWORD(lParam))
|
---|
401 | {
|
---|
402 | DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
|
---|
403 | }
|
---|
404 | InvalidateRect(hwnd, NULL, TRUE);
|
---|
405 | break;
|
---|
406 | }
|
---|
407 | return 1; /* success. FIXME: check text length */
|
---|
408 | }
|
---|
409 |
|
---|
410 | LRESULT STATIC_GetText(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
411 | {
|
---|
412 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
413 |
|
---|
414 | if (style == SS_ICON)
|
---|
415 | {
|
---|
416 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
|
---|
417 |
|
---|
418 | if ((wParam < 4) || !lParam) return 0;
|
---|
419 | memcpy((VOID*)lParam,&infoPtr->hIcon,4);
|
---|
420 |
|
---|
421 | return 4;
|
---|
422 | } else return DefWindowProcA(hwnd,WM_GETTEXT,wParam,lParam);
|
---|
423 | }
|
---|
424 |
|
---|
425 | LRESULT STATIC_GetTextLength(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
426 | {
|
---|
427 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
428 |
|
---|
429 | if (style == SS_ICON) return 4;
|
---|
430 | else return DefWindowProcA(hwnd,WM_GETTEXTLENGTH,wParam,lParam);
|
---|
431 | }
|
---|
432 |
|
---|
433 | LRESULT STATIC_SetFont(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
434 | {
|
---|
435 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
|
---|
436 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
437 |
|
---|
438 | if (style == SS_ICON) return 0;
|
---|
439 | if (style == SS_BITMAP) return 0;
|
---|
440 | if (style == SS_ENHMETAFILE) return 0;
|
---|
441 |
|
---|
442 | infoPtr->hFont = (HFONT)wParam;
|
---|
443 |
|
---|
444 | if (LOWORD(lParam))
|
---|
445 | {
|
---|
446 | InvalidateRect(hwnd,NULL,FALSE);
|
---|
447 | UpdateWindow(hwnd);
|
---|
448 | }
|
---|
449 |
|
---|
450 | return 0;
|
---|
451 | }
|
---|
452 |
|
---|
453 | LRESULT STATIC_GetFont(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
454 | {
|
---|
455 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
|
---|
456 |
|
---|
457 | return infoPtr->hFont;
|
---|
458 | }
|
---|
459 |
|
---|
460 | LRESULT STATIC_NCHitTest(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
461 | {
|
---|
462 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
463 | LRESULT lResult;
|
---|
464 |
|
---|
465 | if (dwStyle & SS_NOTIFY)
|
---|
466 | lResult = HTCLIENT;
|
---|
467 | else lResult = HTTRANSPARENT;
|
---|
468 |
|
---|
469 | return lResult;
|
---|
470 | }
|
---|
471 |
|
---|
472 | LRESULT STATIC_GetDlgCode(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
473 | {
|
---|
474 | return DLGC_STATIC;
|
---|
475 | }
|
---|
476 |
|
---|
477 | LRESULT STATIC_GetIcon(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
478 | {
|
---|
479 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
|
---|
480 |
|
---|
481 | return infoPtr->hIcon;
|
---|
482 | }
|
---|
483 |
|
---|
484 | LRESULT STATIC_GetImage(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
485 | {
|
---|
486 | STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
|
---|
487 | DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
|
---|
488 |
|
---|
489 | switch (wParam)
|
---|
490 | {
|
---|
491 | case IMAGE_BITMAP:
|
---|
492 | if (style & SS_BITMAP) return infoPtr->hIcon;
|
---|
493 | break;
|
---|
494 |
|
---|
495 | case IMAGE_CURSOR:
|
---|
496 | case IMAGE_ICON:
|
---|
497 | if (style & SS_ICON) return infoPtr->hIcon;
|
---|
498 | break;
|
---|
499 |
|
---|
500 | case IMAGE_ENHMETAFILE:
|
---|
501 | if (style & SS_ENHMETAFILE) return infoPtr->hIcon;
|
---|
502 | break;
|
---|
503 |
|
---|
504 | default:
|
---|
505 | break;
|
---|
506 | }
|
---|
507 |
|
---|
508 | return 0;
|
---|
509 | }
|
---|
510 |
|
---|
511 | LRESULT STATIC_SetImage(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
512 | {
|
---|
513 | LRESULT lResult = 0;
|
---|
514 |
|
---|
515 | switch (wParam)
|
---|
516 | {
|
---|
517 | case IMAGE_CURSOR:
|
---|
518 | case IMAGE_ICON:
|
---|
519 | lResult = STATIC_SetIcon(hwnd,(HICON)lParam);
|
---|
520 | break;
|
---|
521 |
|
---|
522 | case IMAGE_BITMAP:
|
---|
523 | lResult = STATIC_SetBitmap(hwnd,(HBITMAP)lParam);
|
---|
524 | break;
|
---|
525 |
|
---|
526 | case IMAGE_ENHMETAFILE:
|
---|
527 | lResult = STATIC_SetMetafile(hwnd,(HENHMETAFILE)lParam);
|
---|
528 | break;
|
---|
529 |
|
---|
530 | default:
|
---|
531 | return 0;
|
---|
532 | }
|
---|
533 |
|
---|
534 | if (lResult) InvalidateRect(hwnd,NULL,FALSE);
|
---|
535 |
|
---|
536 | return lResult;
|
---|
537 | }
|
---|
538 |
|
---|
539 | LRESULT STATIC_SetIconMsg(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
---|
540 | {
|
---|
541 | LRESULT lResult;
|
---|
542 |
|
---|
543 | lResult = STATIC_SetIcon(hwnd,(HICON)wParam);
|
---|
544 |
|
---|
545 | InvalidateRect(hwnd,NULL,FALSE);
|
---|
546 |
|
---|
547 | return lResult;
|
---|
548 | }
|
---|
549 |
|
---|
550 | LRESULT STATIC_Click(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
|
---|
551 | {
|
---|
552 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
553 |
|
---|
554 | if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),STN_CLICKED),hwnd);
|
---|
555 |
|
---|
556 | return DefWindowProcA(hwnd,uMsg,wParam,lParam);
|
---|
557 | }
|
---|
558 |
|
---|
559 | LRESULT STATIC_DoubleClick(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
|
---|
560 | {
|
---|
561 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
562 |
|
---|
563 | if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),STN_DBLCLK),hwnd);
|
---|
564 |
|
---|
565 | return DefWindowProcA(hwnd,uMsg,wParam,lParam);
|
---|
566 | }
|
---|
567 |
|
---|
568 | /***********************************************************************
|
---|
569 | * StaticWndProc
|
---|
570 | */
|
---|
571 | LRESULT WINAPI StaticWndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
|
---|
572 | {
|
---|
573 | switch (uMsg)
|
---|
574 | {
|
---|
575 | case WM_NCCREATE:
|
---|
576 | return STATIC_NCCreate(hwnd,wParam,lParam);
|
---|
577 |
|
---|
578 | case WM_CREATE:
|
---|
579 | return STATIC_Create(hwnd,wParam,lParam);
|
---|
580 |
|
---|
581 | case WM_NCDESTROY:
|
---|
582 | return STATIC_NCDestroy(hwnd,wParam,lParam);
|
---|
583 |
|
---|
584 | case WM_PAINT:
|
---|
585 | return STATIC_Paint(hwnd,wParam,lParam);
|
---|
586 |
|
---|
587 | case WM_ENABLE:
|
---|
588 | return STATIC_Enable(hwnd,wParam,lParam);
|
---|
589 |
|
---|
590 | case WM_SYSCOLORCHANGE:
|
---|
591 | return STATIC_SysColorChange(hwnd,wParam,lParam);
|
---|
592 |
|
---|
593 | case WM_SETTEXT:
|
---|
594 | return STATIC_SetText(hwnd,wParam,lParam);
|
---|
595 |
|
---|
596 | case WM_GETTEXT:
|
---|
597 | return STATIC_GetText(hwnd,wParam,lParam);
|
---|
598 |
|
---|
599 | case WM_GETTEXTLENGTH:
|
---|
600 | return STATIC_GetTextLength(hwnd,wParam,lParam);
|
---|
601 |
|
---|
602 | case WM_SETFONT:
|
---|
603 | return STATIC_SetFont(hwnd,wParam,lParam);
|
---|
604 |
|
---|
605 | case WM_GETFONT:
|
---|
606 | return STATIC_GetFont(hwnd,wParam,lParam);
|
---|
607 |
|
---|
608 | case WM_NCHITTEST:
|
---|
609 | return STATIC_NCHitTest(hwnd,wParam,lParam);
|
---|
610 |
|
---|
611 | case WM_GETDLGCODE:
|
---|
612 | return STATIC_GetDlgCode(hwnd,wParam,lParam);
|
---|
613 |
|
---|
614 | case WM_LBUTTONDOWN:
|
---|
615 | case WM_NCLBUTTONDOWN:
|
---|
616 | return STATIC_Click(hwnd,uMsg,wParam,lParam);
|
---|
617 |
|
---|
618 | case WM_LBUTTONDBLCLK:
|
---|
619 | case WM_NCLBUTTONDBLCLK:
|
---|
620 | return STATIC_DoubleClick(hwnd,uMsg,wParam,lParam);
|
---|
621 |
|
---|
622 | case STM_GETIMAGE:
|
---|
623 | return STATIC_GetImage(hwnd,wParam,lParam);
|
---|
624 |
|
---|
625 | case STM_GETICON:
|
---|
626 | return STATIC_GetIcon(hwnd,wParam,lParam);
|
---|
627 |
|
---|
628 | case STM_SETIMAGE:
|
---|
629 | return STATIC_SetImage(hwnd,wParam,lParam);
|
---|
630 |
|
---|
631 | case STM_SETICON:
|
---|
632 | return STATIC_SetIconMsg(hwnd,wParam,lParam);
|
---|
633 |
|
---|
634 | case STM_MSGMAX:
|
---|
635 | return 0; //CB: undocumented!
|
---|
636 |
|
---|
637 | default:
|
---|
638 | return DefWindowProcA(hwnd,uMsg,wParam,lParam);
|
---|
639 | break;
|
---|
640 | }
|
---|
641 |
|
---|
642 | return DefWindowProcA(hwnd,uMsg,wParam,lParam);
|
---|
643 | }
|
---|
644 |
|
---|
645 |
|
---|
646 | static void STATIC_PaintTextfn(HWND hwnd, HDC hdc )
|
---|
647 | {
|
---|
648 | RECT rc;
|
---|
649 | HBRUSH hBrush;
|
---|
650 | WORD wFormat;
|
---|
651 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
652 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
|
---|
653 | INT textLen;
|
---|
654 |
|
---|
655 | GetClientRect(hwnd,&rc);
|
---|
656 |
|
---|
657 | switch (dwStyle & SS_TYPEMASK)
|
---|
658 | {
|
---|
659 | case SS_LEFT:
|
---|
660 | wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
|
---|
661 | break;
|
---|
662 |
|
---|
663 | case SS_CENTER:
|
---|
664 | case SS_CENTERIMAGE:
|
---|
665 | wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
|
---|
666 | break;
|
---|
667 |
|
---|
668 | case SS_RIGHT:
|
---|
669 | wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
|
---|
670 | break;
|
---|
671 |
|
---|
672 | case SS_SIMPLE:
|
---|
673 | wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP;
|
---|
674 | break;
|
---|
675 |
|
---|
676 | case SS_LEFTNOWORDWRAP:
|
---|
677 | wFormat = DT_LEFT | DT_EXPANDTABS | DT_VCENTER;
|
---|
678 | break;
|
---|
679 |
|
---|
680 | default:
|
---|
681 | return;
|
---|
682 | }
|
---|
683 |
|
---|
684 | if (dwStyle & SS_NOPREFIX) wFormat |= DT_NOPREFIX;
|
---|
685 | if (dwStyle & SS_ENDELLIPSIS) wFormat |= DT_END_ELLIPSIS;
|
---|
686 | if (dwStyle & SS_PATHELLIPSIS) wFormat |= DT_PATH_ELLIPSIS;
|
---|
687 | if (dwStyle & SS_WORDELLIPSIS) wFormat |= DT_WORD_ELLIPSIS;
|
---|
688 |
|
---|
689 | if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont );
|
---|
690 | //SvL: This is what the latest Wine code does. Fixes the common color dialog
|
---|
691 | #if 1
|
---|
692 | if ((dwStyle & SS_NOPREFIX) || ((dwStyle & SS_TYPEMASK) != SS_SIMPLE))
|
---|
693 | {
|
---|
694 | hBrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC,
|
---|
695 | hdc, hwnd );
|
---|
696 | if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH);
|
---|
697 | FillRect( hdc, &rc, hBrush );
|
---|
698 | }
|
---|
699 | #else
|
---|
700 | hBrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC,
|
---|
701 | hdc, hwnd );
|
---|
702 | if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH);
|
---|
703 | FillRect( hdc, &rc, hBrush );
|
---|
704 | #endif
|
---|
705 |
|
---|
706 | if (!IsWindowEnabled(hwnd)) SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT));
|
---|
707 |
|
---|
708 | textLen = GetWindowTextLengthA(hwnd);
|
---|
709 | if (textLen > 0)
|
---|
710 | {
|
---|
711 | char* text;
|
---|
712 |
|
---|
713 | textLen++;
|
---|
714 | text = (char*)malloc(textLen);
|
---|
715 | GetWindowTextA(hwnd,text,textLen);
|
---|
716 | DrawTextExA(hdc,text,-1,&rc,wFormat,NULL);
|
---|
717 | free(text);
|
---|
718 | }
|
---|
719 | }
|
---|
720 |
|
---|
721 | static void STATIC_PaintRectfn( HWND hwnd, HDC hdc )
|
---|
722 | {
|
---|
723 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
724 | RECT rc;
|
---|
725 | HBRUSH hBrush;
|
---|
726 |
|
---|
727 | GetClientRect( hwnd, &rc);
|
---|
728 |
|
---|
729 | switch (dwStyle & SS_TYPEMASK)
|
---|
730 | {
|
---|
731 | case SS_BLACKRECT:
|
---|
732 | hBrush = CreateSolidBrush(color_windowframe);
|
---|
733 | FillRect( hdc, &rc, hBrush );
|
---|
734 | break;
|
---|
735 | case SS_GRAYRECT:
|
---|
736 | hBrush = CreateSolidBrush(color_background);
|
---|
737 | FillRect( hdc, &rc, hBrush );
|
---|
738 | break;
|
---|
739 | case SS_WHITERECT:
|
---|
740 | hBrush = CreateSolidBrush(color_window);
|
---|
741 | FillRect( hdc, &rc, hBrush );
|
---|
742 | break;
|
---|
743 | case SS_BLACKFRAME:
|
---|
744 | hBrush = CreateSolidBrush(color_windowframe);
|
---|
745 | FrameRect( hdc, &rc, hBrush );
|
---|
746 | break;
|
---|
747 | case SS_GRAYFRAME:
|
---|
748 | hBrush = CreateSolidBrush(color_background);
|
---|
749 | FrameRect( hdc, &rc, hBrush );
|
---|
750 | break;
|
---|
751 | case SS_WHITEFRAME:
|
---|
752 | hBrush = CreateSolidBrush(color_window);
|
---|
753 | FrameRect( hdc, &rc, hBrush );
|
---|
754 | break;
|
---|
755 | default:
|
---|
756 | return;
|
---|
757 | }
|
---|
758 | DeleteObject( hBrush );
|
---|
759 | }
|
---|
760 |
|
---|
761 |
|
---|
762 | static void STATIC_PaintIconfn( HWND hwnd, HDC hdc )
|
---|
763 | {
|
---|
764 | RECT rc;
|
---|
765 | HBRUSH hbrush;
|
---|
766 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
|
---|
767 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
768 |
|
---|
769 | GetClientRect( hwnd, &rc );
|
---|
770 | hbrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC,
|
---|
771 | hdc, hwnd );
|
---|
772 | FillRect( hdc, &rc, hbrush );
|
---|
773 |
|
---|
774 | if (dwStyle & SS_CENTERIMAGE)
|
---|
775 | {
|
---|
776 | ICONINFO ii;
|
---|
777 | BITMAP bmp;
|
---|
778 |
|
---|
779 | #if 0
|
---|
780 | //TODO: fill with upper left pixel of icon
|
---|
781 | COLORREF color;
|
---|
782 |
|
---|
783 | color = GetPixel(hMemDC, 0, 0);
|
---|
784 | hbrush = CreateSolidBrush(color);
|
---|
785 | FillRect( hdc, &rc, hbrush );
|
---|
786 | DeleteObject(hbrush);
|
---|
787 | #endif
|
---|
788 |
|
---|
789 | if (!GetIconInfo(infoPtr->hIcon,&ii)) return;
|
---|
790 | if (ii.hbmColor)
|
---|
791 | GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
|
---|
792 | else
|
---|
793 | {
|
---|
794 | GetObjectA(ii.hbmMask,sizeof(BITMAP),(LPVOID)&bmp);
|
---|
795 | bmp.bmHeight /= 2;
|
---|
796 | }
|
---|
797 | DrawIcon(hdc,(rc.right-bmp.bmWidth)/2,(rc.bottom-bmp.bmHeight)/2,infoPtr->hIcon);
|
---|
798 | if (ii.hbmColor) DeleteObject(ii.hbmColor);
|
---|
799 | if (ii.hbmMask) DeleteObject(ii.hbmMask);
|
---|
800 | }
|
---|
801 | else
|
---|
802 | if (infoPtr->hIcon) {
|
---|
803 | DrawIcon(hdc,rc.left,rc.top,infoPtr->hIcon);
|
---|
804 | }
|
---|
805 | }
|
---|
806 |
|
---|
807 | static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc )
|
---|
808 | {
|
---|
809 | RECT rc;
|
---|
810 | HBRUSH hbrush;
|
---|
811 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
|
---|
812 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
813 | HDC hMemDC;
|
---|
814 | HBITMAP oldbitmap;
|
---|
815 |
|
---|
816 | GetClientRect( hwnd, &rc );
|
---|
817 | hbrush = SendMessageA( GetParent(hwnd), WM_CTLCOLORSTATIC,
|
---|
818 | hdc, hwnd );
|
---|
819 |
|
---|
820 | if (infoPtr->hIcon)
|
---|
821 | {
|
---|
822 | BITMAP bm;
|
---|
823 |
|
---|
824 | if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP) return;
|
---|
825 | if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
|
---|
826 |
|
---|
827 | GetObjectA(infoPtr->hIcon, sizeof(bm), &bm);
|
---|
828 | oldbitmap = SelectObject(hMemDC, infoPtr->hIcon);
|
---|
829 |
|
---|
830 | // Paint the image in center area
|
---|
831 | if(dwStyle & SS_CENTERIMAGE)
|
---|
832 | {
|
---|
833 | SIZE szbm;
|
---|
834 | SIZE szdc;
|
---|
835 | COLORREF color;
|
---|
836 |
|
---|
837 | //SvL: Fill client area with pixel in upper left corner (SDK docs)
|
---|
838 | color = GetPixel(hMemDC, 0, 0);
|
---|
839 | hbrush = CreateSolidBrush(color);
|
---|
840 | FillRect( hdc, &rc, hbrush );
|
---|
841 | DeleteObject(hbrush);
|
---|
842 |
|
---|
843 | if(bm.bmWidth > rc.right - rc.left)
|
---|
844 | {
|
---|
845 | szdc.cx = 0;
|
---|
846 | szbm.cx = (bm.bmWidth - (rc.right - rc.left)) / 2;
|
---|
847 | bm.bmWidth = rc.right - rc.left;
|
---|
848 | }
|
---|
849 | else
|
---|
850 | {
|
---|
851 | szbm.cx = 0;
|
---|
852 | szdc.cx = ((rc.right - rc.left) - bm.bmWidth) / 2;
|
---|
853 | }
|
---|
854 | if(bm.bmHeight > rc.bottom - rc.top)
|
---|
855 | {
|
---|
856 | szdc.cy = 0;
|
---|
857 | szbm.cy = (bm.bmHeight - (rc.bottom - rc.top)) / 2;
|
---|
858 | bm.bmWidth = rc.bottom - rc.top;
|
---|
859 | }
|
---|
860 | else
|
---|
861 | {
|
---|
862 | szbm.cy = 0;
|
---|
863 | szdc.cy = ((rc.bottom - rc.top) - bm.bmHeight) / 2;
|
---|
864 | }
|
---|
865 | BitBlt(hdc, szdc.cx, szdc.cy, bm.bmWidth, bm.bmHeight, hMemDC,
|
---|
866 | szbm.cx, szbm.cy, SRCCOPY);
|
---|
867 | }
|
---|
868 | else
|
---|
869 | {
|
---|
870 | FillRect( hdc, &rc, hbrush );
|
---|
871 | BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
|
---|
872 | }
|
---|
873 |
|
---|
874 | SelectObject(hMemDC, oldbitmap);
|
---|
875 | DeleteDC(hMemDC);
|
---|
876 | }
|
---|
877 | }
|
---|
878 |
|
---|
879 | static void STATIC_PaintMetafilefn(HWND hwnd,HDC hdc)
|
---|
880 | {
|
---|
881 | RECT rect;
|
---|
882 | HBRUSH hbrush;
|
---|
883 | STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
|
---|
884 |
|
---|
885 | GetClientRect(hwnd,&rect);
|
---|
886 | hbrush = SendMessageA(GetParent(hwnd),WM_CTLCOLORSTATIC,hdc,hwnd);
|
---|
887 | FillRect(hdc,&rect,hbrush);
|
---|
888 |
|
---|
889 | if (infoPtr->hIcon) PlayEnhMetaFile(hdc,(HENHMETAFILE)infoPtr->hIcon,&rect);
|
---|
890 | }
|
---|
891 |
|
---|
892 | static void STATIC_PaintOwnerDrawfn(HWND hwnd,HDC hdc)
|
---|
893 | {
|
---|
894 | DRAWITEMSTRUCT di;
|
---|
895 |
|
---|
896 | di.CtlType = ODT_STATIC;
|
---|
897 | di.CtlID = GetWindowLongA(hwnd,GWL_ID);
|
---|
898 | di.itemID = 0;
|
---|
899 | di.itemAction = ODA_DRAWENTIRE;
|
---|
900 | di.itemState = ODS_DEFAULT;
|
---|
901 | di.hwndItem = hwnd;
|
---|
902 | di.hDC = hdc;
|
---|
903 | GetClientRect(hwnd,&di.rcItem);
|
---|
904 | di.itemData = 0;
|
---|
905 |
|
---|
906 | SendMessageA(GetParent(hwnd),WM_CTLCOLORSTATIC,hdc,hwnd);
|
---|
907 | SendMessageA(GetParent(hwnd),WM_DRAWITEM,di.CtlID,(LPARAM)&di);
|
---|
908 | }
|
---|
909 |
|
---|
910 | static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc )
|
---|
911 | {
|
---|
912 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
913 | RECT rc;
|
---|
914 |
|
---|
915 | GetClientRect( hwnd, &rc );
|
---|
916 | switch (dwStyle & SS_TYPEMASK)
|
---|
917 | {
|
---|
918 | case SS_ETCHEDHORZ:
|
---|
919 | DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
|
---|
920 | break;
|
---|
921 | case SS_ETCHEDVERT:
|
---|
922 | DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
|
---|
923 | break;
|
---|
924 | case SS_ETCHEDFRAME:
|
---|
925 | DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);
|
---|
926 | break;
|
---|
927 | }
|
---|
928 | }
|
---|
929 |
|
---|
930 | BOOL STATIC_Register()
|
---|
931 | {
|
---|
932 | WNDCLASSA wndClass;
|
---|
933 |
|
---|
934 | //SvL: Don't check this now
|
---|
935 | // if (GlobalFindAtomA(STATICCLASSNAME)) return FALSE;
|
---|
936 |
|
---|
937 | ZeroMemory(&wndClass,sizeof(WNDCLASSA));
|
---|
938 | wndClass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_PARENTDC;
|
---|
939 | wndClass.lpfnWndProc = (WNDPROC)StaticWndProc;
|
---|
940 | wndClass.cbClsExtra = 0;
|
---|
941 | wndClass.cbWndExtra = sizeof(STATICINFO);
|
---|
942 | wndClass.hCursor = LoadCursorA (0,IDC_ARROWA);
|
---|
943 | wndClass.hbrBackground = (HBRUSH)0;
|
---|
944 | wndClass.lpszClassName = STATICCLASSNAME;
|
---|
945 |
|
---|
946 | return RegisterClassA(&wndClass);
|
---|
947 | }
|
---|
948 |
|
---|
949 |
|
---|
950 | BOOL STATIC_Unregister()
|
---|
951 | {
|
---|
952 | if (GlobalFindAtomA (STATICCLASSNAME))
|
---|
953 | return UnregisterClassA(STATICCLASSNAME,(HINSTANCE)NULL);
|
---|
954 | else return FALSE;
|
---|
955 | }
|
---|