netapi32: Default to CP_UTF8 when WINEUNIXCP is not set.
[wine.git] / dlls / comctl32 / theme_dialog.c
blob0f7835ae32fedad486060bc66e1a6a0596441128
1 /*
2 * Theming - Dialogs
4 * Copyright (c) 2005 by Frank Richter
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
23 #include <string.h>
24 #include <stdlib.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "uxtheme.h"
31 #include "vssym32.h"
32 #include "comctl32.h"
33 #include "wine/debug.h"
35 /**********************************************************************
36 * The dialog subclass window proc.
38 LRESULT CALLBACK THEMING_DialogSubclassProc (HWND hWnd, UINT msg,
39 WPARAM wParam, LPARAM lParam,
40 ULONG_PTR dwRefData)
42 HTHEME theme = GetWindowTheme ( hWnd );
43 static const WCHAR themeClass[] = L"Window";
44 BOOL themingActive = IsThemeDialogTextureEnabled (hWnd);
45 BOOL doTheming = themingActive && (theme != NULL);
46 LRESULT result;
48 switch (msg)
50 case WM_CREATE:
51 result = THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
52 theme = OpenThemeData( hWnd, themeClass );
53 return result;
55 case WM_DESTROY:
56 CloseThemeData ( theme );
57 SetWindowTheme( hWnd, NULL, NULL );
58 OpenThemeData( hWnd, NULL );
59 return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
61 case WM_THEMECHANGED:
62 CloseThemeData ( theme );
63 OpenThemeData( hWnd, themeClass );
64 InvalidateRect( hWnd, NULL, TRUE );
65 return 0;
67 case WM_ERASEBKGND:
68 if (!doTheming) return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
70 RECT rc;
71 WNDPROC dlgp = (WNDPROC)GetWindowLongPtrW (hWnd, DWLP_DLGPROC);
72 if (!CallWindowProcW(dlgp, hWnd, msg, wParam, lParam))
74 /* Draw background*/
75 GetClientRect (hWnd, &rc);
76 if (IsThemePartDefined (theme, WP_DIALOG, 0))
77 /* Although there is a theme for the WINDOW class/DIALOG part,
78 * but I[res] haven't seen Windows using it yet... Even when
79 * dialog theming is activated, the good ol' BTNFACE
80 * background seems to be used. */
81 #if 0
82 DrawThemeBackground (theme, (HDC)wParam, WP_DIALOG, 0, &rc,
83 NULL);
84 #endif
85 return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
86 else
87 /* We might have gotten a TAB theme class, so check if we can
88 * draw as a tab page. */
89 if (IsThemePartDefined (theme, TABP_BODY, 0))
90 DrawThemeBackground (theme, (HDC)wParam, TABP_BODY, 0, &rc,
91 NULL);
92 else
93 return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
95 return 1;
98 case WM_CTLCOLORSTATIC:
99 if (!doTheming) return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
101 WNDPROC dlgp = (WNDPROC)GetWindowLongPtrW (hWnd, DWLP_DLGPROC);
102 LRESULT result = CallWindowProcW(dlgp, hWnd, msg, wParam, lParam);
103 if (!result)
105 /* Override defaults with more suitable values when themed */
106 HDC controlDC = (HDC)wParam;
107 HWND controlWnd = (HWND)lParam;
108 WCHAR controlClass[32];
109 RECT rc;
111 GetClassNameW (controlWnd, controlClass, ARRAY_SIZE(controlClass));
112 if (lstrcmpiW (controlClass, WC_STATICW) == 0)
114 /* Static control - draw parent background and set text to
115 * transparent, so it looks right on tab pages. */
116 GetClientRect (controlWnd, &rc);
117 DrawThemeParentBackground (controlWnd, controlDC, &rc);
118 SetBkMode (controlDC, TRANSPARENT);
120 /* Return NULL brush since we painted the BG already */
121 return (LRESULT)GetStockObject (NULL_BRUSH);
123 else
124 return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
127 return result;
130 default:
131 /* Call old proc */
132 return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
134 return 0;