Jump to content

Recommended Posts

Posted

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...

#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
Posted

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.

Posted

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?

Posted

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! :shocked:

Posted (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 :shocked:

Thanks for all the help

Edited by stevey

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...