PRB: TreeView Ctrl Button Background Doesn't Change After TVM_SETBKCOLOR (216140)
The information in this article applies to:
- Microsoft Platform Software Development Kit (SDK) 1.0
This article was previously published under Q216140 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);
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbCtrl kbprb kbTreeView KB216140 |
---|
|