comctl32/propsheet: Handle page dialog tab texture in DefDlgProc().
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9083b1e8b1
commit
d1c0990344
|
@ -63,7 +63,6 @@
|
||||||
#include "prsht.h"
|
#include "prsht.h"
|
||||||
#include "comctl32.h"
|
#include "comctl32.h"
|
||||||
#include "uxtheme.h"
|
#include "uxtheme.h"
|
||||||
#include "vsstyle.h"
|
|
||||||
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
|
@ -141,7 +140,6 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const WCHAR PropSheetInfoStr[] = L"PropertySheetInfo";
|
static const WCHAR PropSheetInfoStr[] = L"PropertySheetInfo";
|
||||||
static const WCHAR PropSheetPageBackgroundBrush[] = L"PropSheetPageBackgroundBrush";
|
|
||||||
|
|
||||||
#define PSP_INTERNAL_UNICODE 0x80000000
|
#define PSP_INTERNAL_UNICODE 0x80000000
|
||||||
|
|
||||||
|
@ -1198,136 +1196,6 @@ PROPSHEET_WizardSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
|
||||||
return DefSubclassProc(hwnd, uMsg, wParam, lParam);
|
return DefSubclassProc(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HBRUSH get_propsheet_background_brush(HWND hwnd)
|
|
||||||
{
|
|
||||||
HBITMAP bitmap, old_bitmap;
|
|
||||||
HDC hdc, hdc_screen;
|
|
||||||
HBRUSH brush;
|
|
||||||
HTHEME theme;
|
|
||||||
HRESULT hr;
|
|
||||||
RECT rect;
|
|
||||||
SIZE size;
|
|
||||||
|
|
||||||
brush = GetPropW(hwnd, PropSheetPageBackgroundBrush);
|
|
||||||
if (brush)
|
|
||||||
return brush;
|
|
||||||
|
|
||||||
theme = OpenThemeData(NULL, L"Tab");
|
|
||||||
if (!theme)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
hr = GetThemePartSize(theme, NULL, TABP_BODY, 0, NULL, TS_TRUE, &size);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
size.cx = 10;
|
|
||||||
size.cy = 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
hdc_screen = GetDC(NULL);
|
|
||||||
hdc = CreateCompatibleDC(hdc_screen);
|
|
||||||
bitmap = CreateCompatibleBitmap(hdc_screen, size.cx, size.cy);
|
|
||||||
old_bitmap = SelectObject(hdc, bitmap);
|
|
||||||
|
|
||||||
SetRect(&rect, 0, 0, size.cx, size.cy);
|
|
||||||
/* FIXME: XP draws the tab body bitmap directly without transparency even if there is */
|
|
||||||
FillRect(hdc, &rect, GetSysColorBrush(COLOR_3DFACE));
|
|
||||||
hr = DrawThemeBackground(theme, hdc, TABP_BODY, 0, &rect, NULL);
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
|
||||||
brush = CreatePatternBrush(bitmap);
|
|
||||||
SetPropW(hwnd, PropSheetPageBackgroundBrush, brush);
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectObject(hdc, old_bitmap);
|
|
||||||
DeleteDC(hdc);
|
|
||||||
ReleaseDC(NULL, hdc_screen);
|
|
||||||
CloseThemeData(theme);
|
|
||||||
return brush;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Subclassing window procedure for theming dialogs in property sheet pages */
|
|
||||||
static LRESULT CALLBACK PROPSHEET_ThemedSubclassProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
|
|
||||||
UINT_PTR id, DWORD_PTR ref)
|
|
||||||
{
|
|
||||||
POINT org, old_org;
|
|
||||||
LOGBRUSH logbrush;
|
|
||||||
WNDPROC dlgproc;
|
|
||||||
HBRUSH brush;
|
|
||||||
LRESULT lr;
|
|
||||||
RECT rect;
|
|
||||||
HDC hdc;
|
|
||||||
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case WM_THEMECHANGED:
|
|
||||||
{
|
|
||||||
brush = GetPropW(hwnd, PropSheetPageBackgroundBrush);
|
|
||||||
if (brush)
|
|
||||||
{
|
|
||||||
RemovePropW(hwnd, PropSheetPageBackgroundBrush);
|
|
||||||
if (GetObjectW(brush, sizeof(logbrush), &logbrush) == sizeof(logbrush))
|
|
||||||
DeleteObject((HBITMAP)logbrush.lbHatch);
|
|
||||||
DeleteObject(brush);
|
|
||||||
}
|
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WM_ERASEBKGND:
|
|
||||||
{
|
|
||||||
if (!IsThemeActive() || !IsThemeDialogTextureEnabled(hwnd))
|
|
||||||
break;
|
|
||||||
|
|
||||||
dlgproc = (WNDPROC)GetWindowLongPtrW(hwnd, DWLP_DLGPROC);
|
|
||||||
lr = CallWindowProcW(dlgproc, hwnd, msg, wp, lp);
|
|
||||||
if (lr)
|
|
||||||
return lr;
|
|
||||||
|
|
||||||
brush = get_propsheet_background_brush(hwnd);
|
|
||||||
if (!brush)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Using FillRect() to draw background could introduce a tiling effect if the destination
|
|
||||||
* rectangle is larger than the pattern brush size, which is usually 10x600. This bug is
|
|
||||||
* visible on property sheet pages if system DPI is set to 192. However, the same bug also
|
|
||||||
* exists on XP and explains why vista+ don't use gradient tab body background anymore */
|
|
||||||
hdc = (HDC)wp;
|
|
||||||
GetViewportOrgEx(hdc, &org);
|
|
||||||
SetBrushOrgEx(hdc, org.x, org.y, &old_org);
|
|
||||||
GetClientRect(hwnd, &rect);
|
|
||||||
FillRect(hdc, &rect, brush);
|
|
||||||
SetBrushOrgEx(hdc, old_org.x, old_org.y, NULL);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_CTLCOLORSTATIC:
|
|
||||||
{
|
|
||||||
if (!IsThemeActive() || !IsThemeDialogTextureEnabled(hwnd))
|
|
||||||
break;
|
|
||||||
|
|
||||||
dlgproc = (WNDPROC)GetWindowLongPtrW(hwnd, DWLP_DLGPROC);
|
|
||||||
lr = CallWindowProcW(dlgproc, hwnd, msg, wp, lp);
|
|
||||||
if (lr)
|
|
||||||
return lr;
|
|
||||||
|
|
||||||
brush = get_propsheet_background_brush(hwnd);
|
|
||||||
if (!brush)
|
|
||||||
break;
|
|
||||||
|
|
||||||
hdc = (HDC)wp;
|
|
||||||
SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
|
||||||
|
|
||||||
org.x = 0;
|
|
||||||
org.y = 0;
|
|
||||||
MapWindowPoints((HWND)lp, hwnd, &org, 1);
|
|
||||||
SetBrushOrgEx(hdc, -org.x, -org.y, NULL);
|
|
||||||
return (LRESULT)brush;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefSubclassProc(hwnd, msg, wp, lp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the size of an in-memory Template
|
* Get the size of an in-memory Template
|
||||||
*
|
*
|
||||||
|
@ -1599,10 +1467,6 @@ static BOOL PROPSHEET_CreatePage(HWND hwndParent,
|
||||||
SetWindowSubclass(hwndPage, PROPSHEET_WizardSubclassProc, 1,
|
SetWindowSubclass(hwndPage, PROPSHEET_WizardSubclassProc, 1,
|
||||||
(DWORD_PTR)ppshpage);
|
(DWORD_PTR)ppshpage);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
SetWindowSubclass(hwndPage, PROPSHEET_ThemedSubclassProc, 1, (DWORD_PTR)ppshpage);
|
|
||||||
}
|
|
||||||
if (!(psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD))
|
if (!(psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD))
|
||||||
EnableThemeDialogTexture (hwndPage, ETDT_ENABLETAB);
|
EnableThemeDialogTexture (hwndPage, ETDT_ENABLETAB);
|
||||||
|
|
||||||
|
@ -2487,8 +2351,6 @@ static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
||||||
PropSheetInfo * psInfo = GetPropW(hwndDlg, PropSheetInfoStr);
|
PropSheetInfo * psInfo = GetPropW(hwndDlg, PropSheetInfoStr);
|
||||||
HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
||||||
PropPageInfo* oldPages;
|
PropPageInfo* oldPages;
|
||||||
LOGBRUSH logbrush;
|
|
||||||
HBRUSH brush;
|
|
||||||
|
|
||||||
TRACE("index %d, hpage %p\n", index, hpage);
|
TRACE("index %d, hpage %p\n", index, hpage);
|
||||||
if (!psInfo) {
|
if (!psInfo) {
|
||||||
|
@ -2546,18 +2408,6 @@ static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
||||||
RemoveWindowSubclass(psInfo->proppage[index].hwndPage,
|
RemoveWindowSubclass(psInfo->proppage[index].hwndPage,
|
||||||
PROPSHEET_WizardSubclassProc, 1);
|
PROPSHEET_WizardSubclassProc, 1);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
RemoveWindowSubclass(psInfo->proppage[index].hwndPage, PROPSHEET_ThemedSubclassProc, 1);
|
|
||||||
brush = GetPropW(psInfo->proppage[index].hwndPage, PropSheetPageBackgroundBrush);
|
|
||||||
if (brush)
|
|
||||||
{
|
|
||||||
RemovePropW(psInfo->proppage[index].hwndPage, PropSheetPageBackgroundBrush);
|
|
||||||
if (GetObjectW(brush, sizeof(logbrush), &logbrush) == sizeof(logbrush))
|
|
||||||
DeleteObject((HBITMAP)logbrush.lbHatch);
|
|
||||||
DeleteObject(brush);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Destroy page dialog window */
|
/* Destroy page dialog window */
|
||||||
DestroyWindow(psInfo->proppage[index].hwndPage);
|
DestroyWindow(psInfo->proppage[index].hwndPage);
|
||||||
|
@ -2855,8 +2705,6 @@ static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page, const PropSheetInfo* psIn
|
||||||
*/
|
*/
|
||||||
static void PROPSHEET_CleanUp(HWND hwndDlg)
|
static void PROPSHEET_CleanUp(HWND hwndDlg)
|
||||||
{
|
{
|
||||||
LOGBRUSH logbrush;
|
|
||||||
HBRUSH brush;
|
|
||||||
int i;
|
int i;
|
||||||
PropSheetInfo* psInfo = RemovePropW(hwndDlg, PropSheetInfoStr);
|
PropSheetInfo* psInfo = RemovePropW(hwndDlg, PropSheetInfoStr);
|
||||||
|
|
||||||
|
@ -2877,18 +2725,6 @@ static void PROPSHEET_CleanUp(HWND hwndDlg)
|
||||||
RemoveWindowSubclass(psInfo->proppage[i].hwndPage,
|
RemoveWindowSubclass(psInfo->proppage[i].hwndPage,
|
||||||
PROPSHEET_WizardSubclassProc, 1);
|
PROPSHEET_WizardSubclassProc, 1);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
RemoveWindowSubclass(psInfo->proppage[i].hwndPage, PROPSHEET_ThemedSubclassProc, 1);
|
|
||||||
brush = GetPropW(psInfo->proppage[i].hwndPage, PropSheetPageBackgroundBrush);
|
|
||||||
if (brush)
|
|
||||||
{
|
|
||||||
RemovePropW(psInfo->proppage[i].hwndPage, PropSheetPageBackgroundBrush);
|
|
||||||
if (GetObjectW(brush, sizeof(logbrush), &logbrush) == sizeof(logbrush))
|
|
||||||
DeleteObject((HBITMAP)logbrush.lbHatch);
|
|
||||||
DeleteObject(brush);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(psInfo->proppage[i].hwndPage)
|
if(psInfo->proppage[i].hwndPage)
|
||||||
DestroyWindow(psInfo->proppage[i].hwndPage);
|
DestroyWindow(psInfo->proppage[i].hwndPage);
|
||||||
|
|
Loading…
Reference in New Issue