![]() | Type | Description | ||
| Variant | A picture object being displayed in the node, or a string expression that indicates the picture's file path or a string expression that indicates the base64 encoded string that holds the picture. Use the eximages tool to save your icons as base64 encoded format |
Use the Picture property to load an user defined picture to a node. Use the Image property to display a 16x16 icon in the node. Use the PictureAlignment property to align the picture in the node. Also, you can assign a picture to a node when calling Add method. Use the BackColor property to specify the node's background color. Use the Picture property to display a picture on the control's background. Use the Caption property to assign a caption to a node.
The following VB sample loads icons and pictures using the BASE64 encoded strings:
Run the sample and you get:

The following two VB samples are equivalents:
With ChartView1
With .Nodes
With .Add("<r><dotline><b><fgcolor=0000FF>Andrew Fuller</fgcolor></b><br><solidline><b>Title</b>:<r><fgcolor=FF0000>Vice President Sales</fgcolor><br>USA, Tacoma, WA, 98401, 908 W. Capital Way<br><dotline><upline><b>Phone:</b><r>(206) 555-9482", , , 1, "c:\temp\sample\andrew.gif")
.BackColor = vbWhite
End With
End With
End With

With ChartView1
With .Nodes
With .Add("<r><dotline><b><fgcolor=0000FF>Andrew Fuller</fgcolor></b><br><solidline><b>Title</b>:<r><fgcolor=FF0000>Vice President Sales</fgcolor><br>USA, Tacoma, WA, 98401, 908 W. Capital Way<br><dotline><upline><b>Phone:</b><r>(206) 555-9482", , , 1)
.BackColor = vbWhite
.Picture = "c:\temp\sample\andrew.gif"
End With
End With
End With
I am wondering how to add a bitmap to a node without using an image list? Actually from a CBitmap that I already have. The idea is to get an IPicture object that displays that HBITMAP handle, so we have to use the OleCreatePictureIndirect API function that does the job. We can use the CPictureHolder class, already defined in the afxctl.h file, or we can use a direct function IPictureFromCBitmap as defined bellow.
#include <afxctl.h>
CPictureHolder pict;
if ( pict.CreateFromBitmap( (HBITMAP)bitmap.Detach() ) )
{
COleVariant vtPicture;
V_VT( &vtPicture ) = VT_DISPATCH;
(V_DISPATCH( &vtPicture ) = pict.GetPictureDispatch() )->AddRef();
node.SetPicture( vtPicture );
}
#include <atlbase.h>
CComVariant IPictureFromCBitmap( CBitmap* p )
{
if ( NULL != p )
{
PICTDESC pDesc = {0};
pDesc.cbSizeofstruct = sizeof( PICTDESC );
pDesc.picType = PICTYPE_BITMAP;
pDesc.bmp.hbitmap = (HBITMAP)p->Detach();
CComPtr<IPicture> spPicture;
if ( SUCCEEDED( OleCreatePictureIndirect( &pDesc, IID_IPicture, FALSE, (LPVOID*)&spPicture ) ) )
return CComVariant( CComQIPtr<IDispatch>( spPicture ) );
}
return NULL;
}
and you call something like node.SetPicture( IPictureFromCBitmap( &bitmap ) );
where the node member is the node in the control to put the picture, and the bitmap is an object of CBitmap type.