Solved

exposing an imagelist property in my custom control

Posted on 2004-10-12
3
283 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now