473,388 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Trouble with ListImage

Help

I have a form where I am trying to load Icons to subsequently display in a
Tree menu system. The following 2 bits of code are run on the OnOpen Event
after clearing out the old images.
The form has a MSComctlLib.ImageListCtrl.2 control on it.
The IconTable contains the name of the icon e.g. Folder_Open.ico and a
number
The 11 images were originally loaded "by hand"

After running the initialize routine if I type ?
ImList.Object.ListImages.Count in the immediate window I get as expected 0,
but if I look at the ImList control, all 11 images are still there

Function ImageList_Initialize(ByVal ImageList As Object)

On Error GoTo ImageList_Initialize_Error

ImageList.ListImages.Clear

ImageList_Initialize_Error:
If Err Then MsgBox Err.Description, vbCritical, "No." & Err.Number

End Function

If I manually delete the images, the following routine does not add them
back

Function ImageList_Fill(ByVal ImageList As Object, ByVal IconTableName As
String) As Boolean

On Error GoTo ImageList_Fill_Error
'* ImageList-Variablen definieren
Dim img As ListImage
'* DAO-Variablen definieren
Dim MyDb As Database
Dim IconTable As Recordset

'* Funktion initialisieren
ImageList_Fill = False

ImList.Object.ImageWidth = 16
ImList.Object.ImageHeight = 16
'* DAO-Variablen initialisieren
Set MyDb = CurrentDb()
Set IconTable = MyDb.OpenRecordset(IconTableName, dbOpenDynaset)
'* Wenn kein Datensatz vorhanden, dann Abbruch!
If IconTable.RecordCount = 0 Then GoTo ImageList_Fill_Exit

IconTable.MoveFirst
While Not IconTable.EOF
'* kleine Images in ImageList einfügen
If Dir(CoIconPath & "\" & IconTable![IconName] & ".ico") "" Then
' Found
Set img = ImageList.ListImages.Add(IconTable![IconNo] + 1,
IconTable![IconName], _
LoadPicture(CoIconPath & "\" & IconTable![IconName] &
".ico"))
End If
IconTable.MoveNext
Debug.Print ImList.Object.ListImages.Count
Wend

'* Funktion erfolgreich!
ImageList_Fill = True

ImageList_Fill_Exit:
'* DAO-Variablen schliessen
IconTable.Clone
MyDb.Close
'* DAO-Variablen terminieren
Set IconTable = Nothing
Set MyDb = Nothing

ImageList_Fill_Error:
If Err Then MsgBox Err.Description, vbCritical, "No." & Err.Number

End Function

Can anyone point me in the right direction. It is a pain in the a.. loading
the images by hand

Many thanks

Phil

PS Sorry about the German. Can't remember where I nicked the original code
from
Jul 29 '08 #1
0 1056

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James | last post by:
Hi I am having some trouble getting a asp page to load. Im a noob to the asp side. I have followed knowledege base Article 301305. I am running 2000 adv, IIS 5.0 I have the following...
4
by: Jacek Dziedzic | last post by:
Hi! First of all, I hope my problem is not too loosely tied to the "standard C++" that is the topic of this group. I have some code that exhibits a strange behaviour: on one computer, where I...
0
by: Paul C | last post by:
Hello, everybody. I am having trouble running some of the VS.NET samples, specifically the CarSelector web app, which is very simple. The symptom is that the web controls (drop down listboxes and...
0
by: Alexandre Jaquet | last post by:
Hi does anybody know how to solve my trouble, when I try to create a MS Office project I always got trouble. I can't create office project when I try to create one vs.net restart ... :s
1
by: Jim Bancroft | last post by:
Hi everyone, I'm running into a problem with my ASP.Net application. I've just created a new aspx page which uses some new components of mine that inherit from ServicedComponent and are...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
2
by: JLupear | last post by:
I am having trouble with my code again, I had prepared a question and the code to upload, however I am having trouble posting it, are there limits to the amount of lines you can post? I split it...
0
by: mrchatgroup | last post by:
news from http://www.mrchat.net/myblog/myblog/small-accidents-mean-big-trouble-for-supercollider.html Small Accidents Mean Big Trouble for Supercollider Image Scientists expect startup...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.