Fix Bugzilla Bug 676: dynamic explorer start menu sidebar size

svn path=/trunk/; revision=18172
This commit is contained in:
Martin Fuchs 2005-09-30 18:48:14 +00:00
parent 70c65c0144
commit 39d1d2d86c
2 changed files with 30 additions and 5 deletions

View file

@ -1555,12 +1555,18 @@ StartMenuRoot::StartMenuRoot(HWND hwnd)
// ignore exception and don't show additional shortcuts // ignore exception and don't show additional shortcuts
} }
ReadLogoSize();
}
void StartMenuRoot::ReadLogoSize()
{
// read size of logo bitmap // read size of logo bitmap
BITMAP bmp_hdr; 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.cx = bmp_hdr.bmWidth;
_logo_size.cy = bmp_hdr.bmHeight; _logo_size.cy = bmp_hdr.bmHeight;
// cache logo width
_border_left = _logo_size.cx + 1; _border_left = _logo_size.cx + 1;
} }
@ -1776,6 +1782,11 @@ LRESULT StartMenuRoot::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
Paint(canvas); Paint(canvas);
break;} break;}
case WM_DISPLAYCHANGE:
// re-evaluate logo size using the correct color depth
ReadLogoSize();
break;
default: default:
return super::WndProc(nmsg, wparam, lparam); return super::WndProc(nmsg, wparam, lparam);
} }
@ -1785,11 +1796,8 @@ LRESULT StartMenuRoot::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
void StartMenuRoot::Paint(PaintCanvas& canvas) void StartMenuRoot::Paint(PaintCanvas& canvas)
{ {
int clr_bits;
{WindowCanvas dc(_hwnd); clr_bits=GetDeviceCaps(dc, BITSPIXEL);}
MemCanvas mem_dc; 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); BitmapSelection sel(mem_dc, bmp);
ClientRect clnt(_hwnd); ClientRect clnt(_hwnd);
@ -1807,6 +1815,20 @@ void StartMenuRoot::Paint(PaintCanvas& canvas)
super::Paint(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) void StartMenuRoot::CloseStartMenu(int id)
{ {

View file

@ -377,6 +377,9 @@ protected:
void Paint(PaintCanvas& canvas); void Paint(PaintCanvas& canvas);
void CloseStartMenu(int id=0); void CloseStartMenu(int id=0);
void ReadLogoSize();
UINT GetLogoResId();
}; };