|

  |
Before you Begin
|
  |
  |
 |
The vbAccelerator sample requires the SSubTmr.DLL. Please make sure you have downloaded and registered this
control before trying the project.
|
  |
Overview
|
The Microsoft Common Controls work with the ImageList provided with the controls, but what
if you want to use an external ImageList with better facilities, or, particularly, if you
want to use a System ImageList with these components?
Previously on vbAccelerator I said this couldn't be done, however, thanks to Tom Esh for
proving me wrong! By using the native API for the ListView, you can
assign a new ImageList and then use the API to set the Image index for the icon for each
ListItem. It is possible you can use similar techniques in the TreeView, TabStrip and
other controls too. Found out how to do it? Mail me!
These techniques work in VB5 and VB6, although the download code only includes VB5 projects.
|
The ListView and External ImageLists
|
The steps required to make a VB ListView use an External ImageList are as follows:
- Ensure that the ListView control is set to use Shared ImageLists (i.e. it will not destroy the ImageList when closed)
- Assign a standard ImageList to the control with one image in (only required for VB6)
- Use the LVM_SETIMAGELIST message to change the ImageList handle to the external ImageList.
Here, if you wish, you can conserve system resources by deleting the ImageList associated with
the MS ImageList control.
- When adding an item, add it with Image index 1, and then use the LVM_SETITEM message to modify
the Image index.
- Whenever VB tries to reset the ImageList handle, ensure that the correct handle is replaced
again. This appears to only occur when you change the View property of the
ListView, however you can achieve a complete workaround by subclassing for the
LVM_SETIMAGELIST message sent to the control and consuming it.
These steps are demonstrated in the download samples.
|
Back to top
Back to Source Code
|
  |