473,395 Members | 1,869 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,395 software developers and data experts.

Help with Image List control

I am using an imageList control for a tree menu. Works fine

Problem I have is using VB to populate the ImageList

Basically I have a table of Icons that I wish to use. They point to a folder
where I store the Icon images. The name of the ImageList is ImList.
The LoadPicture routine finds the full path of the Icon, and obviously I
want to store these icons in the ImList. No problem doing it manually with
the form in design view, but this is not something that a user has access to

I don't speak German so that has not helped. Can't remember where I copied
the code from

The code is

Private Sub Form_Open(Cancel As Integer)

Call ImageList_Initialize(ImList)
Call ImageList_Fill(ImList, "Icons")

End Sub
.................................................. .........

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
.................................................. ................

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
Set img = ImageList.ListImages.Add(IconTable![IconNo] + 1,
IconTable![IconName], _
LoadPicture(CoIconPath & "\" & IconTable![IconName] & ".ico"))
IconTable.MoveNext
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
.......................

What am I missing

Thanks

Phil
Jun 27 '08 #1
0 2123

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

Similar topics

0
by: Greg Christie | last post by:
I think I have a somewhat unique situation here, so I thought I should post it for the few poor souls who run across it and try to google it like I did. First of all, I was getting the following...
2
by: Lyn | last post by:
Hi, I am struggling to display photographs in a list format. Any help will be greatly appreciated. Originally I had attempted to store photographs as embedded OLE Objects, but had lots of...
8
by: Tim Geiges | last post by:
Since I am being challenged with learning c# I figured I could pass some of the pain on to you guys :-) I have another question(this one is important for me to fix before I can get my app to Beta)...
3
by: Larry | last post by:
I've set up a list of image filesnames in a listview control(lvSrcFileList), I'm using the selectedIndexChange event to select which file is being displayed in a picturebox control(pbImagePreview)....
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
8
by: Lloyd Sheen | last post by:
I have a list of JPG's which are found in a SQL Server database. When the page selects a certain piece of data it will refer to the file system (resident on IIS server with a virtual directory)...
0
by: Lou O | last post by:
I have browsed and seen several posts on the subject but my issue seems to be unique. I have an image control on a form that updates on the after update event of a list box on the control. For...
0
by: richard12345 | last post by:
Hi Guys I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.