Fix the creation of treeview with checkboxes.

This commit is contained in:
Maxime Bellengé 2003-08-23 23:18:48 +00:00 committed by Alexandre Julliard
parent 6af30d6994
commit cb1c112dd6

View File

@ -4825,14 +4825,18 @@ TREEVIEW_Create(HWND hwnd)
{ {
RECT rc; RECT rc;
HBITMAP hbm, hbmOld; HBITMAP hbm, hbmOld;
HDC hdc; HDC hdc,hdcScreen;
int nIndex; int nIndex;
infoPtr->himlState = infoPtr->himlState =
ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 3, 0); ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 3, 0);
hdc = CreateCompatibleDC(0); hdcScreen = CreateDCA("DISPLAY", NULL, NULL, NULL);
hbm = CreateCompatibleBitmap(hdc, 48, 16);
/* Create a coloured bitmap compatible with the screen depth
because checkboxes are not black&white */
hdc = CreateCompatibleDC(hdcScreen);
hbm = CreateCompatibleBitmap(hdcScreen, 48, 16);
hbmOld = SelectObject(hdc, hbm); hbmOld = SelectObject(hdc, hbm);
rc.left = 0; rc.top = 0; rc.left = 0; rc.top = 0;
@ -4848,12 +4852,14 @@ TREEVIEW_Create(HWND hwnd)
DrawFrameControl(hdc, &rc, DFC_BUTTON, DrawFrameControl(hdc, &rc, DFC_BUTTON,
DFCS_BUTTONCHECK|DFCS_FLAT|DFCS_CHECKED); DFCS_BUTTONCHECK|DFCS_FLAT|DFCS_CHECKED);
SelectObject(hdc, hbmOld);
nIndex = ImageList_AddMasked(infoPtr->himlState, hbm, nIndex = ImageList_AddMasked(infoPtr->himlState, hbm,
GetSysColor(COLOR_WINDOW)); GetSysColor(COLOR_WINDOW));
TRACE("chckbox index %d\n", nIndex); TRACE("checkbox index %d\n", nIndex);
SelectObject(hdc, hbmOld);
DeleteObject(hbm); DeleteObject(hbm);
DeleteDC(hdc); DeleteDC(hdc);
DeleteDC(hdcScreen);
infoPtr->stateImageWidth = 16; infoPtr->stateImageWidth = 16;
infoPtr->stateImageHeight = 16; infoPtr->stateImageHeight = 16;