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