PRB: TreeView Ctrl Button Background Doesn't Change After TVM_SETBKCOLOR

ID: Q216140


The information in this article applies to:


SYMPTOMS

In a TreeView control with the TVS_HASLINES and TVS_HASBUTTONS style, the background color behind the "+" and "-" buttons does not change when the background color of the control is changed with the TVM_SETBKCOLOR message.


RESOLUTION

After you change the background color of the TreeView control, remove the TVS_HASLINES style and add it again. The following code sample illustrates what you need to do to work around the problem:


LONG lStyle;
// hWndTree is the handle of the TreeView control.
TreeView_SetBkColor(hWndTree, clrNew);
lStyle = GetWindowLong(hWndTree, GWL_STYLE);
lStyle &= ~TVS_HASLINES; // Remove the TVS_HASLINES style.
SetWindowLong(hWndTree, GWL_STYLE, lStyle);
lStyle |= TVS_HASLINES; // Add the TVS_HASLINES style again.
SetWindowLong(hWndTree, GWL_STYLE, lStyle); 

Additional query words:


Keywords          : kbCtrl kbNTOS400 kbWinOS2000 kbSDKPlatform kbTreeView kbGrpUser kbWinOS95 kbWinOS98 
Version           : WINDOWS:
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: February 7, 1999