stevey Posted April 6, 2007 Share Posted April 6, 2007 I am making a menu and some items I need to be grouped buttons, some I need check boxes, and some just buttons.... Is this the correct way to do this? Or is there a shorter better way...? This is probably horrible code, it does not even work properly... expandcollapse popup#include <GUIConstants.au3> GUICreate("ProgramTest", 200, 100, 0, 0) ;file menu $fileMenu = GUICtrlCreateMenu("File") $exitItem = GUICtrlCreateMenuitem("ExitButton", $fileMenu) GUICtrlSetOnEvent(-1, "MyExit") ;options menu $optionsMenu = GUICtrlCreateMenu("Options") $onItem = GUICtrlCreateMenuitem("On", $optionsMenu, 1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $offItem =GUICtrlCreateMenuitem("Off", $optionsMenu, 2, 1) GUICtrlCreateMenuitem("", $optionsMenu) ;submenu $moreMenu = GUICtrlCreateMenu("More", $optionsMenu) $enabledItem = GUICtrlCreateMenuitem("Enabled", $moreMenu, 1) GUICtrlSetState(-1, $GUI_UNCHECKED) GUICtrlCreateMenuitem("", $moreMenu) $1Item = GUICtrlCreateMenuitem("1", $moreMenu, 3, 1) $2Item = GUICtrlCreateMenuitem("2", $moreMenu, 4, 1) GUICtrlSetState(-1, $GUI_CHECKED) $3Item = GUICtrlCreateMenuitem("3", $moreMenu, 5, 1) $4Item = GUICtrlCreateMenuitem("4", $moreMenu, 6, 1) ;other menu $otherMenu = GUICtrlCreateMenu("Other") $checkBoxItem = GUICtrlCreateMenuitem("CheckBox", $otherMenu, 1, 1) GUICtrlSetState($checkBoxItem, $GUI_CHECKED) GUICtrlSetOnEvent($checkBoxItem, "CheckBox") GUISetState() WHile 1 Sleep(100) WEnd Func MyExit() MsgBox(0, "Test", "Hey") EndFunc Func CheckBox() If BitAnd(GUICtrlRead($checkBoxItem),$GUI_CHECKED) Then GUICtrlSetState($checkBoxItem, $GUI_UNCHECKED) ElseIf BitAnd(GUICtrlRead($checkBoxItem),$GUI_UNCHECKED) Then GUICtrlSetState($checkBoxItem, $GUI_CHECKED) EndIf EndFunc Link to comment Share on other sites More sharing options...
therks Posted April 6, 2007 Share Posted April 6, 2007 Right away I can tell you you missed one very important line. Opt('GUIOnEventMode', 1)oÝ÷ Øû¶jÛazÚ)¡ü¨º»®*mNÂ)ezvç¯z{f¡×°'!Êë¬x½êò¶)Ê®±á +k':q/z{@Ê2¢íýÛhr§ëaÉb殶sbb33c¶6V6´&÷FVÒÒuT7G&Ä7&VFTÖVçVFVÒgV÷C´6V6´&÷gV÷C²Âb33c¶÷FW$ÖVçR That last 1 makes it a radio menu item, and you just want it checked, right? So set the last 1 to 0, or just leave it out entirely. Other than that, without knowing exactly what it is you want, I'd say that looks like it's working. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
stevey Posted April 6, 2007 Author Share Posted April 6, 2007 That got it... still a few questions.. On the check box, is there a shorter route to writing that code? Or is that a decent way? This, was supposed to be: ;submenu $moreMenu = GUICtrlCreateMenu("More", $optionsMenu) $enabledItem = GUICtrlCreateMenuitem("Enabled", $moreMenu, 1, 1) GUICtrlCreateMenuitem("", $moreMenu) $1Item = GUICtrlCreateMenuitem("1", $moreMenu, 3, 1) $2Item = GUICtrlCreateMenuitem("2", $moreMenu, 4, 1) GUICtrlSetState(-1, $GUI_CHECKED) $3Item = GUICtrlCreateMenuitem("3", $moreMenu, 5, 1) $4Item = GUICtrlCreateMenuitem("4", $moreMenu, 6, 1) The Enabled was supposed to be a radio button grouped with the numbers, but the spacer I think is messing up the group, is that normal for the line? How would I go about grouping it back? Link to comment Share on other sites More sharing options...
therks Posted April 6, 2007 Share Posted April 6, 2007 As far as I know that checkbox method is the best way to do it. I think you are right about the spacer/divider screwing up the grouping. The only way I could think of to fix that, is to manually check/uncheck everything with a function like your checkbox. I could be wrong though, I'm no genius! My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
stevey Posted April 7, 2007 Author Share Posted April 7, 2007 (edited) Seems like a pain for coding these menus, my menu code is going to end up being like 150-200 lines for a basic menu Thanks for all the help Edited April 7, 2007 by stevey Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now