views:

122

answers:

1

In a small project of mine I've came across the need of a collapsible group box.

Searching the Net, I've found one here. In one of the comments there's an improvement on the original code that uses the VisualStyleRenderer class in order to acquire the TreeView open and closed glyph.

Running the code it draws properly the Plus and Minus sing as Windows XP would draw it, however in Windows Vista and Windows 7 the glyph for open and closed nodes are small triangles.

What kind of interface, class or PInvoke, I need to use in order to acquire the right glyph?

+1  A: 

By default, TreeViews have the same appearance as in XP in Windows 7 and Vista. To get the little arrow glyphs you need to set the window theme for the control:

SetWindowTheme(hwnd, L"explorer", NULL)

This can also be used for ListViews.

I'm not sure how the collapsible group box renders the collapse/expand button so I'm not sure how to get it to draw them with the Explorer theme.

Joakim Hårsman