Jump to content
Sign in to follow this  
GajjarTejas

Menu: is Item Checked

Recommended Posts

GajjarTejas

hi! I have created menu with radio check box then button. My problem is that getting status of MenuItem3, MenuItem4 and MenuItem5. here is my script.

#include 
#include 
#include 

$hGUI = GUICreate("Form1", 361, 94, 387, 377) ;Create GUI
$MenuItem1 = GUICtrlCreateMenu("MenuItem1") ;Create Main Menu
$MenuItem2 = GUICtrlCreateMenu("MenuItem2", $MenuItem1) ;Create SubMenu(branch: MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("MenuItem3", $MenuItem2, -1, 1) ;Create SubMenu WITH RADIO(branch: MenuItem2)
$MenuItem4 = GUICtrlCreateMenuItem("MenuItem4", $MenuItem2, -1, 1) ;Create SubMenu WITH RADIO(branch: MenuItem2)
GUICtrlSetState(-1, $GUI_CHECKED) ;Check MenuItem4
$MenuItem5 = GUICtrlCreateMenuItem("MenuItem5", $MenuItem2, -1, 1) ;Create SubMenu WITH RADIO(branch: MenuItem2)
$Button = GUICtrlCreateButton("Test!", 125, 20, 131, 36)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button
If GUICtrlRead($MenuItem3) = $GUI_CHECKED Then MsgBox(0, "Test", "MenuItem3 is checked!")
If GUICtrlRead($MenuItem4) = $GUI_CHECKED Then MsgBox(0, "Test", "MenuItem4 is checked!")
If GUICtrlRead($MenuItem5) = $GUI_CHECKED Then MsgBox(0, "Test", "MenuItem5 is checked!")
EndSwitch
WEnd

Share this post


Link to post
Share on other sites
stormbreaker

Not good, something like:

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

$hGUI = GUICreate("Form1", 361, 94, 387, 377) ;Create GUI
$MenuItem1 = GUICtrlCreateMenu("MenuItem1") ;Create Main Menu
$MenuItem2 = GUICtrlCreateMenu("MenuItem2", $MenuItem1) ;Create SubMenu(branch: MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("MenuItem3", $MenuItem2, -1, 1) ;Create SubMenu WITH RADIO(branch: MenuItem2)
$MenuItem4 = GUICtrlCreateMenuItem("MenuItem4", $MenuItem2, -1, 1) ;Create SubMenu WITH RADIO(branch: MenuItem2)
GUICtrlSetState(-1, $GUI_CHECKED) ;Check MenuItem4
$MenuItem5 = GUICtrlCreateMenuItem("MenuItem5", $MenuItem2, -1, 1) ;Create SubMenu WITH RADIO(branch: MenuItem2)
$Button = GUICtrlCreateButton("Test!", 125, 20, 131, 36)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button
If BitAnd(GUICtrlRead($MenuItem3), $GUI_CHECKED) Then MsgBox(0, "Test", "MenuItem3 is checked!")
If BitAnd(GUICtrlRead($MenuItem4), $GUI_CHECKED) Then MsgBox(0, "Test", "MenuItem4 is checked!")
If BitAnd(GUICtrlRead($MenuItem5), $GUI_CHECKED) Then MsgBox(0, "Test", "MenuItem5 is checked!")
EndSwitch
WEnd

does it, am I right or am I right?

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites
GajjarTejas

Right!

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  

×