Open toolbar button Menu with {%ALT}!!!!! 
Author Message
 Open toolbar button Menu with {%ALT}!!!!!

Hi, My name is Christopher, I would like any advice related to next
question:

-How can I automatically, open a Toolbar Drop-Down Button Menu upon
pressing an F-key.?

Like what you do with the drop-down combo box, sending the key secuence
{%ALT}
reagards and thanks in advance...

Chris.



Sat, 16 Nov 2002 03:00:00 GMT  
 Open toolbar button Menu with {%ALT}!!!!!
After working a bit, and reading a message from Olivier Belzile

I found how to do it.

For those who could be interested in this issue I am posting the solution:

Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long,

ByVal y As Long) As Long

Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long,

ByVal dx As Long,

ByVal dy As Long,

ByVal cButtons As Long,

ByVal dwExtraInfo As Long)

Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10

Private Sub Command2_Click()
    Dim r As Long

    r = SetCursorPos((Form1.Left / Screen.TwipsPerPixelX) +
(Toolbar.Buttons(1).Width / Screen.TwipsPerPixelX),  _
                                (Form1.Top / Screen.TwipsPerPixelY) +
(Toolbar.ButtonHeight / Screen.TwipsPerPixelY))

    mouse_event MOUSEEVENTF_LEFTDOWN, _
                         (Form1.Left / Screen.TwipsPerPixelX) +
(Toolbar.Buttons(1).Width / Screen.TwipsPerPixelX), _
                         (Form1.Top / Screen.TwipsPerPixelY) +
(Toolbar.ButtonHeight / Screen.TwipsPerPixelY), _
                         0, _
                         0

    mouse_event MOUSEEVENTF_LEFTUP,  _
                         (Form1.Left / Screen.TwipsPerPixelX) +
(Toolbar.Buttons(1).Width / Screen.TwipsPerPixelX), _
                         (Form1.Top / Screen.TwipsPerPixelY) +
(Toolbar.ButtonHeight / Screen.TwipsPerPixelY), _
                         0, _
                         0
End Sub

You must define a Form and a Toolbar on it, also a Command button
(command2). Also, you need to add a dropdown button to the toolbar.

If there is any easier way to do this, please let me know.

Chris

Quote:

> Hi, My name is Christopher, I would like any advice related to next
> question:

> -How can I automatically, open a Toolbar Drop-Down Button Menu upon
> pressing an F-key.?

> Like what you do with the drop-down combo box, sending the key secuence
> {%ALT}
> reagards and thanks in advance...

> Chris.



Sun, 17 Nov 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Open a custom form with a module-button (not a toolbar button)

2. Toolbar button caption does not support ALT keys

3. Active/Inactive toolbar buttons/menu commands

4. Responding to Menu items and Toolbar buttons

5. Transparent images in toolbar button/menu ?

6. Click-Event for runtime-built Toolbar Button Dropdown Menu

7. Controls on a form (including menus and toolbar buttons)

8. Simulating toolbar button click through menu item?

9. Methods for linking menu items and toolbar buttons?

10. Avoiding duplicate code in menus and toolbar buttons

11. Toolbar Button menu

12. VB Toolbar showing button menus with code

 

 
Powered by phpBB® Forum Software