- m_hWnd = (WXHWND)::CreateWindowEx
- (
- exStyle,
- WC_TREEVIEW,
- "",
- wstyle,
- pos.x, pos.y, size.x, size.y,
- (HWND)parent->GetHWND(),
- (HMENU)m_windowId,
- wxGetInstance(),
- NULL
- );
-
- wxCHECK_MSG( m_hWnd, FALSE, "Failed to create tree ctrl" );
-
- if ( parent )
- parent->AddChild(this);
-
- SubclassWin(m_hWnd);
+ if ( !MSWCreateControl(WC_TREEVIEW, wstyle) )
+ return FALSE;
+
+ // the treectrl with any other background looks ugly because the items
+ // background is white anyhow
+ SetBackgroundColour(*wxWHITE);
+
+ // VZ: this is some experimental code which may be used to get the
+ // TVS_CHECKBOXES style functionality for comctl32.dll < 4.71.
+ // AFAIK, the standard DLL does about the same thing anyhow.
+#if 0
+ if ( m_windowStyle & wxTR_MULTIPLE )
+ {
+ wxBitmap bmp;
+
+ // create the DC compatible with the current screen
+ HDC hdcMem = CreateCompatibleDC(NULL);
+
+ // create a mono bitmap of the standard size
+ int x = GetSystemMetrics(SM_CXMENUCHECK);
+ int y = GetSystemMetrics(SM_CYMENUCHECK);
+ wxImageList imagelistCheckboxes(x, y, FALSE, 2);
+ HBITMAP hbmpCheck = CreateBitmap(x, y, // bitmap size
+ 1, // # of color planes
+ 1, // # bits needed for one pixel
+ 0); // array containing colour data
+ SelectObject(hdcMem, hbmpCheck);
+
+ // then draw a check mark into it
+ RECT rect = { 0, 0, x, y };
+ if ( !::DrawFrameControl(hdcMem, &rect,
+ DFC_BUTTON,
+ DFCS_BUTTONCHECK | DFCS_CHECKED) )
+ {
+ wxLogLastError(_T("DrawFrameControl(check)"));
+ }
+
+ bmp.SetHBITMAP((WXHBITMAP)hbmpCheck);
+ imagelistCheckboxes.Add(bmp);
+
+ if ( !::DrawFrameControl(hdcMem, &rect,
+ DFC_BUTTON,
+ DFCS_BUTTONCHECK) )
+ {
+ wxLogLastError(_T("DrawFrameControl(uncheck)"));
+ }
+
+ bmp.SetHBITMAP((WXHBITMAP)hbmpCheck);
+ imagelistCheckboxes.Add(bmp);
+
+ // clean up
+ ::DeleteDC(hdcMem);
+
+ // set the imagelist
+ SetStateImageList(&imagelistCheckboxes);
+ }
+#endif // 0
+
+ SetSize(pos.x, pos.y, size.x, size.y);