Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

referencing mainfrm objects from a class

in my project ,the form main has an image list control say iml1.
from form main i call a class that populates all the properties of a node.but to display the image of the node i need to add images from this class on to the image list control on form main. i will just show you the code snippets to make my point more clear.

from form main :
Set gPhysTree = New CPhysicalTree ' is a call made to class cphysical tree that will set all the properties for physical tree treeview.
> form main has an imagelist control iml tree that contains all the images that will be present in tree view nodes and has to be populated at run time.
>in cphysical tree class
when i try to implement this code.
For X = 1 To frmmain.imlTree.ListImages.Count'it causes error 426
If frmmain.imlTree.ListImages(X).Key = TypeName Then

Else
frmmain.imlTree.ListImages.Add , TypeName, Scodpic
End If
Next X
Set NewNode = .Nodes.Add(parentNode.Index, tvwChild, , _
Obj.Name & " [" & TypeName & "]", _
TypeName)

it throws an error no 426 that only one mdi form allowed.
since my main form will always be opened before this code is executed .
is there any method i can use to reference the frm main object (imagelist)from class module and populate it.
[1567 byte] By [aks79] at [2007-11-11 8:46:23]
# 1 Re: referencing mainfrm objects from a class
what do you mean with "from form main"? There is no "main" in a form; do you mean the Load event? Or do you mean the "Sub Main" in a module?

Marco
mstraf at 2007-11-11 17:25:01 >