I am looking for a way for a Dialog (that is using a Callback Procedure) to have a button cause the contextual menu for itself to appear.
Currently I am
1) determine that a button has been pushed
2) determine that the button is "the one" I am talking about
3) execute MouseClick(@RCLICK,0)
but it does not always work
1) for instance, if the button press was achieved by keyboard actions (TAB, TAB, spacebar)
2) if the user moves the mouse immediately after the click
===
Some Ideas I have thought of but have not determined how
1) determine the mouse coordinates of the button that I am interested in, move mouse and then right click
how to accurately get mouse coords of a PUSHBUTTON control?
(MousePlay seems to have some possibilities because it can find the mouse coords of 0,0 of a parentwindow...)
2) programmically tell the dialog to open the menu
how to tell the dialog open menu X?
Aaron
Not surprisingly, I hope, we automate Dialog testing. Some of the things we do include using MouseMove and MouseClick to simulate a user right-click and use the SendKey* functions to test context menu hot keys.
You can always get a control's coordinates directly from the control using DialogControlGet request 17. Of course these numbers are in dialog units so they would need to be converted to virtual units. The Tech. Database contains several examples that illustrate conversion. WinPlaceGet and WinPositionChild can also be used to get window locations.
So I found a "less math" solution
(I really can do dialog unit math, but I really don't like to :) )
if ....
elseif ControlName == "SearchResultsButton" then ; this is "The Button that I want to do nothing more than right click itself"
DialogControlState(Handle, "SearchResultsButton",6, 0) ; neat trick that moves mouse over button..
MouseClick(@RCLICK, 0 )
return (-2)
elseif ....
Works as long you have a control with an event you can handle and you want to display the context menu when and were that event occurs.