user: Fix LB_GETTEXT unmapping for A<->W.
[wine/multimedia.git] / dlls / user / static.c
blobc40a09dc436180f9ecb9b36329e61a134cf8145c
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_PRINTCLIENT:
286 case WM_PAINT:
288 PAINTSTRUCT ps;
289 HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
290 if (staticPaintFunc[style])
291 (staticPaintFunc[style])( hwnd, hdc, full_style );
292 if (!wParam) EndPaint(hwnd, &ps);
294 break;
296 case WM_ENABLE:
297 InvalidateRect(hwnd, NULL, TRUE);
298 break;
300 case WM_SYSCOLORCHANGE:
301 STATIC_InitColours();
302 InvalidateRect(hwnd, NULL, TRUE);
303 break;
305 case WM_NCCREATE:
306 if (full_style & SS_SUNKEN)
307 SetWindowLongW( hwnd, GWL_EXSTYLE,
308 GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
310 if(unicode)
311 lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName);
312 else
313 lParam = (LPARAM)(((LPCREATESTRUCTA)lParam)->lpszName);
314 /* fall through */
315 case WM_SETTEXT:
316 switch (style) {
317 case SS_ICON:
319 HICON hIcon;
320 if(unicode)
321 hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam);
322 else
323 hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam);
324 /* FIXME : should we also return the previous hIcon here ??? */
325 STATIC_SetIcon(hwnd, hIcon, full_style);
326 break;
328 case SS_BITMAP:
330 HBITMAP hBitmap;
331 if(unicode)
332 hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam);
333 else
334 hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam);
335 STATIC_SetBitmap(hwnd, hBitmap, full_style);
336 break;
338 case SS_LEFT:
339 case SS_CENTER:
340 case SS_RIGHT:
341 case SS_SIMPLE:
342 case SS_LEFTNOWORDWRAP:
344 if (HIWORD(lParam))
346 if(unicode)
347 lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
348 else
349 lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
351 if (uMsg == WM_SETTEXT)
352 STATIC_TryPaintFcn( hwnd, full_style );
353 break;
355 default:
356 if (HIWORD(lParam))
358 if(unicode)
359 lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam );
360 else
361 lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
363 if(uMsg == WM_SETTEXT)
364 InvalidateRect(hwnd, NULL, TRUE);
366 return 1; /* success. FIXME: check text length */
368 case WM_SETFONT:
369 if ((style == SS_ICON) || (style == SS_BITMAP)) return 0;
370 SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam );
371 if (LOWORD(lParam))
372 InvalidateRect( hwnd, NULL, TRUE );
373 break;
375 case WM_GETFONT:
376 return GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
378 case WM_NCHITTEST:
379 if (full_style & SS_NOTIFY)
380 return HTCLIENT;
381 else
382 return HTTRANSPARENT;
384 case WM_GETDLGCODE:
385 return DLGC_STATIC;
387 case WM_LBUTTONDOWN:
388 case WM_NCLBUTTONDOWN:
389 if (full_style & SS_NOTIFY)
390 SendMessageW( GetParent(hwnd), WM_COMMAND,
391 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_CLICKED ), (LPARAM)hwnd);
392 return 0;
394 case WM_LBUTTONDBLCLK:
395 case WM_NCLBUTTONDBLCLK:
396 if (full_style & SS_NOTIFY)
397 SendMessageW( GetParent(hwnd), WM_COMMAND,
398 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DBLCLK ), (LPARAM)hwnd);
399 return 0;
401 case STM_GETIMAGE:
402 case STM_GETICON16:
403 case STM_GETICON:
404 return GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
406 case STM_SETIMAGE:
407 switch(wParam) {
408 case IMAGE_BITMAP:
409 lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
410 break;
411 case IMAGE_CURSOR:
412 FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
413 break;
414 case IMAGE_ENHMETAFILE:
415 FIXME("STM_SETIMAGE: Unhandled type IMAGE_ENHMETAFILE\n");
416 break;
417 case IMAGE_ICON:
418 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
419 break;
420 default:
421 FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
422 break;
424 InvalidateRect( hwnd, NULL, TRUE );
425 break;
427 case STM_SETICON16:
428 case STM_SETICON:
429 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
430 InvalidateRect( hwnd, NULL, TRUE );
431 break;
433 default:
434 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
435 DefWindowProcA(hwnd, uMsg, wParam, lParam);
437 return lResult;
440 /***********************************************************************
441 * StaticWndProcA
443 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
445 if (!IsWindow( hWnd )) return 0;
446 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
449 /***********************************************************************
450 * StaticWndProcW
452 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
454 if (!IsWindow( hWnd )) return 0;
455 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
458 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
460 DRAWITEMSTRUCT dis;
461 UINT id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID );
463 dis.CtlType = ODT_STATIC;
464 dis.CtlID = id;
465 dis.itemID = 0;
466 dis.itemAction = ODA_DRAWENTIRE;
467 dis.itemState = 0;
468 dis.hwndItem = hwnd;
469 dis.hDC = hdc;
470 dis.itemData = 0;
471 GetClientRect( hwnd, &dis.rcItem );
473 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
474 SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
477 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
479 RECT rc;
480 HBRUSH hBrush;
481 HFONT hFont;
482 WORD wFormat;
483 INT len;
484 WCHAR *text;
486 GetClientRect( hwnd, &rc);
488 switch (style & SS_TYPEMASK)
490 case SS_LEFT:
491 wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK;
492 break;
494 case SS_CENTER:
495 wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK;
496 break;
498 case SS_RIGHT:
499 wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK;
500 break;
502 case SS_SIMPLE:
503 wFormat = DT_LEFT | DT_SINGLELINE;
504 break;
506 case SS_LEFTNOWORDWRAP:
507 wFormat = DT_LEFT | DT_EXPANDTABS;
508 break;
510 default:
511 return;
514 if (style & SS_NOPREFIX)
515 wFormat |= DT_NOPREFIX;
516 if ((style & SS_CENTERIMAGE) && (style & SS_TYPEMASK) != SS_SIMPLE)
517 wFormat |= DT_SINGLELINE | DT_VCENTER;
519 if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET ))) SelectObject( hdc, hFont );
521 if ((style & SS_NOPREFIX) || ((style & SS_TYPEMASK) != SS_SIMPLE))
523 hBrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
524 (WPARAM)hdc, (LPARAM)hwnd );
525 if (!hBrush) /* did the app forget to call defwindowproc ? */
526 hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
527 (WPARAM)hdc, (LPARAM)hwnd);
528 FillRect( hdc, &rc, hBrush );
530 if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
532 if (!(len = SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ))) return;
533 if (!(text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return;
534 SendMessageW( hwnd, WM_GETTEXT, len + 1, (LPARAM)text );
535 DrawTextW( hdc, text, -1, &rc, wFormat );
536 HeapFree( GetProcessHeap(), 0, text );
539 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
541 RECT rc;
542 HBRUSH hBrush;
544 GetClientRect( hwnd, &rc);
546 switch (style & SS_TYPEMASK)
548 case SS_BLACKRECT:
549 hBrush = CreateSolidBrush(color_3ddkshadow);
550 FillRect( hdc, &rc, hBrush );
551 break;
552 case SS_GRAYRECT:
553 hBrush = CreateSolidBrush(color_3dshadow);
554 FillRect( hdc, &rc, hBrush );
555 break;
556 case SS_WHITERECT:
557 hBrush = CreateSolidBrush(color_3dhighlight);
558 FillRect( hdc, &rc, hBrush );
559 break;
560 case SS_BLACKFRAME:
561 hBrush = CreateSolidBrush(color_3ddkshadow);
562 FrameRect( hdc, &rc, hBrush );
563 break;
564 case SS_GRAYFRAME:
565 hBrush = CreateSolidBrush(color_3dshadow);
566 FrameRect( hdc, &rc, hBrush );
567 break;
568 case SS_WHITEFRAME:
569 hBrush = CreateSolidBrush(color_3dhighlight);
570 FrameRect( hdc, &rc, hBrush );
571 break;
572 default:
573 return;
575 DeleteObject( hBrush );
579 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
581 RECT rc;
582 HBRUSH hbrush;
583 HICON hIcon;
584 INT x, y;
586 GetClientRect( hwnd, &rc );
587 hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
588 (WPARAM)hdc, (LPARAM)hwnd );
589 FillRect( hdc, &rc, hbrush );
590 hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
591 if (style & SS_CENTERIMAGE)
593 CURSORICONINFO *info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL;
594 x = (rc.right - rc.left)/2 - (info ? info->nWidth/2 : 0);
595 y = (rc.bottom - rc.top)/2 - (info ? info->nHeight/2 : 0);
597 else
599 x = rc.left;
600 y = rc.top;
602 if (hIcon)
603 DrawIcon( hdc, x, y, hIcon );
606 static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
608 HDC hMemDC;
609 HBITMAP hBitmap, oldbitmap;
611 /* message is still sent, even if the returned brush is not used */
612 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
613 (WPARAM)hdc, (LPARAM)hwnd );
615 if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
617 INT x, y;
618 BITMAP bm;
620 if(GetObjectType(hBitmap) != OBJ_BITMAP) return;
621 if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
622 GetObjectW(hBitmap, sizeof(bm), &bm);
623 oldbitmap = SelectObject(hMemDC, hBitmap);
624 if (style & SS_CENTERIMAGE)
626 RECT rcClient;
627 GetClientRect(hwnd, &rcClient);
628 x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
629 y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
631 else
633 x = 0;
634 y = 0;
636 BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
637 SRCCOPY);
638 SelectObject(hMemDC, oldbitmap);
639 DeleteDC(hMemDC);
644 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
646 RECT rc;
648 GetClientRect( hwnd, &rc );
649 switch (style & SS_TYPEMASK)
651 case SS_ETCHEDHORZ:
652 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
653 break;
654 case SS_ETCHEDVERT:
655 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
656 break;
657 case SS_ETCHEDFRAME:
658 DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);
659 break;