2015-08-31 09:55:33 -05:00
|
|
|
// 30 may 2015
|
|
|
|
#include "uipriv_windows.h"
|
|
|
|
|
|
|
|
// This just defines the implementation of the tab page HWND itself.
|
|
|
|
// The actual work of hosting a tab page's control is in child.c.
|
|
|
|
|
|
|
|
// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
|
|
|
|
#define tabMargin 7
|
|
|
|
|
2015-08-31 16:50:23 -05:00
|
|
|
void tabPageMargins(HWND hwnd, intmax_t *left, intmax_t *top, intmax_t *right, intmax_t *bottom)
|
2015-08-31 09:55:33 -05:00
|
|
|
{
|
|
|
|
uiWindowsSizing *d;
|
|
|
|
|
|
|
|
d = uiWindowsNewSizing(hwnd);
|
|
|
|
*left = uiWindowsDlgUnitsToX(tabMargin, d->BaseX);
|
|
|
|
*top = uiWindowsDlgUnitsToY(tabMargin, d->BaseY);
|
|
|
|
*right = *left;
|
|
|
|
*bottom = *top;
|
|
|
|
uiWindowsFreeSizing(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
// dummy dialog procedure; see below for details
|
|
|
|
// let's handle parent messages here to avoid needing to subclass
|
|
|
|
static INT_PTR CALLBACK dlgproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
LRESULT lResult;
|
|
|
|
|
|
|
|
if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE) {
|
|
|
|
SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, (LONG_PTR) lResult);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
// unthemed dialogs don't respond to WM_PRINTCLIENT
|
|
|
|
// fortunately they don't have any special painting
|
|
|
|
if (uMsg == WM_PRINTCLIENT) {
|
|
|
|
// don't worry about the return value; hopefully DefWindowProcW() caught it (if not the dialog procedure itself)
|
|
|
|
// we COULD paint the dialog background brush ourselves but meh, it works
|
|
|
|
SendMessageW(hwnd, WM_ERASEBKGND, wParam, lParam);
|
|
|
|
// and pretend we did nothing just so the themed dialog can still paint its content
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (uMsg == WM_INITDIALOG)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND newTabPage(void)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
// unfortunately this needs to be a proper dialog for EnableThemeDialogTexture() to work; CreateWindowExW() won't suffice
|
|
|
|
hwnd = CreateDialogW(hInstance, MAKEINTRESOURCE(rcTabPageDialog),
|
|
|
|
utilWindow, dlgproc);
|
2015-08-31 16:50:23 -05:00
|
|
|
if (hwnd == NULL)
|
2015-08-31 09:55:33 -05:00
|
|
|
logLastError("error creating tab page in newTabPage()");
|
|
|
|
|
2015-08-31 16:50:23 -05:00
|
|
|
hr = EnableThemeDialogTexture(hwnd, ETDT_ENABLE | ETDT_USETABTEXTURE | ETDT_ENABLETAB);
|
2015-08-31 09:55:33 -05:00
|
|
|
if (hr != S_OK)
|
|
|
|
logHRESULT("error setting tab page background in newTabPage()", hr);
|
|
|
|
|
2015-09-01 10:46:53 -05:00
|
|
|
// and start the tab page hidden
|
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
|
2015-08-31 09:55:33 -05:00
|
|
|
return hwnd;
|
|
|
|
}
|