andris333
asked on
Imagelist problem
Ok, I use following vb code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
<!--
Option Explicit
Sub Window_OnLoad()
Dim node
Set node = TreeView1.Nodes.Add(,,"KEY 1", "Test1")
node.expanded=true
node.Image=1
Set node = TreeView1.Nodes.Add("KEY1" , 4, "KEY2", "Test2")
node.Image=1
Set node = TreeView1.Nodes.Add("KEY1" , 4, "KEY3", "Test3")
node.Image=1
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<OBJECT ID="TreeView1" WIDTH=100 HEIGHT=100
CLASSID="CLSID:0713E8A2-85 0A-101B-AF C0-4210102 A8DA7"
CODEBASE="http://activex.microsoft.com/controls/vb5/comctl32.cab
#version=5,1,43,19">
<PARAM NAME="_ExtentX" VALUE="2646">
<PARAM NAME="_ExtentY" VALUE="2646">
<PARAM NAME="_Version" VALUE="327682">
<PARAM NAME="Style" VALUE="7">
<PARAM NAME="Appearance" VALUE="1">
<PARAM NAME="ImageList" VALUE="myImageList">
</OBJECT>
<OBJECT ID="myImageList" WIDTH=39 HEIGHT=39
CLASSID="CLSID:58DA8D8F-9D 6A-101B-AF C0-4210102 A8DA7"
CODEBASE="http://activex.microsoft.com/controls/vb5/comctl32.cab #version=5,1,43,19"
DATA="DATA:application/x-o leobject;B ASE64,j43a WGqdGxCvwE IQECqNpy
FDNBIIAAAA7QMAAO0DAACAfuHm AgAFADEAAA AQ
ABAA/wD/AP//QQAB782rAAAFAN TrZgBBAEEA /////////w AAAAAAAQAA AAEG
AAAAQwBhAG0AZQByAGEAAQAAAA EAAABsdAAA +AAAAEJN9g AAAAAAAAB2 AAAA
KAAAABAAAAAQAAAAAQAEAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAA
AIAAAIAAAACAgACAAAAAgACAAI CAAACAgIAA wMDAAAAA/w AA/wAAAP// AP8A
AAD/AP8A//8AAP///wCIiIiIiI iIiIiIiIiI iIiIiIiIiI iIiIiIiIhw B4iI
iIcAAAAAAAB4gHcAd3cAdwiAdw d3d3B3CIB3 B4d3cHcIgH cH+HdwdwiA /wB3
dwD/CID/8AAAD/8IgAAAAAAAAA iIAIcP8HgA iIiIiHAHiI iIiIiIiIiI iIiI
iIiIiIiIiEUA+EcA
">
</OBJECT>
</BODY>
</HTML>
The problem with th cod above is that on specidic computers it gives me an error: Imagelist must be initialized before it can be used. I tested this code on several computers and sometimes there is no problem, but sometimes I have this imagelist error.
Is there any problem with code above that could be fixed?
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
<!--
Option Explicit
Sub Window_OnLoad()
Dim node
Set node = TreeView1.Nodes.Add(,,"KEY
node.expanded=true
node.Image=1
Set node = TreeView1.Nodes.Add("KEY1"
node.Image=1
Set node = TreeView1.Nodes.Add("KEY1"
node.Image=1
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<OBJECT ID="TreeView1" WIDTH=100 HEIGHT=100
CLASSID="CLSID:0713E8A2-85
CODEBASE="http://activex.microsoft.com/controls/vb5/comctl32.cab
#version=5,1,43,19">
<PARAM NAME="_ExtentX" VALUE="2646">
<PARAM NAME="_ExtentY" VALUE="2646">
<PARAM NAME="_Version" VALUE="327682">
<PARAM NAME="Style" VALUE="7">
<PARAM NAME="Appearance" VALUE="1">
<PARAM NAME="ImageList" VALUE="myImageList">
</OBJECT>
<OBJECT ID="myImageList" WIDTH=39 HEIGHT=39
CLASSID="CLSID:58DA8D8F-9D
CODEBASE="http://activex.microsoft.com/controls/vb5/comctl32.cab #version=5,1,43,19"
DATA="DATA:application/x-o
FDNBIIAAAA7QMAAO0DAACAfuHm
ABAA/wD/AP//QQAB782rAAAFAN
AAAAQwBhAG0AZQByAGEAAQAAAA
KAAAABAAAAAQAAAAAQAEAAAAAA
AIAAAIAAAACAgACAAAAAgACAAI
AAD/AP8A//8AAP///wCIiIiIiI
iIcAAAAAAAB4gHcAd3cAdwiAdw
dwD/CID/8AAAD/8IgAAAAAAAAA
iIiIiIiIiEUA+EcA
">
</OBJECT>
</BODY>
</HTML>
The problem with th cod above is that on specidic computers it gives me an error: Imagelist must be initialized before it can be used. I tested this code on several computers and sometimes there is no problem, but sometimes I have this imagelist error.
Is there any problem with code above that could be fixed?
Forgotten the Set statement
Set TreeView1.ImageList = YourImageList
Set TreeView1.ImageList = YourImageList
ASKER
I set imagelist with param:
<PARAM NAME="ImageList" VALUE="myImageList">
Also you will get that error if your imagelist is empty (that you haven't added any images)
ASKER
But I have images in it. This treeview works, but it displays errors on some computers and I don't understand why.
This maybe something to do with Web stuff and I am unfamiliar with that. Hope others can help
The only think I can think of is that those computers have a different common control (mscomctl.ocx) and so loading the Imagelist failed. Can you compare the files of a working PC and one that is not working
The only think I can think of is that those computers have a different common control (mscomctl.ocx) and so loading the Imagelist failed. Can you compare the files of a working PC and one that is not working
ASKER
I compared these two versions and theya are different. How could I update mscomctl.ocx?
What OS are you using on these computers?
What Office are you using on these computers?
What Office are you using on these computers?
Try closing all VB and Office apps. Try replacing the mscomctl.ocx with the new one. I think it will refuse this but try.
If that fails restart the PC on command prompt only try renaming the old mscomctl.ocx and copying the new one in its place
If that fails get the latest VB runtime from MS (this may not work because sometimes programs like Office XP or Office 2003 have newer versions of windows components than latest Visual Basic components)
If that fails restart the PC on command prompt only try renaming the old mscomctl.ocx and copying the new one in its place
If that fails get the latest VB runtime from MS (this may not work because sometimes programs like Office XP or Office 2003 have newer versions of windows components than latest Visual Basic components)
ASKER
I reinstalled last versions of comctl and mscomctl from Visual Basic runtime Service Pack 6.0, but still I get the same errors.
Btw, here are the system file data, where I have tested this file:
Win2000 (error)
comctl23.ocx doesn't exist
comctl232 6.0.80.22
mscomctl 6.0.88.62
comctl32.dll - 5.81.4916.400
Win2000 (error)
comctl23.ocx doesn't exist
comctl232 6.0.80.22
mscomctl 6.0.88.62
comctl32.dll - 5.81.4916.400
Win2000 (OK)
comctl23 6.0.80.22
comctl232 6.0.0.8450
mscomctl 6.0.88.62
comctl32.dll - 5.81.3502.6601
Win2000 (Error)
comctl32.dll - 5.81.4916.400
others doesn't exist
WinXP (Error)
comctl32 5.82.2900.2180
comctl32.dll - 5.82.2900.2180
mscomctl - 6.1.95.45
I think that the problem is in imagelist, becuse I can load trees without images.
Code like this could load tree without images:
Dim newNode
'set TreeView1.ImageList = myImageList
Set newNode = TreeView1.Nodes.Add(,,"KEY
newNode.expanded=true
Set newNode = TreeView1.Nodes.Add(,,"KEY
newNode.expanded=true
Set newNode = TreeView1.Nodes.Add("KEY10
newNode.Tag = "10089"
Set newNode = TreeView1.Nodes.Add("KEY10
newNode.Tag = "10090"
But when I try to add an image to tree, it shows an error. Even code like:
newNode.Image=myImageList.
doesn't work. It displays an error that "index is out of bounds".
Maybe there is a problem with licensing? The code on XP tried to download two files from the internet. I saw it in Tools-->Internet Options->General->Settings
Any ideas?
>>But when I try to add an image to tree, it shows an error. Even code like:
>> newNode.Image=myImageList. ListImages (0).Pictur e
>>doesn't work. It displays an error that "index is out of bounds".
I thought the listimages where 1 based. Try this
Dim newNode as Node
Set TreeView1.ImageList = myImageList
Set newNode = TreeView1.Nodes.Add("KEY10 088",4,"KE Y10090","T est3")
newNode.Image = 1
Make sure there at least 1 picture in the imagelist
Does this make any difference?
>> newNode.Image=myImageList.
>>doesn't work. It displays an error that "index is out of bounds".
I thought the listimages where 1 based. Try this
Dim newNode as Node
Set TreeView1.ImageList = myImageList
Set newNode = TreeView1.Nodes.Add("KEY10
newNode.Image = 1
Make sure there at least 1 picture in the imagelist
Does this make any difference?
ASKER
I have tried your code and it still doesn't work. :(
Btw, I can't use Set TreeView1.ImageList = myImageList.
Check out this link to see why:
http://support.microsoft.com/kb/184975/EN-US
ASKER
Hi gbzhhu,
Thanx for all your help, but I already created same functionality tree using client side Javascript and XML/XSLT.
I posted a comment to close this question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you have this somewhere?
TreeView1.ImageList = Yourimagelist 'where yourimagelist is the imagelist that contains images for the treeview