2005-08-19 12:05:34 +02:00
|
|
|
/*
|
|
|
|
* Theming - Dialogs
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005 by Frank Richter
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-19 12:05:34 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "uxtheme.h"
|
2021-07-20 15:04:24 +02:00
|
|
|
#include "uxthemedll.h"
|
2011-06-27 14:21:48 +02:00
|
|
|
#include "vssym32.h"
|
2005-08-19 12:05:34 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2021-07-20 15:04:24 +02:00
|
|
|
LRESULT WINAPI UXTHEME_DefDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
|
2005-08-19 12:05:34 +02:00
|
|
|
{
|
|
|
|
HTHEME theme = GetWindowTheme ( hWnd );
|
2020-11-16 15:26:34 +01:00
|
|
|
static const WCHAR themeClass[] = L"Window";
|
2005-08-19 12:05:34 +02:00
|
|
|
BOOL themingActive = IsThemeDialogTextureEnabled (hWnd);
|
|
|
|
BOOL doTheming = themingActive && (theme != NULL);
|
|
|
|
LRESULT result;
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
2021-07-20 15:04:24 +02:00
|
|
|
result = user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-19 12:05:34 +02:00
|
|
|
theme = OpenThemeData( hWnd, themeClass );
|
|
|
|
return result;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
CloseThemeData ( theme );
|
2011-06-27 14:22:40 +02:00
|
|
|
SetWindowTheme( hWnd, NULL, NULL );
|
|
|
|
OpenThemeData( hWnd, NULL );
|
2021-07-20 15:04:24 +02:00
|
|
|
return user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-19 12:05:34 +02:00
|
|
|
|
|
|
|
case WM_THEMECHANGED:
|
|
|
|
CloseThemeData ( theme );
|
|
|
|
OpenThemeData( hWnd, themeClass );
|
|
|
|
InvalidateRect( hWnd, NULL, TRUE );
|
|
|
|
return 0;
|
2021-04-27 05:35:28 +02:00
|
|
|
|
2005-08-19 12:05:34 +02:00
|
|
|
case WM_ERASEBKGND:
|
2021-07-20 15:04:24 +02:00
|
|
|
if (!doTheming) return user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-19 12:05:34 +02:00
|
|
|
{
|
|
|
|
RECT rc;
|
2006-05-26 16:34:09 +02:00
|
|
|
WNDPROC dlgp = (WNDPROC)GetWindowLongPtrW (hWnd, DWLP_DLGPROC);
|
|
|
|
if (!CallWindowProcW(dlgp, hWnd, msg, wParam, lParam))
|
2005-08-19 12:05:34 +02:00
|
|
|
{
|
|
|
|
/* Draw background*/
|
|
|
|
GetClientRect (hWnd, &rc);
|
|
|
|
if (IsThemePartDefined (theme, WP_DIALOG, 0))
|
|
|
|
/* Although there is a theme for the WINDOW class/DIALOG part,
|
|
|
|
* but I[res] haven't seen Windows using it yet... Even when
|
|
|
|
* dialog theming is activated, the good ol' BTNFACE
|
|
|
|
* background seems to be used. */
|
|
|
|
#if 0
|
|
|
|
DrawThemeBackground (theme, (HDC)wParam, WP_DIALOG, 0, &rc,
|
|
|
|
NULL);
|
|
|
|
#endif
|
2021-07-20 15:04:24 +02:00
|
|
|
return user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-19 12:05:34 +02:00
|
|
|
else
|
|
|
|
/* We might have gotten a TAB theme class, so check if we can
|
|
|
|
* draw as a tab page. */
|
|
|
|
if (IsThemePartDefined (theme, TABP_BODY, 0))
|
|
|
|
DrawThemeBackground (theme, (HDC)wParam, TABP_BODY, 0, &rc,
|
|
|
|
NULL);
|
|
|
|
else
|
2021-07-20 15:04:24 +02:00
|
|
|
return user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-19 12:05:34 +02:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-08-25 17:20:48 +02:00
|
|
|
case WM_CTLCOLORSTATIC:
|
2021-07-20 15:04:24 +02:00
|
|
|
if (!doTheming) return user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-25 17:20:48 +02:00
|
|
|
{
|
2006-05-26 16:34:09 +02:00
|
|
|
WNDPROC dlgp = (WNDPROC)GetWindowLongPtrW (hWnd, DWLP_DLGPROC);
|
|
|
|
LRESULT result = CallWindowProcW(dlgp, hWnd, msg, wParam, lParam);
|
2005-08-25 17:20:48 +02:00
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
/* Override defaults with more suitable values when themed */
|
|
|
|
HDC controlDC = (HDC)wParam;
|
|
|
|
HWND controlWnd = (HWND)lParam;
|
|
|
|
WCHAR controlClass[32];
|
|
|
|
RECT rc;
|
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
GetClassNameW (controlWnd, controlClass, ARRAY_SIZE(controlClass));
|
2005-08-25 17:20:48 +02:00
|
|
|
if (lstrcmpiW (controlClass, WC_STATICW) == 0)
|
|
|
|
{
|
|
|
|
/* Static control - draw parent background and set text to
|
|
|
|
* transparent, so it looks right on tab pages. */
|
|
|
|
GetClientRect (controlWnd, &rc);
|
|
|
|
DrawThemeParentBackground (controlWnd, controlDC, &rc);
|
|
|
|
SetBkMode (controlDC, TRANSPARENT);
|
|
|
|
|
|
|
|
/* Return NULL brush since we painted the BG already */
|
|
|
|
return (LRESULT)GetStockObject (NULL_BRUSH);
|
|
|
|
}
|
|
|
|
else
|
2021-07-20 15:04:24 +02:00
|
|
|
return user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-25 17:20:48 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-08-19 12:05:34 +02:00
|
|
|
default:
|
|
|
|
/* Call old proc */
|
2021-07-20 15:04:24 +02:00
|
|
|
return user_api.pDefDlgProc(hWnd, msg, wParam, lParam, unicode);
|
2005-08-19 12:05:34 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|