Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toolbar from Taskbar (Tricky VB question)

Status
Not open for further replies.

Illspirit

Programmer
Oct 15, 2001
4
GB
Hi,

This isn't a C++ question, and I know VERY little C++, but I'm hoping a C++ programmer will have the answer.

I'm developing a Longhorn style desktop sidebar for Windows XP in Visual Basic, and I have it all working pretty well so far apart from the system tray. I am currently moving the ToolbarWindow32 from the taskbar onto my window, however this is causing explorer to become unstable and crash. I'm anxious to keep the existing taskbar untouched by my app, so I've had another idea which seemed good at first glance.

I want to use the SendMessage function with the toolbar messages to create a clone of the system tray on my window. So far I have managed to create a ToolbarWindow32 on my window by using CreateWindowEx, and create the same number of buttons by sending TB_BUTTONCOUNT to the tray. Ive sent TB_GETBITMAP to each button to get its imagelist index.

The problem is that I cannot get the icons to display on my toolbar buttons. I am using TB_GETIMAGELIST to get the handle of the system tray's image list, and TB_SETIMAGELIST to set my toolbar to use the same imagelist (Ive checked mine with GETIMAGELIST and they definatley use the same handle), but it doesnt work - my buttons are just very small, blank buttons. Ive also tried to use the ImageList_Duplicate API to copy the system tray's image list, but that just returns 0. I've spent a few weeks on this and I just havent been able to work it out.

I've asked on Visual Basic forums but nobody seems to be able to help because nobody seems to have attempted anything even remoteley similar to this before in VB. I'm just wondering if anyone can help me out, because I'm guessing that this is something to do with the way Windows works rather than the code Ive used (I'm 99.9% sure my code is correct). All the documentation I can find on using the TB_* messages is related to C++, which is why I have decided to seek help here.

If my problem is unclear then please let me know and I'll try and rephrase it. I'm getting quite desperate and I need to make some progress on this issue quite soon.

Thanks a lot,
Illspirit
 
>> I am using TB_GETIMAGELIST to get the handle of the
>> system tray's image list

That handle is not going to be valid in your process.

-pete
 
Hi,

I'm not sure I understand, please could you explain that a little?

Thanks
 
The image list resource is loaded into the memory of the system tray process. The handle is a "key" to finding the resource in the system tray process. When you use the handle the function will try to use the handle to find the resource in your process memory. Not going to work cause it's not there.

-pete
 
OK, I think I understand. I take it there is no way I can do this then? No way to get round this problem or make my own copy of the image list?
 
>> make my own copy of the image list?

An image list is a memory based (as opposed to disk based) representation of a runtime resource. You cannot copy memory from another process, well ok so you can but I would not try it especially from VB.

You can, in theory, create your own processes image list by loading the same disk based resources that the system tray uses for it's image list (usually a resource based bitmap). Of course you have to know where they are first ( for example SHELL32.DLL), then you have to create an image list resource in your application.

-pete
 
OK, Thanks for your help. I think I'll have to find a different approach to this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top