Hello:

I am working in VFP8, SP1, and trying to add an imagelist OLE object
to a form that also has a treeview control on it. When I try to
assign the imagelist object to the treeview object, I get the
following error message at runtime:

OLE IDISPATCH EXCEPTION CODE 0 FROM TREECTL: INVALID OBJECT.

The code I'm running, in the INIT method of the treeview control
(tvProcessResults.init) is:

This.ImageList = ThisForm.oleControl1

I have set up the imagelist OLE object with several 32x32 icon images
in the ImageListCtrl Properties menu, and made sure that the INIT on
the imagelist control runs *before* the INIT on the treeview.

I can't figure out what is wrong here

Ideas?

Thanks!

Steven C

Re: Treeview Imagelist Assignment ProblemOLE Dispatch Exception Code 0 by David

David
Wed Feb 04 19:45:02 CST 2004

Steve,

When the ListView instantiates there is no guarantee that the ImageList has
been instantiated yet. The best solution is to use a line like

this.oTreeView.ImageList = thisform.oImageList

in the Form.Init(). At that point both controls will have instantiated. Also
is oleControl1 the name of your imagelist?

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro

<Steven C> wrote in message
news:5sm220hut2op67icorbavm9hicmosn087r@4ax.com...
> Hello:
>
> I am working in VFP8, SP1, and trying to add an imagelist OLE object
> to a form that also has a treeview control on it. When I try to
> assign the imagelist object to the treeview object, I get the
> following error message at runtime:
>
> OLE IDISPATCH EXCEPTION CODE 0 FROM TREECTL: INVALID OBJECT.
>
> The code I'm running, in the INIT method of the treeview control
> (tvProcessResults.init) is:
>
> This.ImageList = ThisForm.oleControl1
>
> I have set up the imagelist OLE object with several 32x32 icon images
> in the ImageListCtrl Properties menu, and made sure that the INIT on
> the imagelist control runs *before* the INIT on the treeview.



Re: Treeview Imagelist Assignment ProblemOLE Dispatch Exception Code 0 by Steven

Steven
Wed Feb 04 22:31:13 CST 2004

On Wed, 4 Feb 2004 19:45:02 -0600, "David Frankenbach"
<sendnospam@sendnospam.net> wrote:

>Steve,
>
>When the ListView instantiates there is no guarantee that the ImageList has
>been instantiated yet. The best solution is to use a line like
>
> this.oTreeView.ImageList = thisform.oImageList
>
>in the Form.Init(). At that point both controls will have instantiated. Also
>is oleControl1 the name of your imagelist?

David:

I did try that, ie, putting the initialization in the form init
method, since it fires last, but I am still getting this message.
Actually, the name of my imagelist control is: "oleImageList." Thus,
the code I put into the form.init() method is:

thisform.tvProcessResults.ImageList = thisform.oleImageList

where tvProcessResults is my Treeview control, and oleImageList is my
imagelist control. In the form init method, right after the above
assignment, I issue:

ThisForm.m_refreshnodes

Which builds the treeview.

I keep getting the: "OLE IDispatch exception code 0 from TreeCtrl:
Invalid Object" error when I assign the ImageList to the Treeview.

The image control I'm using is Microsoft ImageList Control 6.0 (SP4)

Thanks!

Steven C

Re: Treeview Imagelist Assignment ProblemOLE Dispatch Exception Code 0 by Steven

Steven
Wed Feb 04 23:35:27 CST 2004

On Wed, 4 Feb 2004 19:45:02 -0600, "David Frankenbach"
<sendnospam@sendnospam.net> wrote:

>Steve,
>
>When the ListView instantiates there is no guarantee that the ImageList has
>been instantiated yet. The best solution is to use a line like
>
> this.oTreeView.ImageList = thisform.oImageList
>
>in the Form.Init(). At that point both controls will have instantiated. Also
>is oleControl1 the name of your imagelist?

David:

I think I was dealing with a version incompatibility issue. I copied
the treeview control from the example form on your website and pasted
it into my form, and everything worked great. For some reason, the
treeview version (version 6) that I was using didn't work with the
imagelist. Interesting, eh?

Thanks!

Steven

Re: Treeview Imagelist Assignment ProblemOLE Dispatch Exception Code 0 by David

David
Thu Feb 05 09:54:09 CST 2004

Steven,

I've been using the 6.0 version of the controls together. Is it possible
that you had one of them as the 5.0 control and the other 6.0?

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro

<Steven C> wrote in message
news:9cl320p19u6ldcebdv8279leh94kcktm4h@4ax.com...
> On Wed, 4 Feb 2004 19:45:02 -0600, "David Frankenbach"
> <sendnospam@sendnospam.net> wrote:

> I think I was dealing with a version incompatibility issue. I copied
> the treeview control from the example form on your website and pasted
> it into my form, and everything worked great. For some reason, the
> treeview version (version 6) that I was using didn't work with the
> imagelist. Interesting, eh?