PRB: Problems Using Subclassed TreeView MFC Control in VB (197257)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q197257 SYMPTOMS
You create a TreeView subclassed control using C++ with MFC ActiveX control
Wizard. It works correctly in the MFC container, but when used in the VB
container, the background color behind the "+", "-", and dotted lines is
the container's background color rather than the TreeView control's
background color. Further, when the VB project is compiled and run, an
error message is generated indicating that the control can not be created
and the application terminates.
CAUSE
The cause for the first problem is that the TreeView control creates
bitmaps for the "+", "-", and dotted line when the control is first
created. These bitmaps are used if the background color is not changed.
When VB is used as the container, the TreeView control uses the container's
back color as the default color.
The cause of the second problem is that the "SysTreeView32" window class
needs to be registered before it can be created. A VB application won't
register it automatically.
RESOLUTION
To fix the first problem, set the TreeView control's back color after the
"SysTreeView32" window is created so that the bitmaps for "+", "-", and
dotted lines are regenerated.
To fix the second problem, call "InitCommonControls()" before calling
"COleControl::OnCreate(lpCreateStruct)" to create the window.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbCtrl kbprb KB197257 |
---|
|