ImageList for Icons not set

The place for threads about version 2.x of TimoSoft ExplorerTreeView.
Post Reply
Natorion
Lieutenant
Posts: 14
Joined: 12 Jan 2009, 10:35

ImageList for Icons not set

Post by Natorion »

Hi,

another TreeView question incoming ;)

I am setting the IExplorerTreeView.hImageList(ilItems) property with the help of a MSComctlLib.ImageList.hImageList.

Code: Select all

tvwUnicodeResult.hImageList(ilItems) = ImgNodePicture.hImageList
So far so good. On two developer machines the icons are shown. On two test machines they aren't. All computers have WinXP as OS. The ImageList is correctly initialized. I dug in a little bit and I found the following problem. The vwUnicodeResult.hImageList(ilItems) is not set with the value of ImgNodePicture.hImageList. On the two test machines the handle stays '0' which means don't show icons. Do you have any clue whats going wrong?

regards
natorion

Edit: setting the hImageList for ilHighResolution and ilState works fine. I am a little bit puzzeled :)
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: ImageList for Icons not set

Post by TiKu »

Are there any differences between the systems? Do some have themes activated and others not? Do they have different service packs installed? Do they use slightly different versions of mscomctl.ocx?

Looking at the code, I don't see a reason why this should fail. The control just passes the image list handle to the native tree view control by calling SendMessage with TVM_SETIMAGELIST and TVSIL_NORMAL, so it's probably code inside comctl32.dll that fails.
I wouldn't use the ImageList control from mscomctl.ocx anyway. Mscomctl.ocx is not dynamically linked to comctl32.dll, but ExplorerTreeView is. The native tree view control of Windows XP might have problems to use an image list control from 1998. Also none of the ImageList controls that allow adding the images at design time, do properly support 32 bit icons. Therefore I would always create the image list at run time, using the ImageList_* API. Yes, I've used the vbAccelerator control in the sample projects myself, but changed them to API-created image lists after I noticed the problems with 32 bit icons.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Natorion
Lieutenant
Posts: 14
Joined: 12 Jan 2009, 10:35

Re: ImageList for Icons not set

Post by Natorion »

Thanks for the fast reply.

I tried setting the imagelist directly with

Code: Select all

 buffer = TreeView_SetImageList(tvwUnicodeResult.hWnd, ImgNodePicture.hImageList, TVSIL_NORMAL)
...

Public Function TreeView_SetImageList(hWnd As Long, himl As Long, iImage As Long) As Long
  TreeView_SetImageList = SendMessage(hWnd, TVM_SETIMAGELIST, ByVal iImage, ByVal himl)
End Function
and the return value is 0. The hImageList property remains 0 although :/. The themes are the same (WinXP with Silver theme).

After all I tried checking the mscomctl.ocx files. Well, they differ. I swapped the file from the test machine (build date of the file 2002) with the file from my dev machine (build date of the file 2004) and it works. Thanks for the tip ;)

Regarding the ImageList* API, do you have any hintfull links on that topic?
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: ImageList for Icons not set

Post by TiKu »

Well, the image list API is documented. If you need sample code, have a look at the VB6 samples that come with my controls. Many of them use API-created image lists.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Natorion
Lieutenant
Posts: 14
Joined: 12 Jan 2009, 10:35

Re: ImageList for Icons not set

Post by Natorion »

Thanks, I do not know why I did not find it myself.
Post Reply