Sign in to follow this  
Followers 0
Aceguy

Guictrlcreatecontextmenu() help wanted please

6 posts in this topic

#include<guiconstants.au3>
Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Countdown", 450, 80, 810, 74, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST))
$settings = GUICtrlCreateButton("Settings", 375, 40, 60, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$buttoncontext = GUICtrlCreateContextMenu($settings)
$buttonitem = GUICtrlCreateMenu("Listen Time", $buttoncontext)
$buttonitem1 = GUICtrlCreateMenu("Bar Update", $buttoncontext)
$key0 = GUICtrlCreateMenuItem("200", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
$key1 = GUICtrlCreateMenuItem("100", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
$key2 = GUICtrlCreateMenuItem("75", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
$key3 = GUICtrlCreateMenuItem("50", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
GUICtrlSetState(-1, $GUI_CHECKED)
$key2 = GUICtrlCreateMenuItem("25", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
$bar1 = GUICtrlCreateMenuItem("1000", $buttonitem1)
GUICtrlSetOnEvent(-1, "bars")
$bar2 = GUICtrlCreateMenuItem("500", $buttonitem1)
GUICtrlSetOnEvent(-1, "bars")
GUICtrlSetState(-1, $GUI_CHECKED)
$bar2 = GUICtrlCreateMenuItem("250", $buttonitem1)
GUICtrlSetOnEvent(-1, "bars")

GUISetState(@SW_SHOW)

while 1
sleep(50)
WEnd

Func listen()
EndFunc

func Bars()
EndFunc

How do i register the Menu being clicked please.?

Share this post


Link to post
Share on other sites



From the help file...

#include<guiconstants.au3>

$Form1 = GUICreate("Countdown", 450, 80, 810, 74, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST))
$settings = GUICtrlCreateButton("Settings", 375, 40, 60, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$buttoncontext = GUICtrlCreateContextMenu($settings)
$buttonitem = GUICtrlCreateMenu("Listen Time", $buttoncontext)
$buttonitem1 = GUICtrlCreateMenu("Bar Update", $buttoncontext)
$key0 = GUICtrlCreateMenuItem("200", $buttonitem)
$key1 = GUICtrlCreateMenuItem("100", $buttonitem)
$key2 = GUICtrlCreateMenuItem("75", $buttonitem)
$key3 = GUICtrlCreateMenuItem("50", $buttonitem)
GUICtrlSetState(-1, $GUI_CHECKED)

$key2 = GUICtrlCreateMenuItem("25", $buttonitem)
$bar1 = GUICtrlCreateMenuItem("1000", $buttonitem1)
$bar2 = GUICtrlCreateMenuItem("500", $buttonitem1)
GUICtrlSetState(-1, $GUI_CHECKED)

GUISetState(@SW_SHOW)

while 1

 $msg = GUIGetMsg()
        
    Select
        
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop

    Case $msg = $key0
    GUICtrlSetState($key0,$GUI_CHECKED)
    Msgbox(4096,"Selected","200")
        
    
    EndSelect
WEnd

Func listen()
EndFunc

func Bars()
EndFunc

Share this post


Link to post
Share on other sites

how does this work with guictrlsetonevent.?

Why would you want to use guictrlsetonevent?

Share this post


Link to post
Share on other sites

#include<guiconstants.au3>
Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Countdown", 450, 80, 810, 74, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST))
$settings = GUICtrlCreateButton("Settings", 375, 40, 60, 20)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$buttoncontext = GUICtrlCreateContextMenu($settings)
$buttonitem = GUICtrlCreateMenu("Listen Time", $buttoncontext)
$buttonitem1 = GUICtrlCreateMenu("Bar Update", $buttoncontext)

$key0 = GUICtrlCreateMenuItem("200", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
$key1 = GUICtrlCreateMenuItem("100", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
$key2 = GUICtrlCreateMenuItem("75", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
$key3 = GUICtrlCreateMenuItem("50", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")
GUICtrlSetState(-1, $GUI_CHECKED)
$key2 = GUICtrlCreateMenuItem("25", $buttonitem)
GUICtrlSetOnEvent(-1, "listen")

$bar1 = GUICtrlCreateMenuItem("1000", $buttonitem1)
GUICtrlSetOnEvent(-1, "bars")
$bar2 = GUICtrlCreateMenuItem("500", $buttonitem1)
GUICtrlSetOnEvent(-1, "bars")
GUICtrlSetState(-1, $GUI_CHECKED)
$bar2 = GUICtrlCreateMenuItem("250", $buttonitem1)
GUICtrlSetOnEvent(-1, "bars")

GUISetState(@SW_SHOW)

while 1
sleep(50)
WEnd

Func listen()

    Select
        Case @GUI_CTRLID = $key0
            GUICtrlSetState($key0,$GUI_CHECKED)
            MsgBox(0, "200 Checked", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
           ;Exit
            
    EndSelect
    
EndFunc

func Bars()
EndFunc

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0