?
Solved

exposing an imagelist property in my custom control

Posted on 2004-10-12
3
Medium Priority
?
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
danaseaman earned 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 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