Jump to content

Recommended Posts

Posted

So, if someone would explain to me why the ContextMenu shows on "Button 2" when it is set for "Button 1" :huh: ???

#include <GUIConstantsEx.au3>

$MyGUI = GUICreate("My TEST GUI", 220, 125)

 $Button1 = GUICtrlCreateButton("Button 1", 10, 10, 200, 25)
  $ContextMenu = GUICtrlCreateContextMenu ($Button1)
   $MenuItem1 = GUICtrlCreateMenuItem("Item 1", $ContextMenu)
   $MenuItem2 = GUICtrlCreateMenuItem("Item 2", $ContextMenu)

 $Label = GUICtrlCreateLabel ("", 10, 55, 200, 20)

 $Button2 = GUICtrlCreateButton("Button 2 - Show Menu on Button 1", 10, 90, 200, 25)

GUISetState()

While 1
 $msg = GUIGetMsg()

 Select
  Case $msg = $GUI_EVENT_CLOSE
   ExitLoop

  Case $msg = $Button2
   ControlClick ($MyGUI, "", $Button1, "secondary")

  Case $msg = $MenuItem1
   GUICtrlSetData ($Label, 'Menu Item 1 selected')

  Case $msg = $MenuItem2
   GUICtrlSetData ($Label, 'Menu Item 2 selected')

 EndSelect
WEnd

Exit

Thank you :D

Posted (edited)

ContextMenu is displayed at the current position of the Mouse

In Edit Controls the ContextMenu is displayed at the Caret position

#include-once
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
$MyGUI = GUICreate("My TEST GUI", 220, 125)
$Button1 = GUICtrlCreateButton("Button 1", 10, 10, 200, 25)
$ContextMenu = GUICtrlCreateContextMenu ($Button1)
$MenuItem1 = GUICtrlCreateMenuItem("Item 1", $ContextMenu)
$MenuItem2 = GUICtrlCreateMenuItem("Item 2", $ContextMenu)
$Label = GUICtrlCreateLabel ("", 10, 55, 200, 20)
$Button2 = GUICtrlCreateButton("Button 2 - Show Menu on Button 1", 10, 90, 200, 25)

GUISetState()

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
GUIDelete($MyGUI)
Exit
Case $msg = $Button2
Local $cPos=ControlGetPos('','',$Button1)
Local $tPoint=DllStructCreate($tagPOINT)
DllStructSetData($tPoint,1,($cPos[0]+$cPos[2])/2)
DllStructSetData($tPoint,2,($cPos[1]+$cPos[3])/2)
Local $wPos=_WinAPI_ClientToScreen($MyGUI,$tPoint)
MouseMove(DllStructGetData($wPos,1),DllStructGetData($wPos,2),0)
ControlClick ($MyGUI, "", $Button1, "secondary")
Case $msg = $MenuItem1
GUICtrlSetData ($Label, 'Menu Item 1 selected')
Case $msg = $MenuItem2
GUICtrlSetData ($Label, 'Menu Item 2 selected')
EndSelect
WEnd
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted (edited)

ContextMenu is displayed at the current position of the Mouse

Then what is the point of "x" and "y" in

ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )
x ... [optional] The x position to click within the control. Default is center.
y ... [optional] The y position to click within the control. Default is center.

Edit: Stupid of me to ask :oops: . It is not for this control but for others when needed

Edited by toofat

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...