How can I set Metatreex node iamge in VC++

Author Message
Brade 02/06/2006 07:51 am
Now I can change the background of the Metatree by using class CPictureHolder.But it seems too hard to set the nodes image.How can I set the param of Metatree.setimagelist().Would you be so kind to tell me what the IUnknown param should be.It would be better to get an VC demo.
Thank you all!
Oleg Chernavin 02/07/2006 06:07 am
Can you please tell us how you create the component in VC++ and how did you try to assign the images? We will try to reproduce this and make a recommendation.

Thank you!

Best regards,
Oleg Chernavin
MP Staff
brade 02/09/2006 01:29 am
Make an dialog resouce,add a Metatreex control to the dialog.
May be the following codes would be enough to you!
//metatree is a metatreex type member param of MyView

CMTitems items=metatree.GetItems();
CMTitem item=items.insert(0,"root");
intems.add(item,"child0");
intems.add(item,"child1");
//use CPictureHolder class to set the background
CPictureHolder mypic;
mypic.CreateFromBitmap(ID_BITMAP);
LPDISPATCH pdisp=mypic.getdispatch();
metatree.setbackground(pdisp);
//ID_BITMAP is my bitmap ID

//I just don`t know how to set the Imagelist for the nodes. Such as root ,child0,child1.
//that is how to set the param of the member funtion: SetImagelist(Iunknow newvalue);
In VB demo you set the imagelist for the metatree like this:

Set Images = CreateObject("MSComctlLib.ImageListCtrl")
Images.ImageHeight = 32
Images.ImageWidth = 32
Images.MaskColor = &HFF00FF
Set Pict = LoadPicture("MXDemo.bmp")
Images.ListImages.Add 1, , Pict
MetaTreeX1.SetImageList Images

How can I make it in VC++


surpose ID_MYIMAGELIST is my imagelist id.how can I load the imagelist and set the nodes iamge.
Using SetImagelist() function?How to set the param of the function!
or other ways?

Thank you for your attention.



Oleg Chernavin 02/10/2006 07:42 am
I think, we will need to add a function for image lists. Can you please wait a week until this is done?

Oleg.
brade 02/10/2006 09:26 pm
Thank you for your kindness.
Best wishes!
Alex Filatkin 03/05/2006 12:33 pm
Dear Brade,

We are very sorry for long delay.

This example demonstrates how to set imagelist in VC++.
So, please note that i am not experience in VC++ and my codes may contain some mistakes
===
// load images from resources
CPictureHolder mypic2;
mypic2.CreateFromBitmap(IDB_BITMAP4);
LPDISPATCH pdisp2=mypic2.GetPictureDispatch();

IImageList il;
IImages ii;
il.CreateDispatch("MSComctlLib.ImageListCtrl");
il.SetImageHeight(32);
il.SetImageWidth(32);
ii = il.GetListImages();
VARIANT v1;
VariantInit(&v1);
v1.vt = VT_INT;
v1.intVal = 1;
VARIANT v2;
VariantInit(&v2);
v2.vt = VT_DISPATCH;
v2.pdispVal = pdisp2;

// add images to imagelist
ii.Add(&v1, NULL, &v2);

// set imagelis "il" to m_metatree
m_metatree.SetImageList(il);

VariantClear(&v2);
VariantClear(&v1);
===

IImageList and IImages classes i created by ClassWizard->Add Class -> From a type library MSCOMCTL.OCX

Sincerely yours,
Alex Filatkin
MP Staff