Does anyone know if it is possible to get the hwnd of a toolbar's buttons?
Printable View
Does anyone know if it is possible to get the hwnd of a toolbar's buttons?
Don't know if it'll work but you can compute the position of a certain button (first getting the position of the toolbar related to the screen coordinates and then get the position of the button by using some kind of ratio) in the toolbar and you can use "WindowFromPoint" to get the handle of the button by providing the position you calculated before.
I tried using that WindowFromPoint but it returned the handle of the toolbar =\
I even tried CreateWindowEx ing a transparent window over the coordinates of a button but it still didn't work. (I am trying to add a CustomToolTip to my toolbar buttons). Even though I do InitCommonControls with ICC_COOL_CLASSES it still doesnt seem to recognize it..I can't even attach the tip balloon to the toolbar =\
Can anyone verify that the value of ICC_COOL_CLASSES is &H400? Maybe that's whats wrong.
Toolbarbuttons don't have a window handle because they are no windows. The toolbar draws them. the only windowhandle you could retrieve is the one from the toolbar.
How would you do that?
The toolbars .hWnd property will give you its handle.
What is brenarro actually trying to do? If he's trying to interact somehow with a button on a toolbar in another process, he will have to engage in a message dialog with the toolbar's window.
This is similar to the case for ListViews, TreViews etc, in other words, possible but tricky. Interacting with post-Win3.1 controls like this requires the use of shared memory bufers...
Dr Memory :cool:
Well, what I was orignally trying to do was hook the "custom tool tip window" (a balloon tip, basically) created by the attached class file to the buttons on a toolbar.
I did not write this class, but you need to specify the handle of the parent window that will hold the "custom tool tip window".
Since I can only get the handle of the entire toolbar, and not the individual buttons, I would only be able to make one balloon tip for the whole bar, and not each button.
MathImagics can you elaborate on what you mean by sharing memoy buffers, or perhaps point me to a site that can explain more?
You can have separate tooltips for each button via the ToolTipText property.Quote:
Originally posted by brenaaro
Since I can only get the handle of the entire toolbar, and not the individual buttons, I would only be able to make one balloon tip for the whole bar, and not each button.
There will be a ToolTip control associated with the target ToolBar control. The window handle of the ToolTip control can be found by sending the ToolBar window a TB_GETTOOLTIPS message.
Once you know the ToolTip windw handle, there are two ways to go. One I know works I'll come to, the other is Subclassing the ToolTip window, which I can't say much about, as I try to avoid subclassing if I can.
The ToolTip window has an array of TOOLINFO structures, and if you want to put your own text in there it can be done with a TTM_UPDATETOOLTIP message....
BUT!!!!! .....
I'll continue if you can confirm that this is what you are trying to do - substitute text of your own in selected button/tooltips... is this correct????
Megatron, sorry if I'm barking up the wrong tree - I'm not sure if he's trying to snaffle another running application, or he's working on a toolbar that belongs to him.....
Will this only work for VB apps? Like if you are Shelling another app into VB will this still work?
That's pretty close to what I'm trying to do. I know I can assign normal tooltips to each of the toolbars buttons via their ToolTip property, but that gives the standard "small, square" tooltips.
The clsToolTips lets you create "XP-like" balloon tips.
So essentially, yes I suppose if I can get the handle of the existing tooltips, and replace them with the balloon tips of clsToolTips (which include the icons, caption, speech bubble shape, etc) that would be genial.
The toolbar does belong to me.
I am "snaffle another running application" - is this the path you were headed down?
brookema: I'm snaffling my own app, but I think we will end up using the same solution if it presents itself. It looks likely that we will need to get the window of the tooltips themselves and then do some manipulation...if that's where MathImagics is heading?
The API method will work for any App, but my method will only work in design time of a VB project.Quote:
Originally posted by brookema
Will this only work for VB apps? Like if you are Shelling another app into VB will this still work?
If it's your own application, then presumably you are building the toolbar?
If so, AND you can add the buttons in the program, then you could send a TB_SETTOOLTIPS message to the toolbar, passing it the handle of your ToolTip window (a bit like assigning an image list to a Treeview).....
Sorry, gotta have dinner now, I'll check back in half an hour or so...
Dr Memory
Which API method is this?Quote:
Originally posted by Megatron
The API method will work for any App, but my method will only work in design time of a VB project.
... as I was saying, if it's your toolbar then you can send it a TB_SETTOOLTIPS message passing the handle of the ToolTip control you create.
But you need to do this association before you add any buttons, which means you have create the toolbar without buttons, then associate it with your Tooltip window, and then you add the buttons, so that Windows will send the right signals to your Tooltip window, when the mouse moves, etc...
I hope this helps (forget the shared memory stuff, I thought you were talking about a toolbar in another process)
Dr Memory :cool:
Hmm interesting idea...
I'm at home now but I'll try it when I get into the office tomorow morning and let you know what I got.
Thanks for the input btw.
what i do is:
first use FindWindow to find the window, then use FindWindowEx to find the button inside the window