Results 1 to 22 of 22

Thread: hwnd of Toolbar buttons.

  1. #1

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391

    Question hwnd of Toolbar buttons.

    Does anyone know if it is possible to get the hwnd of a toolbar's buttons?
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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.
    Baaaaaaaaah

  3. #3

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391
    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.
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    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.

  5. #5
    Addicted Member brookema's Avatar
    Join Date
    Jul 2002
    Location
    Washington DC
    Posts
    161
    How would you do that?

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    The toolbars .hWnd property will give you its handle.

  7. #7
    Addicted Member MathImagics's Avatar
    Join Date
    Jun 2002
    Location
    Uki, NSW Australia
    Posts
    169

    A related problem

    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
    "He's got a B.A. (in be-bop), a Ph.D. (in swing), he's a Master of Rhythm, he's the Rock'n'Roll king" ("The Rock'n'Roll Doctor", Lowell George)

    "If you push something hard enough, it will fall over" (Fudd's Third Law of Opposition)

  8. #8

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391
    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?
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  9. #9
    Megatron
    Guest
    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.
    You can have separate tooltips for each button via the ToolTipText property.

  10. #10
    Addicted Member MathImagics's Avatar
    Join Date
    Jun 2002
    Location
    Uki, NSW Australia
    Posts
    169

    The plot thickens.....

    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????
    "He's got a B.A. (in be-bop), a Ph.D. (in swing), he's a Master of Rhythm, he's the Rock'n'Roll king" ("The Rock'n'Roll Doctor", Lowell George)

    "If you push something hard enough, it will fall over" (Fudd's Third Law of Opposition)

  11. #11
    Addicted Member MathImagics's Avatar
    Join Date
    Jun 2002
    Location
    Uki, NSW Australia
    Posts
    169
    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.....

  12. #12
    Addicted Member brookema's Avatar
    Join Date
    Jul 2002
    Location
    Washington DC
    Posts
    161
    Will this only work for VB apps? Like if you are Shelling another app into VB will this still work?

  13. #13

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391
    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.
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  14. #14

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391
    The toolbar does belong to me.
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  15. #15
    Addicted Member brookema's Avatar
    Join Date
    Jul 2002
    Location
    Washington DC
    Posts
    161
    I am "snaffle another running application" - is this the path you were headed down?

  16. #16

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391
    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?
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  17. #17
    Megatron
    Guest
    Originally posted by brookema
    Will this only work for VB apps? Like if you are Shelling another app into VB will this still work?
    The API method will work for any App, but my method will only work in design time of a VB project.

  18. #18
    Addicted Member MathImagics's Avatar
    Join Date
    Jun 2002
    Location
    Uki, NSW Australia
    Posts
    169
    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
    "He's got a B.A. (in be-bop), a Ph.D. (in swing), he's a Master of Rhythm, he's the Rock'n'Roll king" ("The Rock'n'Roll Doctor", Lowell George)

    "If you push something hard enough, it will fall over" (Fudd's Third Law of Opposition)

  19. #19
    Addicted Member brookema's Avatar
    Join Date
    Jul 2002
    Location
    Washington DC
    Posts
    161
    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.
    Which API method is this?

  20. #20
    Addicted Member MathImagics's Avatar
    Join Date
    Jun 2002
    Location
    Uki, NSW Australia
    Posts
    169
    ... 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
    "He's got a B.A. (in be-bop), a Ph.D. (in swing), he's a Master of Rhythm, he's the Rock'n'Roll king" ("The Rock'n'Roll Doctor", Lowell George)

    "If you push something hard enough, it will fall over" (Fudd's Third Law of Opposition)

  21. #21

    Thread Starter
    Hyperactive Member brenaaro's Avatar
    Join Date
    Sep 2001
    Location
    Montreal, Canada
    Posts
    391

    I'll give it a shot.

    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.
    And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.

  22. #22
    New Member
    Join Date
    Jul 2002
    Location
    holland
    Posts
    5
    what i do is:
    first use FindWindow to find the window, then use FindWindowEx to find the button inside the window
    There is always a way to create what u want

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width