More work on winrebarexplorertheme.cpp. It registers themes.
This commit is contained in:
parent
91fe6e7c47
commit
d082b4efa4
|
@ -35,6 +35,7 @@ HINSTANCE hInstance;
|
||||||
HWND rebar;
|
HWND rebar;
|
||||||
HWND leftbar;
|
HWND leftbar;
|
||||||
HWND rightbar;
|
HWND rightbar;
|
||||||
|
HWND rebarCombo;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
const WCHAR *text;
|
const WCHAR *text;
|
||||||
|
@ -47,6 +48,43 @@ static struct {
|
||||||
{ L"New folder", FALSE },
|
{ L"New folder", FALSE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const WCHAR *buttons[] = {
|
||||||
|
L"SetWindowTheme()",
|
||||||
|
L"Custom Draw Vista",
|
||||||
|
L"Custom Draw 7",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const WCHAR *rebarThemes[] = {
|
||||||
|
L"NULL",
|
||||||
|
L"",
|
||||||
|
L"AlternateRebar",
|
||||||
|
L"BrowserTabBar",
|
||||||
|
L"Communications",
|
||||||
|
L"Default",
|
||||||
|
L"ExplorerBar",
|
||||||
|
L"Help",
|
||||||
|
L"InactiveNavbar",
|
||||||
|
L"InactiveNavbarComposited",
|
||||||
|
L"ITBarBase",
|
||||||
|
L"MaxInactiveNavbar",
|
||||||
|
L"MaxInactiveNavbarComposited",
|
||||||
|
L"MaxNavbar",
|
||||||
|
L"MaxNavbarComposited",
|
||||||
|
L"Media",
|
||||||
|
L"Navbar",
|
||||||
|
L"NavbarBase",
|
||||||
|
L"NavbarComposited",
|
||||||
|
L"NavbarNonTopmost",
|
||||||
|
L"Rebar",
|
||||||
|
L"RebarStyle",
|
||||||
|
L"TaskBar",
|
||||||
|
L"TaskBarComposited",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO toolbarThemes
|
||||||
|
|
||||||
void onWM_CREATE(HWND hwnd)
|
void onWM_CREATE(HWND hwnd)
|
||||||
{
|
{
|
||||||
TBBUTTON tbb[5];
|
TBBUTTON tbb[5];
|
||||||
|
@ -54,6 +92,9 @@ void onWM_CREATE(HWND hwnd)
|
||||||
DWORD tbbtnsize;
|
DWORD tbbtnsize;
|
||||||
LONG tbsizex, tbsizey;
|
LONG tbsizex, tbsizey;
|
||||||
REBARBANDINFOW rbi;
|
REBARBANDINFOW rbi;
|
||||||
|
HWND button;
|
||||||
|
LONG buttonx, buttony;
|
||||||
|
LONG combox, comboy;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rebar = CreateWindowExW(0,
|
rebar = CreateWindowExW(0,
|
||||||
|
@ -111,6 +152,37 @@ void onWM_CREATE(HWND hwnd)
|
||||||
rbi.cxIdeal = tbsizex;
|
rbi.cxIdeal = tbsizex;
|
||||||
if (SendMessageW(rebar, RB_INSERTBANDW, (WPARAM) (-1), (LPARAM) (&rbi)) == 0)
|
if (SendMessageW(rebar, RB_INSERTBANDW, (WPARAM) (-1), (LPARAM) (&rbi)) == 0)
|
||||||
diele("RB_INSERTBANDW leftbar");
|
diele("RB_INSERTBANDW leftbar");
|
||||||
|
|
||||||
|
buttonx = 10;
|
||||||
|
buttony = 40;
|
||||||
|
#define buttonwid 200
|
||||||
|
#define buttonht 25
|
||||||
|
for (i = 0; buttons[i] != NULL; i++) {
|
||||||
|
button = CreateWindowExW(0,
|
||||||
|
L"BUTTON", buttons[i],
|
||||||
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
||||||
|
buttonx, buttony,
|
||||||
|
buttonwid, buttonht,
|
||||||
|
hwnd, (HMENU) (200 + i), hInstance, NULL);
|
||||||
|
if (button == NULL)
|
||||||
|
diele("CreateWIndowExW(L\"BUTTON\")");
|
||||||
|
if (i == 0) {
|
||||||
|
combox = buttonx + buttonwid + 5;
|
||||||
|
comboy = buttony;
|
||||||
|
}
|
||||||
|
buttony += buttonht + 5;
|
||||||
|
}
|
||||||
|
rebarCombo = CreateWindowExW(WS_EX_CLIENTEDGE,
|
||||||
|
L"COMBOBOX", L"",
|
||||||
|
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
|
||||||
|
combox, comboy,
|
||||||
|
buttonwid, buttonht,
|
||||||
|
hwnd, (HMENU) 300, hInstance, NULL);
|
||||||
|
if (rebarCombo == NULL)
|
||||||
|
diele("CreateWindowExW(L\"COMBOBOX\")");
|
||||||
|
for (i = 0; rebarThemes[i] != NULL; i++)
|
||||||
|
// TODO check error
|
||||||
|
SendMessageW(rebarCombo, CB_ADDSTRING, 0, (LPARAM) (rebarThemes[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO it seems like I shouldn't have to do this?
|
// TODO it seems like I shouldn't have to do this?
|
||||||
|
@ -129,6 +201,54 @@ void repositionRebar(HWND hwnd)
|
||||||
SendMessageW(rebar, RB_SETBANDWIDTH, 0, win.right - win.left);
|
SendMessageW(rebar, RB_SETBANDWIDTH, 0, win.right - win.left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO check errors
|
||||||
|
void handleEvents(HWND hwnd, WPARAM wParam)
|
||||||
|
{
|
||||||
|
LRESULT n;
|
||||||
|
const WCHAR *selRebar = NULL, *selToolbar = NULL;
|
||||||
|
WCHAR *bufRebar = NULL, *bufToolbar = NULL;
|
||||||
|
BOOL changeRebar = FALSE, changeToolbar = FALSE;
|
||||||
|
|
||||||
|
switch (wParam) {
|
||||||
|
case MAKEWPARAM(300, CBN_SELCHANGE):
|
||||||
|
n = SendMessageW(rebarCombo, CB_GETCURSEL, 0, 0);
|
||||||
|
selRebar = rebarThemes[n];
|
||||||
|
changeRebar = TRUE;
|
||||||
|
break;
|
||||||
|
case MAKEWPARAM(200, BN_CLICKED):
|
||||||
|
n = SendMessageW(rebarCombo, WM_GETTEXTLENGTH, 0, 0);
|
||||||
|
bufRebar = new WCHAR[n + 1];
|
||||||
|
GetWindowTextW(rebarCombo, bufRebar, n + 1);
|
||||||
|
selRebar = bufRebar;
|
||||||
|
selToolbar = bufRebar;
|
||||||
|
changeRebar = TRUE;
|
||||||
|
changeToolbar = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (changeRebar) {
|
||||||
|
if (selRebar != NULL && wcscmp(selRebar, L"NULL") == 0)
|
||||||
|
selRebar = NULL;
|
||||||
|
if (selRebar != NULL && *selRebar != L'\0')
|
||||||
|
SendMessageW(rebar, RB_SETWINDOWTHEME, 0, (LPARAM) selRebar);
|
||||||
|
else
|
||||||
|
SetWindowTheme(rebar, selRebar, selRebar);
|
||||||
|
InvalidateRect(hwnd, NULL, TRUE);
|
||||||
|
}
|
||||||
|
if (changeToolbar) {
|
||||||
|
if (selToolbar != NULL && wcscmp(selToolbar, L"NULL") == 0)
|
||||||
|
selToolbar = NULL;
|
||||||
|
if (selToolbar != NULL && *selToolbar != L'\0')
|
||||||
|
SendMessageW(leftbar, TB_SETWINDOWTHEME, 0, (LPARAM) selToolbar);
|
||||||
|
else
|
||||||
|
SetWindowTheme(leftbar, selToolbar, selToolbar);
|
||||||
|
InvalidateRect(hwnd, NULL, TRUE);
|
||||||
|
}
|
||||||
|
if (bufRebar != NULL)
|
||||||
|
delete[] bufRebar;
|
||||||
|
if (bufToolbar != NULL)
|
||||||
|
delete[] bufToolbar;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
|
@ -141,6 +261,9 @@ LRESULT CALLBACK wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
repositionRebar(hwnd);
|
repositionRebar(hwnd);
|
||||||
break;
|
break;
|
||||||
|
case WM_COMMAND:
|
||||||
|
handleEvents(hwnd, wParam);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue