Refined icon loading and tried to expand the winrebarexplorertheme test a bit more elaborate. This is going badly again...
This commit is contained in:
parent
79d1d58af2
commit
ddd6afbf36
|
@ -13,12 +13,11 @@
|
||||||
#include <uxtheme.h>
|
#include <uxtheme.h>
|
||||||
#include <vsstyle.h>
|
#include <vsstyle.h>
|
||||||
#include <vssym32.h>
|
#include <vssym32.h>
|
||||||
#include <shellapi.h>
|
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// cl winrebarexplorertheme.cpp -MT -link user32.lib kernel32.lib gdi32.lib comctl32.lib uxtheme.lib msimg32.lib shell32.lib windows.res
|
// cl winrebarexplorertheme.cpp -MT -link user32.lib kernel32.lib gdi32.lib comctl32.lib uxtheme.lib msimg32.lib windows.res
|
||||||
|
|
||||||
void diele(const char *func)
|
void diele(const char *func)
|
||||||
{
|
{
|
||||||
|
@ -43,8 +42,10 @@ HWND rebarCombo;
|
||||||
HWND toolbarCombo;
|
HWND toolbarCombo;
|
||||||
HWND toolbarTransparentCheckbox;
|
HWND toolbarTransparentCheckbox;
|
||||||
|
|
||||||
|
HICON shieldIcon;
|
||||||
|
HICON applicationIcon;
|
||||||
HICON helpIcon;
|
HICON helpIcon;
|
||||||
HIMAGELIST helpList;
|
HIMAGELIST rightList;
|
||||||
|
|
||||||
#define toolbarStyles (WS_CHILD | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | TBSTYLE_FLAT)
|
#define toolbarStyles (WS_CHILD | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | TBSTYLE_FLAT)
|
||||||
|
|
||||||
|
@ -337,7 +338,8 @@ void onWM_CREATE(HWND hwnd)
|
||||||
if (rightbar == NULL)
|
if (rightbar == NULL)
|
||||||
diele("CreateWindowExW(TOOLBARCLASSNAMEW) rightbar");
|
diele("CreateWindowExW(TOOLBARCLASSNAMEW) rightbar");
|
||||||
SendMessageW(rightbar, TB_BUTTONSTRUCTSIZE, sizeof (TBBUTTON), 0);
|
SendMessageW(rightbar, TB_BUTTONSTRUCTSIZE, sizeof (TBBUTTON), 0);
|
||||||
SendMessageW(rightbar, TB_SETIMAGELIST, 0, (LPARAM) helpList);
|
SendMessageW(rightbar, TB_SETIMAGELIST, 0, (LPARAM) rightList);
|
||||||
|
SendMessageW(rightbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
|
||||||
// TODO this *should* be DIPs...
|
// TODO this *should* be DIPs...
|
||||||
// TODO figure out where the *2 is documented
|
// TODO figure out where the *2 is documented
|
||||||
SendMessageW(rightbar, TB_SETPADDING, 0, MAKELPARAM(6 * 2, 5 * 2));
|
SendMessageW(rightbar, TB_SETPADDING, 0, MAKELPARAM(6 * 2, 5 * 2));
|
||||||
|
@ -345,15 +347,28 @@ void onWM_CREATE(HWND hwnd)
|
||||||
tbb[0].iBitmap = 0;
|
tbb[0].iBitmap = 0;
|
||||||
tbb[0].idCommand = 0;
|
tbb[0].idCommand = 0;
|
||||||
tbb[0].fsState = TBSTATE_ENABLED;
|
tbb[0].fsState = TBSTATE_ENABLED;
|
||||||
tbb[0].fsStyle = BTNS_AUTOSIZE | BTNS_BUTTON;
|
tbb[0].fsStyle = BTNS_AUTOSIZE | BTNS_BUTTON | BTNS_DROPDOWN;
|
||||||
if (SendMessageW(rightbar, TB_ADDBUTTONSW, 1, (LPARAM) tbb) == FALSE)
|
tbb[1].iBitmap = 1;
|
||||||
|
tbb[1].idCommand = 1;
|
||||||
|
tbb[1].fsState = TBSTATE_ENABLED;
|
||||||
|
tbb[1].fsStyle = BTNS_AUTOSIZE | BTNS_BUTTON;
|
||||||
|
tbb[2].iBitmap = 2;
|
||||||
|
tbb[2].idCommand = 2;
|
||||||
|
tbb[2].fsState = TBSTATE_ENABLED;
|
||||||
|
tbb[2].fsStyle = BTNS_AUTOSIZE | BTNS_BUTTON;
|
||||||
|
if (SendMessageW(rightbar, TB_ADDBUTTONSW, 3, (LPARAM) tbb) == FALSE)
|
||||||
diele("TB_ADDBUTTONSW");
|
diele("TB_ADDBUTTONSW");
|
||||||
// TODO check error
|
// TODO check error
|
||||||
// TODO figure out why this works here but not elsewhere
|
// TODO figure out why this works here but not elsewhere
|
||||||
SendMessageW(rightbar, TB_SETBUTTONSIZE, 0, 0);
|
// SendMessageW(rightbar, TB_SETBUTTONSIZE, 0, 0);
|
||||||
|
|
||||||
|
tbsizex = 0;
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
if (SendMessageW(rightbar, TB_GETITEMRECT, (WPARAM) i, (LPARAM) (&btnrect)) == FALSE)
|
||||||
|
diele("TB_GETITEMRECT");
|
||||||
|
tbsizex += btnrect.right - btnrect.left;
|
||||||
|
}
|
||||||
tbbtnsize = (DWORD) SendMessageW(rightbar, TB_GETBUTTONSIZE, 0, 0);
|
tbbtnsize = (DWORD) SendMessageW(rightbar, TB_GETBUTTONSIZE, 0, 0);
|
||||||
tbsizex = LOWORD(tbbtnsize);
|
|
||||||
tbsizey = HIWORD(tbbtnsize);
|
tbsizey = HIWORD(tbbtnsize);
|
||||||
|
|
||||||
ZeroMemory(&rbi, sizeof (REBARBANDINFOW));
|
ZeroMemory(&rbi, sizeof (REBARBANDINFOW));
|
||||||
|
@ -571,7 +586,6 @@ int main(void)
|
||||||
INITCOMMONCONTROLSEX icc;
|
INITCOMMONCONTROLSEX icc;
|
||||||
HICON hDefaultIcon;
|
HICON hDefaultIcon;
|
||||||
HCURSOR hDefaultCursor;
|
HCURSOR hDefaultCursor;
|
||||||
SHSTOCKICONINFO sii;
|
|
||||||
WNDCLASSW wc;
|
WNDCLASSW wc;
|
||||||
HWND mainwin;
|
HWND mainwin;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
@ -596,25 +610,25 @@ int main(void)
|
||||||
if (hDefaultCursor == NULL)
|
if (hDefaultCursor == NULL)
|
||||||
diele("LoadCursorW(IDC_ARROW)");
|
diele("LoadCursorW(IDC_ARROW)");
|
||||||
|
|
||||||
// notes:
|
hr = LoadIconMetric(NULL, IDI_SHIELD, LIM_SMALL, &shieldIcon);
|
||||||
// - https://www.google.com/search?client=firefox-b-1&ei=gGzBW63XLYeG5wL3l5WQBg&q=winapi+%22system+icon%22+image+list&oq=winapi+%22system+icon%22+image+list&gs_l=psy-ab.3...31221.33763..33899...0.0..0.130.1967.22j2......0....1..gws-wiz.......0j0i71j35i39j0i20i264j0i67j0i20i263j0i22i30j0i22i10i30j33i160j33i299j33i22i29i30.wAw65ObMuTg
|
|
||||||
// - https://stackoverflow.com/questions/36763562/how-to-load-imagelist-with-system-dialog-icons
|
|
||||||
// - https://blogs.msdn.microsoft.com/oldnewthing/20121005-00/?p=6393
|
|
||||||
// - https://stackoverflow.com/questions/4285890/how-to-load-a-small-system-icon/4286601
|
|
||||||
// - https://stackoverflow.com/questions/6613513/compliant-loading-of-small-oem-icon-with-loadimage
|
|
||||||
// - https://web.archive.org/web/20170514073649/http://www.catch22.net/tuts/system-image-list
|
|
||||||
ZeroMemory(&sii, sizeof (SHSTOCKICONINFO));
|
|
||||||
sii.cbSize = sizeof (SHSTOCKICONINFO);
|
|
||||||
hr = SHGetStockIconInfo(SIID_HELP, SHGSI_ICON | SHGSI_SMALLICON, &sii);
|
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
diehr("SHGetStockIconInfo(SIID_HELP)", hr);
|
diehr("LoadIconMetric(IDI_SHIELD)", hr);
|
||||||
helpIcon = sii.hIcon;
|
hr = LoadIconMetric(NULL, IDI_APPLICATION, LIM_SMALL, &applicationIcon);
|
||||||
helpList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
|
if (hr != S_OK)
|
||||||
ILC_COLOR32, 0, 1);
|
diehr("LoadIconMetric(IDI_APPLICATION)", hr);
|
||||||
if (helpList == NULL)
|
hr = LoadIconMetric(NULL, IDI_QUESTION, LIM_SMALL, &helpIcon);
|
||||||
|
if (hr != S_OK)
|
||||||
|
diehr("LoadIconMetric(IDI_QUESTION)", hr);
|
||||||
|
rightList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
|
||||||
|
ILC_COLOR32, 0, 3);
|
||||||
|
if (rightList == NULL)
|
||||||
diele("ImageList_Create()");
|
diele("ImageList_Create()");
|
||||||
if (ImageList_ReplaceIcon(helpList, -1, helpIcon) == -1)
|
if (ImageList_ReplaceIcon(rightList, -1, shieldIcon) == -1)
|
||||||
diele("ImageList_ReplaceIcon()");
|
diele("ImageList_ReplaceIcon(IDI_SHIELD)");
|
||||||
|
if (ImageList_ReplaceIcon(rightList, -1, applicationIcon) == -1)
|
||||||
|
diele("ImageList_ReplaceIcon(IDI_APPLICATION)");
|
||||||
|
if (ImageList_ReplaceIcon(rightList, -1, helpIcon) == -1)
|
||||||
|
diele("ImageList_ReplaceIcon(IDI_QUESTION)");
|
||||||
|
|
||||||
ZeroMemory(&wc, sizeof (WNDCLASSW));
|
ZeroMemory(&wc, sizeof (WNDCLASSW));
|
||||||
wc.lpszClassName = L"mainwin";
|
wc.lpszClassName = L"mainwin";
|
||||||
|
|
Loading…
Reference in New Issue