From 39d1d2d86cd764702ed618186e491fa00b1909d1 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Fri, 30 Sep 2005 18:48:14 +0000 Subject: [PATCH] Fix Bugzilla Bug 676: dynamic explorer start menu sidebar size svn path=/trunk/; revision=18172 --- .../system/explorer/taskbar/startmenu.cpp | 32 ++++++++++++++++--- .../system/explorer/taskbar/startmenu.h | 3 ++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index 6a69a0bd0bf..09a01bddc21 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -1555,12 +1555,18 @@ StartMenuRoot::StartMenuRoot(HWND hwnd) // ignore exception and don't show additional shortcuts } + ReadLogoSize(); +} + +void StartMenuRoot::ReadLogoSize() +{ // read size of logo bitmap BITMAP bmp_hdr; - GetObject(ResBitmap(IDB_LOGOV), sizeof(BITMAP), &bmp_hdr); + GetObject(ResBitmap(GetLogoResId()), sizeof(BITMAP), &bmp_hdr); _logo_size.cx = bmp_hdr.bmWidth; _logo_size.cy = bmp_hdr.bmHeight; + // cache logo width _border_left = _logo_size.cx + 1; } @@ -1776,6 +1782,11 @@ LRESULT StartMenuRoot::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) Paint(canvas); break;} + case WM_DISPLAYCHANGE: + // re-evaluate logo size using the correct color depth + ReadLogoSize(); + break; + default: return super::WndProc(nmsg, wparam, lparam); } @@ -1785,11 +1796,8 @@ LRESULT StartMenuRoot::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) void StartMenuRoot::Paint(PaintCanvas& canvas) { - int clr_bits; - {WindowCanvas dc(_hwnd); clr_bits=GetDeviceCaps(dc, BITSPIXEL);} - MemCanvas mem_dc; - ResBitmap bmp(clr_bits<=8? clr_bits<=4? IDB_LOGOV16: IDB_LOGOV256: IDB_LOGOV); + ResBitmap bmp(GetLogoResId()); BitmapSelection sel(mem_dc, bmp); ClientRect clnt(_hwnd); @@ -1807,6 +1815,20 @@ void StartMenuRoot::Paint(PaintCanvas& canvas) super::Paint(canvas); } +UINT StartMenuRoot::GetLogoResId() +{ + WindowCanvas dc(_hwnd); + + int clr_bits = GetDeviceCaps(dc, BITSPIXEL); + + if (clr_bits > 8) + return IDB_LOGOV; + else if (clr_bits > 4) + return IDB_LOGOV256; + else + return IDB_LOGOV16; +} + void StartMenuRoot::CloseStartMenu(int id) { diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index 276e785865e..3c52bda10b3 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -377,6 +377,9 @@ protected: void Paint(PaintCanvas& canvas); void CloseStartMenu(int id=0); + + void ReadLogoSize(); + UINT GetLogoResId(); };