Commit fe5881c7 authored by Felix Nawothnig's avatar Felix Nawothnig Committed by Alexandre Julliard

comctl32: Allow enabling TVS_CHECKBOXES on the fly.

parent d347ebe1
...@@ -4829,6 +4829,46 @@ TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam) ...@@ -4829,6 +4829,46 @@ TREEVIEW_MouseWheel(TREEVIEW_INFO *infoPtr, WPARAM wParam)
/* Create/Destroy *******************************************************/ /* Create/Destroy *******************************************************/
static void
initialize_checkboxes(TREEVIEW_INFO *infoPtr)
{
RECT rc;
HBITMAP hbm, hbmOld;
HDC hdc, hdcScreen;
int nIndex;
infoPtr->himlState = ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 3, 0);
hdcScreen = GetDC(0);
hdc = CreateCompatibleDC(hdcScreen);
hbm = CreateCompatibleBitmap(hdcScreen, 48, 16);
hbmOld = SelectObject(hdc, hbm);
SetRect(&rc, 0, 0, 48, 16);
FillRect(hdc, &rc, (HBRUSH)(COLOR_WINDOW+1));
SetRect(&rc, 18, 2, 30, 14);
DrawFrameControl(hdc, &rc, DFC_BUTTON,
DFCS_BUTTONCHECK|DFCS_FLAT);
SetRect(&rc, 34, 2, 46, 14);
DrawFrameControl(hdc, &rc, DFC_BUTTON,
DFCS_BUTTONCHECK|DFCS_FLAT|DFCS_CHECKED);
SelectObject(hdc, hbmOld);
nIndex = ImageList_AddMasked(infoPtr->himlState, hbm,
GetSysColor(COLOR_WINDOW));
TRACE("checkbox index %d\n", nIndex);
DeleteObject(hbm);
DeleteDC(hdc);
ReleaseDC(0, hdcScreen);
infoPtr->stateImageWidth = 16;
infoPtr->stateImageHeight = 16;
}
static LRESULT static LRESULT
TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
{ {
...@@ -4930,48 +4970,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) ...@@ -4930,48 +4970,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
infoPtr->hwndToolTip = COMCTL32_CreateToolTip(hwnd); infoPtr->hwndToolTip = COMCTL32_CreateToolTip(hwnd);
if (infoPtr->dwStyle & TVS_CHECKBOXES) if (infoPtr->dwStyle & TVS_CHECKBOXES)
{ initialize_checkboxes(infoPtr);
RECT rc;
HBITMAP hbm, hbmOld;
HDC hdc,hdcScreen;
int nIndex;
infoPtr->himlState =
ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 3, 0);
hdcScreen = GetDC(0);
/* 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);
rc.left = 0; rc.top = 0;
rc.right = 48; rc.bottom = 16;
FillRect(hdc, &rc, (HBRUSH)(COLOR_WINDOW+1));
rc.left = 18; rc.top = 2;
rc.right = 30; rc.bottom = 14;
DrawFrameControl(hdc, &rc, DFC_BUTTON,
DFCS_BUTTONCHECK|DFCS_FLAT);
rc.left = 34; rc.right = 46;
DrawFrameControl(hdc, &rc, DFC_BUTTON,
DFCS_BUTTONCHECK|DFCS_FLAT|DFCS_CHECKED);
SelectObject(hdc, hbmOld);
nIndex = ImageList_AddMasked(infoPtr->himlState, hbm,
GetSysColor(COLOR_WINDOW));
TRACE("checkbox index %d\n", nIndex);
DeleteObject(hbm);
DeleteDC(hdc);
ReleaseDC(0, hdcScreen);
infoPtr->stateImageWidth = 16;
infoPtr->stateImageHeight = 16;
}
/* Make sure actual scrollbar state is consistent with uInternalStatus */ /* Make sure actual scrollbar state is consistent with uInternalStatus */
ShowScrollBar(hwnd, SB_VERT, FALSE); ShowScrollBar(hwnd, SB_VERT, FALSE);
...@@ -5333,24 +5332,37 @@ TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -5333,24 +5332,37 @@ TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
if (wParam == GWL_STYLE) if (wParam == GWL_STYLE)
{ {
DWORD dwNewStyle = ((LPSTYLESTRUCT)lParam)->styleNew; DWORD dwNewStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
/* we have to take special care about tooltips */ if ((infoPtr->dwStyle ^ dwNewStyle) & TVS_CHECKBOXES)
if ((infoPtr->dwStyle ^ dwNewStyle) & TVS_NOTOOLTIPS) {
{ if (dwNewStyle & TVS_CHECKBOXES)
if (infoPtr->dwStyle & TVS_NOTOOLTIPS) {
{ initialize_checkboxes(infoPtr);
infoPtr->hwndToolTip = COMCTL32_CreateToolTip(infoPtr->hwnd); TRACE("checkboxes enabled\n");
TRACE("\n"); }
} else
else {
{ FIXME("tried to disable checkboxes\n");
DestroyWindow(infoPtr->hwndToolTip); }
infoPtr->hwndToolTip = 0; }
}
} if ((infoPtr->dwStyle ^ dwNewStyle) & TVS_NOTOOLTIPS)
{
if (infoPtr->dwStyle & TVS_NOTOOLTIPS)
{
infoPtr->hwndToolTip = COMCTL32_CreateToolTip(infoPtr->hwnd);
TRACE("tooltips enabled\n");
}
else
{
DestroyWindow(infoPtr->hwndToolTip);
infoPtr->hwndToolTip = 0;
TRACE("tooltips disabled\n");
}
}
infoPtr->dwStyle = dwNewStyle; infoPtr->dwStyle = dwNewStyle;
} }
TREEVIEW_UpdateSubTree(infoPtr, infoPtr->root); TREEVIEW_UpdateSubTree(infoPtr, infoPtr->root);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment