Fix some DPA functions so they pass the new tests.
[wine/multimedia.git] / dlls / user / static.c
blob65a1249f70d341f6f27577373da715906047d86f
1 /*
2 * Static control
4 * Copyright David W. Metcalfe, 1993
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * NOTES
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Oct. 4, 2004, by Dimitrie O. Paun.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features, or bugs, please note them below.
29 * TODO:
31 * Styles
32 * - SS_EDITCONTROL
33 * - SS_ENDELLIPSIS
34 * - SS_ENHMETAFILE
35 * - SS_PATHELLIPSIS
36 * - SS_REALSIZECONTROL
37 * - SS_REALSIZEIMAGE
38 * - SS_RIGHTJUST
39 * - SS_WORDELLIPSIS
41 * Notifications
42 * - STN_DISABLE
43 * - STN_ENABLE
45 * Messages
46 * - STM_SETIMAGE: IMAGE_CURSOR, IMAGE_ENHMETAFILE
49 #include <stdarg.h>
51 #include "windef.h"
52 #include "winbase.h"
53 #include "wingdi.h"
54 #include "wine/winuser16.h"
55 #include "controls.h"
56 #include "user_private.h"
57 #include "wine/debug.h"
59 WINE_DEFAULT_DEBUG_CHANNEL(static);
61 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style );
62 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style );
63 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style );
64 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style );
65 static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style );
66 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
67 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
68 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
70 static COLORREF color_3dshadow, color_3ddkshadow, color_3dhighlight;
72 /* offsets for GetWindowLong for static private information */
73 #define HFONT_GWL_OFFSET 0
74 #define HICON_GWL_OFFSET (sizeof(HFONT))
75 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
77 typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style );
79 static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
81 STATIC_PaintTextfn, /* SS_LEFT */
82 STATIC_PaintTextfn, /* SS_CENTER */
83 STATIC_PaintTextfn, /* SS_RIGHT */
84 STATIC_PaintIconfn, /* SS_ICON */
85 STATIC_PaintRectfn, /* SS_BLACKRECT */
86 STATIC_PaintRectfn, /* SS_GRAYRECT */
87 STATIC_PaintRectfn, /* SS_WHITERECT */
88 STATIC_PaintRectfn, /* SS_BLACKFRAME */
89 STATIC_PaintRectfn, /* SS_GRAYFRAME */
90 STATIC_PaintRectfn, /* SS_WHITEFRAME */
91 NULL, /* SS_USERITEM */
92 STATIC_PaintTextfn, /* SS_SIMPLE */
93 STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
94 STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
95 STATIC_PaintBitmapfn, /* SS_BITMAP */
96 NULL, /* SS_ENHMETAFILE */
97 STATIC_PaintEtchedfn, /* SS_ETCHEDHORZ */
98 STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
99 STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
103 /*********************************************************************
104 * static class descriptor
106 const struct builtin_class_descr STATIC_builtin_class =
108 "Static", /* name */
109 CS_DBLCLKS | CS_PARENTDC, /* style */
110 StaticWndProcA, /* procA */
111 StaticWndProcW, /* procW */
112 STATIC_EXTRA_BYTES, /* extra */
113 IDC_ARROW, /* cursor */
114 0 /* brush */
118 /***********************************************************************
119 * STATIC_SetIcon
121 * Set the icon for an SS_ICON control.
123 static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style )
125 HICON prevIcon;
126 CURSORICONINFO *info = hicon?(CURSORICONINFO *) GlobalLock16(HICON_16(hicon)):NULL;
128 if ((style & SS_TYPEMASK) != SS_ICON) return 0;
129 if (hicon && !info) {
130 ERR("huh? hicon!=0, but info=0???\n");
131 return 0;
133 prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
134 if (hicon && !(style & SS_CENTERIMAGE))
136 SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
137 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
138 GlobalUnlock16(HICON_16(hicon));
140 return prevIcon;
143 /***********************************************************************
144 * STATIC_SetBitmap
146 * Set the bitmap for an SS_BITMAP control.
148 static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
150 HBITMAP hOldBitmap;
152 if ((style & SS_TYPEMASK) != SS_BITMAP) return 0;
153 if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) {
154 ERR("huh? hBitmap!=0, but not bitmap\n");
155 return 0;
157 hOldBitmap = (HBITMAP)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hBitmap );
158 if (hBitmap && !(style & SS_CENTERIMAGE))
160 BITMAP bm;
161 GetObjectW(hBitmap, sizeof(bm), &bm);
162 SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
163 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
165 return hOldBitmap;
168 /***********************************************************************
169 * STATIC_LoadIconA
171 * Load the icon for an SS_ICON control.
173 static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name )
175 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
176 HICON hicon = LoadIconA( hInstance, name );
177 if (!hicon) hicon = LoadIconA( 0, name );
178 return hicon;
181 /***********************************************************************
182 * STATIC_LoadIconW
184 * Load the icon for an SS_ICON control.
186 static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name )
188 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
189 HICON hicon = LoadIconW( hInstance, name );
190 if (!hicon) hicon = LoadIconW( 0, name );
191 return hicon;
194 /***********************************************************************
195 * STATIC_LoadBitmapA
197 * Load the bitmap for an SS_BITMAP control.
199 static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
201 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
202 HBITMAP hbitmap = LoadBitmapA( hInstance, name );
203 if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */
204 hbitmap = LoadBitmapA( 0, name );
205 return hbitmap;
208 /***********************************************************************
209 * STATIC_LoadBitmapW
211 * Load the bitmap for an SS_BITMAP control.
213 static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name )
215 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
216 HBITMAP hbitmap = LoadBitmapW( hInstance, name );
217 if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */
218 hbitmap = LoadBitmapW( 0, name );
219 return hbitmap;
222 /***********************************************************************
223 * STATIC_TryPaintFcn
225 * Try to immediately paint the control.
227 static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
229 LONG style = full_style & SS_TYPEMASK;
230 RECT rc;
232 GetClientRect( hwnd, &rc );
233 if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style])
235 HDC hdc;
236 hdc = GetDC( hwnd );
237 (staticPaintFunc[style])( hwnd, hdc, full_style );
238 ReleaseDC( hwnd, hdc );
242 static VOID STATIC_InitColours(void)
244 color_3ddkshadow = GetSysColor(COLOR_3DDKSHADOW);
245 color_3dshadow = GetSysColor(COLOR_3DSHADOW);
246 color_3dhighlight = GetSysColor(COLOR_3DHIGHLIGHT);
249 /***********************************************************************
250 * StaticWndProc_common
252 static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
253 LPARAM lParam, BOOL unicode )
255 LRESULT lResult = 0;
256 LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
257 LONG style = full_style & SS_TYPEMASK;
259 switch (uMsg)
261 case WM_CREATE:
262 if (style < 0L || style > SS_TYPEMASK)
264 ERR("Unknown style 0x%02lx\n", style );
265 return -1;
267 STATIC_InitColours();
268 break;
270 case WM_NCDESTROY:
271 if (style == SS_ICON) {
273 * FIXME
274 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
276 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
277 * had already been loaded by the application the last thing we want to do is
278 * GlobalFree16 the handle.
280 break;
282 else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
283 DefWindowProcA(hwnd, uMsg, wParam, lParam);
285 case WM_PAINT:
287 PAINTSTRUCT ps;
288 HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
289 if (staticPaintFunc[style])
290 (staticPaintFunc[style])( hwnd, hdc, full_style );
291 if (!wParam) EndPaint(hwnd, &ps);
293 break;
295 case WM_ENABLE:
296 InvalidateRect(hwnd, NULL, TRUE);
297 break;
299 case WM_SYSCOLORCHANGE:
300 STATIC_InitColours();
301 InvalidateRect(hwnd, NULL, TRUE);
302 break;
304 case WM_NCCREATE:
305 if (full_style & SS_SUNKEN)
306 SetWindowLongW( hwnd, GWL_EXSTYLE,
307 GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
309 if(unicode)
310 lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName);
311 else
312 lParam = (LPARAM)(((LPCREATESTRUCTA)lParam)->lpszName);
313 /* fall through */
314 case WM_SETTEXT:
315 switch (style) {
316 case SS_ICON:
318 HICON hIcon;
319 if(unicode)
320 hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam);
321 else
322 hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam);
323 /* FIXME : should we also return the previous hIcon here ??? */
324 STATIC_SetIcon(hwnd, hIcon, full_style);
325 break;
327 case SS_BITMAP:
329 HBITMAP hBitmap;
330 if(unicode)
331 hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam);
332 else
333 hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam);
334 STATIC_SetBitmap(hwnd, hBitmap, full_style);
335 break;
337 case SS_LEFT:
338 case SS_CENTER:
339 case SS_RIGHT:
340 case SS_SIMPLE:
341 case SS_LEFTNOWORDWRAP:
343 if (HIWORD(lParam))
345 if(unicode)
346 lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
347 else
348 lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
350 if (uMsg == WM_SETTEXT)
351 STATIC_TryPaintFcn( hwnd, full_style );
352 break;
354 default:
355 if (HIWORD(lParam))
357 if(unicode)
358 lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
359 else
360 lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
362 if(uMsg == WM_SETTEXT)
363 InvalidateRect(hwnd, NULL, TRUE);
365 return 1; /* success. FIXME: check text length */
367 case WM_SETFONT:
368 if ((style == SS_ICON) || (style == SS_BITMAP)) return 0;
369 SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam );
370 if (LOWORD(lParam))
371 InvalidateRect( hwnd, NULL, TRUE );
372 break;
374 case WM_GETFONT:
375 return GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
377 case WM_NCHITTEST:
378 if (full_style & SS_NOTIFY)
379 return HTCLIENT;
380 else
381 return HTTRANSPARENT;
383 case WM_GETDLGCODE:
384 return DLGC_STATIC;
386 case WM_LBUTTONDOWN:
387 case WM_NCLBUTTONDOWN:
388 if (full_style & SS_NOTIFY)
389 SendMessageW( GetParent(hwnd), WM_COMMAND,
390 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_CLICKED ), (LPARAM)hwnd);
391 return 0;
393 case WM_LBUTTONDBLCLK:
394 case WM_NCLBUTTONDBLCLK:
395 if (full_style & SS_NOTIFY)
396 SendMessageW( GetParent(hwnd), WM_COMMAND,
397 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DBLCLK ), (LPARAM)hwnd);
398 return 0;
400 case STM_GETIMAGE:
401 case STM_GETICON16:
402 case STM_GETICON:
403 return GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
405 case STM_SETIMAGE:
406 switch(wParam) {
407 case IMAGE_BITMAP:
408 lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
409 break;
410 case IMAGE_CURSOR:
411 FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
412 break;
413 case IMAGE_ENHMETAFILE:
414 FIXME("STM_SETIMAGE: Unhandled type IMAGE_ENHMETAFILE\n");
415 break;
416 case IMAGE_ICON:
417 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
418 break;
419 default:
420 FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
421 break;
423 InvalidateRect( hwnd, NULL, TRUE );
424 break;
426 case STM_SETICON16:
427 case STM_SETICON:
428 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
429 InvalidateRect( hwnd, NULL, TRUE );
430 break;
432 default:
433 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
434 DefWindowProcA(hwnd, uMsg, wParam, lParam);
436 return lResult;
439 /***********************************************************************
440 * StaticWndProcA
442 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
444 if (!IsWindow( hWnd )) return 0;
445 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
448 /***********************************************************************
449 * StaticWndProcW
451 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
453 if (!IsWindow( hWnd )) return 0;
454 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
457 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
459 DRAWITEMSTRUCT dis;
460 UINT id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID );
462 dis.CtlType = ODT_STATIC;
463 dis.CtlID = id;
464 dis.itemID = 0;
465 dis.itemAction = ODA_DRAWENTIRE;
466 dis.itemState = 0;
467 dis.hwndItem = hwnd;
468 dis.hDC = hdc;
469 dis.itemData = 0;
470 GetClientRect( hwnd, &dis.rcItem );
472 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
473 SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
476 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
478 RECT rc;
479 HBRUSH hBrush;
480 HFONT hFont;
481 WORD wFormat;
482 INT len;
483 WCHAR *text;
485 GetClientRect( hwnd, &rc);
487 switch (style & SS_TYPEMASK)
489 case SS_LEFT:
490 wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK;
491 break;
493 case SS_CENTER:
494 wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK;
495 break;
497 case SS_RIGHT:
498 wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK;
499 break;
501 case SS_SIMPLE:
502 wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER;
503 break;
505 case SS_LEFTNOWORDWRAP:
506 wFormat = DT_LEFT | DT_EXPANDTABS | DT_VCENTER;
507 break;
509 default:
510 return;
513 if (style & SS_NOPREFIX)
514 wFormat |= DT_NOPREFIX;
515 if (style & SS_CENTERIMAGE)
516 wFormat |= DT_VCENTER;
518 if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET ))) SelectObject( hdc, hFont );
520 if ((style & SS_NOPREFIX) || ((style & SS_TYPEMASK) != SS_SIMPLE))
522 hBrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
523 (WPARAM)hdc, (LPARAM)hwnd );
524 if (!hBrush) /* did the app forget to call defwindowproc ? */
525 hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
526 (WPARAM)hdc, (LPARAM)hwnd);
527 FillRect( hdc, &rc, hBrush );
529 if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
531 if (!(len = SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ))) return;
532 if (!(text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return;
533 SendMessageW( hwnd, WM_GETTEXT, len + 1, (LPARAM)text );
534 DrawTextW( hdc, text, -1, &rc, wFormat );
535 HeapFree( GetProcessHeap(), 0, text );
538 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
540 RECT rc;
541 HBRUSH hBrush;
543 GetClientRect( hwnd, &rc);
545 switch (style & SS_TYPEMASK)
547 case SS_BLACKRECT:
548 hBrush = CreateSolidBrush(color_3ddkshadow);
549 FillRect( hdc, &rc, hBrush );
550 break;
551 case SS_GRAYRECT:
552 hBrush = CreateSolidBrush(color_3dshadow);
553 FillRect( hdc, &rc, hBrush );
554 break;
555 case SS_WHITERECT:
556 hBrush = CreateSolidBrush(color_3dhighlight);
557 FillRect( hdc, &rc, hBrush );
558 break;
559 case SS_BLACKFRAME:
560 hBrush = CreateSolidBrush(color_3ddkshadow);
561 FrameRect( hdc, &rc, hBrush );
562 break;
563 case SS_GRAYFRAME:
564 hBrush = CreateSolidBrush(color_3dshadow);
565 FrameRect( hdc, &rc, hBrush );
566 break;
567 case SS_WHITEFRAME:
568 hBrush = CreateSolidBrush(color_3dhighlight);
569 FrameRect( hdc, &rc, hBrush );
570 break;
571 default:
572 return;
574 DeleteObject( hBrush );
578 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
580 RECT rc;
581 HBRUSH hbrush;
582 HICON hIcon;
583 INT x, y;
585 GetClientRect( hwnd, &rc );
586 hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
587 (WPARAM)hdc, (LPARAM)hwnd );
588 FillRect( hdc, &rc, hbrush );
589 hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
590 if (style & SS_CENTERIMAGE)
592 CURSORICONINFO *info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL;
593 x = (rc.right - rc.left)/2 - (info ? info->nWidth/2 : 0);
594 y = (rc.bottom - rc.top)/2 - (info ? info->nHeight/2 : 0);
596 else
598 x = rc.left;
599 y = rc.top;
601 if (hIcon)
602 DrawIcon( hdc, x, y, hIcon );
605 static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
607 HDC hMemDC;
608 HBITMAP hBitmap, oldbitmap;
610 /* message is still sent, even if the returned brush is not used */
611 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
612 (WPARAM)hdc, (LPARAM)hwnd );
614 if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
616 INT x, y;
617 BITMAP bm;
619 if(GetObjectType(hBitmap) != OBJ_BITMAP) return;
620 if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
621 GetObjectW(hBitmap, sizeof(bm), &bm);
622 oldbitmap = SelectObject(hMemDC, hBitmap);
623 if (style & SS_CENTERIMAGE)
625 RECT rcClient;
626 GetClientRect(hwnd, &rcClient);
627 x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
628 y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
630 else
632 x = 0;
633 y = 0;
635 BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
636 SRCCOPY);
637 SelectObject(hMemDC, oldbitmap);
638 DeleteDC(hMemDC);
643 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
645 RECT rc;
647 GetClientRect( hwnd, &rc );
648 switch (style & SS_TYPEMASK)
650 case SS_ETCHEDHORZ:
651 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
652 break;
653 case SS_ETCHEDVERT:
654 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
655 break;
656 case SS_ETCHEDFRAME:
657 DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);
658 break;