Calling a Context menu from a push button (OpenInsight 32-Bit)
At 06 APR 2005 11:19:01PM David Goddard wrote:
I'd like to do the following:
Display a menu under a push button when the user clicks on the button. Internet Explorer does this on the Back and Forward buttons. EG clicking the down arrow next to back button displays a menu located under the back button with a list of the last 10 pages viewed.
I can create context menus Ok, but the user needs to rightclick to display the menu and the menu appears where the user clicked.
So how do you display a menu at a specified location when a push button is clicked?
Thanks
Dave G
At 07 APR 2005 12:09AM [email protected]'s Don Bakke wrote:
David,
I haven't tried this myself but I don't see why you can't use a different context menu for the same button to do the same thing. But you'll use the CLICK event to create a different menu structure, modify the lParam to position the menu underneath the button, and then use the PostMessage call to call the popup menu.
At 07 APR 2005 12:15AM David Goddard wrote:
Thanks Don,
I'll give it a go and let you know how I get on.
Dave G
At 07 APR 2005 01:03AM David Goddard wrote:
PostMessage was the trick! Now I have a context menu appearing when the user clicks the push button. Still playing with positioning but hey, i'm half way there.
Thanks
Dave G
At 07 APR 2005 01:17AM [email protected]'s Don Bakke wrote:
At 07 APR 2005 01:53AM David Goddard wrote:
Still having a problem with the position.
I'm calling postmessage as follows
PostMessage(handle,516,0,clickposition)
516 is the Rbuttondown event
0 - does not seem to do anything
clickpos - you specify the position of the mouse here. I can change the Y position OK but the x position does not want to move.
PostMessage uses the top left corner of my button as a starting position. I can pass a negative number to move the mouseclick left, but I can not move the mouseclick down below my push button. So the context menu will appear over my button, not under it.
on MSDN is says that the low-order word specifies the x-coordinate of the cursor and the high-order word specifies the y-coordinate of the cursor. Not sure exactly what this means?
Any help greatly appreciated.
Dave G
At 07 APR 2005 04:22AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:
Dave,
on MSDN is says that the low-order word specifies the x-coordinate of the cursor and the high-order word specifies the y-coordinate of the cursor. Not sure exactly what this means?
It means that the number that you pass in lParam (which the engine translates into a 32-bit integer for you) is actually composed of two 16-bit values, so you need to pack your x and y into this structure accordingly.
eg:
loWord=45
hiWord=30
longVal=( hiWord * 65535 ) + loWord
World leaders in all things RevSoft
At 07 APR 2005 06:11PM David Goddard wrote:
Thanks, works like a bought one now!
Dave G