Solved

exposing an imagelist property in my custom control

Posted on 2004-10-12
3
286 Views
Last Modified: 2013-12-26
hello experts... i'm trying to expose a propery to attach an imagelist to my custom control... but i dont see the property... and i was thinking maybe somehow i have to do the "custom" property like a listview control uses to attach the imagelist.  can someone explain how i can attach an imagelist to my control?

or better yet, if you can tell me how i can create an instance of an imagelist without having to include comctl32.ocx in my custom control project.  comctl32 will be included in the project that i plan to use the custom control in...

i'm trying this to expose the imagelist property...
'=======================================
dim m_ImageList as object
Public Property Get ImageList() As Object
   ImageList = m_ImageList
End Property
Public Property Let ImageList(ByVal NewImageList As Object)
   Set m_ImageList = NewImageList
End Property
Public Property Set ImageList(ByVal NewImageList As Object)
   Set m_ImageList = NewImageList
End Property
'=======================================
0
Comment
Question by:RobK6364
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
danaseaman earned 125 total points
ID: 12292286
If using VbAccelerator ImageList then you only need to supply the handle (m_hIml) which is a long. If you are using the Vb Imagelist then you need to pass an object. Here is code that can handle both situations using Varaint.

Public Property Let ImageList(Value As Variant)
Dim hIml As Long
   '
    If (VarType(Value) = vbLong) Then
      ' Assume a handle to an image list:
      hIml = Value
   ElseIf (VarType(hIml) = vbObject) Then
      ' Assume a VB image list:
      On Error Resume Next
      ' Get the image list initialised.
      Value.ListImages(1).Draw 0, 0, 0, 1
      hIml = Value.hImageList
      If (Err.Number = 0) Then
          ' OK
      Else
          gErr 4, "UniTreeViewCtl"
      End If
      On Error GoTo 0
   End If
   
   If Not (hIml = 0) Then
      SendMessageL m_hWnd, TVM_SETIMAGELIST, TVSIL_NORMAL, hIml
   End If
   '
End Property
0
 
LVL 22

Expert Comment

by:danaseaman
ID: 12292718
By the way...If you want to create the Imagelist in your control there is code at VbAccelerator to do this. The dependency is ComCtl32.Dll which is present in all Windows OS and does not need to be included in your deployment package. There is a great example on how to implement this at PSC. You initialise the ImageList using "InitializeImageListSmall" and supply a bitmap strip using "ImageListSmall_AddBitmap". Link http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=56021&lngWId=1. Also see VbAccelerator.com for lighweight ImageList classes.
0
 
LVL 1

Author Comment

by:RobK6364
ID: 12294314
thanks, got it workin : )
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now