Always display ToolBarButton.DropDownMenu when clicked

D

David Clegg

I have a ToolBarButton with a Style of DropDownButton. I want the
DropDownMenu to display whenever the button is clicked, not just when
the arrow to the right is clicked.

I was thinking I could call
((ContextMenu)toolBarButton).DropDownMenu.Show(), but this needs a
Point parameter, which I'm a bit stuck on trying to calculate.

Is there a way to achieve this?

--
Cheers,
David Clegg
(e-mail address removed)

Vote 1 http://cc.borland.com/codecentral/ccweb.exe/listing?id=21489 :)
Now supports Google Groups searching with Dyna-extend(tm) technology!

QualityCentral. The best way to bug Borland about bugs.
http://qc.borland.com

"Are you sure this is the Sci-Fi Convention? It's full of nerds!" -
Homer Simpson
 
S

Sergey Bogdanov

You may simulate an arrow click by using mouse_event function. Here is
an example how it could be done for a button with DropDownButton style:

int x = 25;
int y = Screen.PrimaryScreen.WorkingArea.Height - 10;

x = 65535 / Screen.PrimaryScreen.WorkingArea.Width * x;
y = 65535 / Screen.PrimaryScreen.WorkingArea.Height * y;

mouse_event(0x8002, x, y, 0, 0);
mouse_event(0x8004, x, y, 0, 0);

....

[DllImport("coredll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int
dwData, int dwExtraInfo);


Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
D

David Clegg

Daniel said:

Thanks for the reference.

However, for this to work, I need to know the position of the arrow
portion of the ToolBarButton. I was going to iterate through all the
ToolBarButtons on the ToolBar and calculate the position based on that
(applying a different increment depending on the ToolBarButton.Style
value for each one). Am I on the right track with this approach, or is
there an easier way?

--
Cheers,
David Clegg
(e-mail address removed)

Vote 1 http://cc.borland.com/codecentral/ccweb.exe/listing?id=21489 :)
Now supports Google Groups searching with Dyna-extend(tm) technology!

QualityCentral. The best way to bug Borland about bugs.
http://qc.borland.com

"Weaselling out of things is important to learn. It's what separates us
from the animals. Except the weasel." - Homer Simpson
 
D

Daniel Moth

It sounds OK...

I haven't really thought about that to be honest because I have chosen to
hardcode the co-ordinates (having a generic solution was not a requirement).

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top