Initialize imagelist?

Have images stored in an imagelist that I want to place in a treeview control. Keep getting the message "Image list must be initialized"

Can anyone direct me to a code sample of this? Can't seem to find anything. I have already added the images that I want thru the "custom properties" property window.

Right now, what I have is :

With tvwMain Set .ImageList = Me.ilstMain '(also tried Me.ilstMain.ListImages) tn = .Add(,, strDefPath, strDefFolNm, 1, 2) End With

This causes an error: "Type Mismatch" If I remove the "Set", it will make it thru the ".ImageList =" line, but when I reach the ".Add" line I get the error : "ImageList must be initialized"

I am using Microsoft ImageList Control 6.0 (SP4) and have a Reference to Microsoft Windows Common Controls 6.0 (SP4), and am not using Option Explicit.

Is there some sort of issue with SW and this image list? I've been going nuts with this, and can't get it to work no matter what I try.

Thanks for any help.

Reply to
What-a-Tool
Loading thread data ...

Hello Sean,

In my code I do the following to initialize the imagelist:

With myForm.myImageList.ListImages .Add Picture:=LoadResPicture("xxx", vbResBitmap), Key:= "foo" .Add Picture:=LoadResPicture("yyy", vbResBitmap), Key:= "bar" 'Add further images from the resource End With

Finally I assign the imagelist to the treeview:

With myForm.myTreeView Set .ImageList = myForm.myImageList 'define other settings ... End With

Hope this helps!

-h-

Reply to
Heikki Leivo

I'm obviously missing some references, as "LoadResPicture", and "vbResBitmap" don't show up in intellisence or help, and give me an "unrecognised sub or function error". I've tried different references looking for the correct one until my face turned purple.

Can anyone tell me which (If any ) references I'm missing?

Reply to
What-a-Tool

You are indeed missing something... LoadResPicture is member of VB6 and vbResBitmap is a member of VisualBasic Runtime, but at least I don't know how (and why) one should _remove_ tehese from their references. You should have "Visual basic runtime objects" and "Visual basic objects and procedures" checked, but I think you should not be able to uncheck them from your references. Are you using Visual Basic 6?

-h-

Reply to
Heikki Leivo

Now I see, you are writing a SW macro, aren't you? There is no sense in using resource functions in a macro. My code was just an example, I used the functions to initialize the imagelist but but they are not required for the code to work.

-h-

Reply to
Heikki Leivo

Thanks for the help. - Still driving me nuts with "Type Mismatch " and Object errors. Never had a headache like this with any other control before. I'll get it figured out though (I Hope!)

Thanks for the help, again.

Reply to
What-a-Tool

Ha - Got it figured out - I'm only half as dumb as I was starting to think!

Had to code in an API call to "mscomctl.ocx". SW must not have the licenses to these controls?

Drove me nuts - the objects were all there for me, just that nothing worked the way it was supposed to!

Thanks for the help

Reply to
What-a-Tool

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.