?
Solved

Imagelist problem

Posted on 2005-04-19
15
Medium Priority
?
590 Views
Last Modified: 2012-08-13
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
Comment
Question by:andris333
  • 7
  • 6
14 Comments
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13816675
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
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13816705
Forgotten the Set statement

Set TreeView1.ImageList = YourImageList
0
 

Author Comment

by:andris333
ID: 13816706

I set imagelist with param:

<PARAM NAME="ImageList" VALUE="myImageList">
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:gbzhhu
ID: 13816723
Also you will get that error if your imagelist is empty (that you haven't added any images)
0
 

Author Comment

by:andris333
ID: 13816750

But I have images in it. This treeview works, but it displays errors on some computers and I don't understand why.
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13816798
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
 

Author Comment

by:andris333
ID: 13834269

I compared these two versions and theya are different. How could I update mscomctl.ocx?
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13835400
What OS are you using on these computers?
What Office are you using on these computers?
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13835873
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
 

Author Comment

by:andris333
ID: 13844048

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
 
LVL 12

Expert Comment

by:gbzhhu
ID: 13856851
>>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
 

Author Comment

by:andris333
ID: 13874841

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
 

Author Comment

by:andris333
ID: 13908439

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
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 13956731
Closed, 200 points refunded.
Netminder
Site Admin
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month16 days, 21 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question