• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 614
  • Last Modified:

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(,,"KEY1", "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-850A-101B-AFC0-4210102A8DA7"
   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-9D6A-101B-AFC0-4210102A8DA7"
CODEBASE="http://activex.microsoft.com/controls/vb5/comctl32.cab        #version=5,1,43,19"
      DATA="DATA:application/x-oleobject;BASE64,j43aWGqdGxCvwEIQECqNpy
           FDNBIIAAAA7QMAAO0DAACAfuHmAgAFADEAAAAQ
           ABAA/wD/AP//QQAB782rAAAFANTrZgBBAEEA/////////wAAAAAAAQAAAAEG
           AAAAQwBhAG0AZQByAGEAAQAAAAEAAABsdAAA+AAAAEJN9gAAAAAAAAB2AAAA
           KAAAABAAAAAQAAAAAQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
           AIAAAIAAAACAgACAAAAAgACAAICAAACAgIAAwMDAAAAA/wAA/wAAAP//AP8A
           AAD/AP8A//8AAP///wCIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIhwB4iI
           iIcAAAAAAAB4gHcAd3cAdwiAdwd3d3B3CIB3B4d3cHcIgHcH+HdwdwiA/wB3
           dwD/CID/8AAAD/8IgAAAAAAAAAiIAIcP8HgAiIiIiHAHiIiIiIiIiIiIiIiI
           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?

0
andris333
Asked:
andris333
  • 7
  • 6
1 Solution
 
gbzhhuCommented:
It seems that you are not setting the imagelist of the treeview

Do you have this somewhere?

TreeView1.ImageList = Yourimagelist   'where yourimagelist is the imagelist that contains images for the treeview
0
 
gbzhhuCommented:
Forgotten the Set statement

Set TreeView1.ImageList = YourImageList
0
 
andris333Author Commented:

I set imagelist with param:

<PARAM NAME="ImageList" VALUE="myImageList">
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
gbzhhuCommented:
Also you will get that error if your imagelist is empty (that you haven't added any images)
0
 
andris333Author Commented:

But I have images in it. This treeview works, but it displays errors on some computers and I don't understand why.
0
 
gbzhhuCommented:
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
0
 
andris333Author Commented:

I compared these two versions and theya are different. How could I update mscomctl.ocx?
0
 
gbzhhuCommented:
What OS are you using on these computers?
What Office are you using on these computers?
0
 
gbzhhuCommented:
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)
0
 
andris333Author Commented:

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(,,"KEY10088","Test1")
      newNode.expanded=true

Set newNode = TreeView1.Nodes.Add(,,"KEY100882","Test12")
      newNode.expanded=true

Set newNode = TreeView1.Nodes.Add("KEY10088",4,"KEY10089","Test2")
      newNode.Tag = "10089"

Set newNode = TreeView1.Nodes.Add("KEY10088",4,"KEY10090","Test3")
      newNode.Tag = "10090"

But when I try to add an image to tree, it shows an error. Even code like:

      newNode.Image=myImageList.ListImages(0).Picture

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->View files. I found on MSDN that if component download broke, there should be an explanation, but these files are empty.

Any ideas?

0
 
gbzhhuCommented:
>>But when I try to add an image to tree, it shows an error. Even code like:

>>      newNode.Image=myImageList.ListImages(0).Picture

>>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("KEY10088",4,"KEY10090","Test3")
     newNode.Image = 1

Make sure there at least 1 picture in the imagelist

Does this make any difference?


0
 
andris333Author Commented:

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
0
 
andris333Author Commented:

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.
0
 
NetminderCommented:
Closed, 200 points refunded.
Netminder
Site Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now