programmatically pressing toolbar buttons 
Author Message
 programmatically pressing toolbar buttons

I'm having difficulty depressing toolbar buttons
programmatically.  At times it works but most of the time
it doesn't.  I'm using KEY names to select the button
(see below).

Toolbar1.Buttons.item(AvViewX1.ProjectionMode).Value =
tbrPressed

AvViewX1.ProjectionMode (object property) is a string
that represents the KEY name.  I know the KEY name is
case sensitive.  Any thoughts?



Sat, 04 Dec 2004 01:54:00 GMT  
 programmatically pressing toolbar buttons
Mike -

Devices, such as the mouse, generate messages, which are queued to controls,
such as the toolbar.  You can send those messages yourself,
programmatically.  You need the handle to the button.  Here is an example
using an array of command buttons:

http://www.mvps.org/vbnet/index.html?http://www.mvps.org/vbnet/api/_a...
.htm

The problem is that the toolbar control does not expose handles to the
individual buttons, but rather to the entire control.  So your code will
need to encode the mouse position, I think.  The last parameter, which the
cited example passes as zero, ByVal:

Call SendMessage(currHwnd, WM_LBUTTONDOWN, 0, ByVal 0&)

In this you need to encode the mouse position in a longword, where the X
coordinated is in the lower order 2 bytes, and the Y coordinate is in the
upper order 2 bytes:

    lngEncodedPosition = Y * 32768 + X

The X and Y are relative to the upper left corner of the toolbar.  The fun
part will be figuring out what X and Y to use.  But maybe this much will get
you going?

HTH - Best Regards - Lee Gillie


Quote:
> I'm having difficulty depressing toolbar buttons
> programmatically.  At times it works but most of the time
> it doesn't.  I'm using KEY names to select the button
> (see below).

> Toolbar1.Buttons.item(AvViewX1.ProjectionMode).Value =
> tbrPressed

> AvViewX1.ProjectionMode (object property) is a string
> that represents the KEY name.  I know the KEY name is
> case sensitive.  Any thoughts?



Sun, 05 Dec 2004 05:16:33 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Retrieving index of pressed toolbar button

2. Find out if button is pressed on a Word toolbar

3. Simultaneously pressing a key and mouse-clicking a button on a toolbar

4. VB6: Problems with pressed / unpressed Toolbar buttons

5. Pressing button menu on a toolbar

6. OL98: Add Toolbar Button Programmatically

7. selecting a toolbar button programmatically

8. Toolbar Button Setting Programmatically

9. Selecting a toolbar button programmatically

10. BUG: Toolbar-Buttons wrong pictures - toolbar.zip (1/1)

11. BUG: Toolbar-Buttons wrong pictures - toolbar.zip (0/1)

12. Changing Toolbar Button Properties Outside of the Toolbar

 

 
Powered by phpBB® Forum Software