Jump to content

Recommended Posts

Posted

Any body use menuradioitem =1 ?
Do any body can make example to show how to read/check state ?

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Hello. Check.

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

Example()

Func Example()
    GUICreate("My GUI menu", 300, 200)

    Local $sStatus = "Ready"

    Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileItem = GUICtrlCreateMenuItem("Open", $idFileMenu)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    Local $idHelpMenu = GUICtrlCreateMenu("?")
    GUICtrlCreateMenuItem("Save", $idFileMenu)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local $idInfoItem = GUICtrlCreateMenuItem("Info", $idHelpMenu)
    Local $idExit = GUICtrlCreateMenuItem("Exit", $idFileMenu)
    Local $idRecentFilesMenu = GUICtrlCreateMenu("Recent Files", $idFileMenu, 1)

    GUICtrlCreateMenuItem("", $idFileMenu, 2) ; Create a separator line

    Local $idViewMenu = GUICtrlCreateMenu("View", -1, 1) ; Is created before "?" menu
    Local $idViewStatusItem = GUICtrlCreateMenuItem("Radio Item", $idViewMenu, -1, 1)
;~     GUICtrlSetState(-1, $GUI_CHECKED)
    Local $idbtnGetState=GUICtrlCreateButton("Get [View->Radio Item] State", 50, 130, 200, 20)
    GUICtrlSetState(-1, $GUI_FOCUS)

    Local $idStatusLabel = GUICtrlCreateLabel($sStatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))

    GUISetState(@SW_SHOW)


    Local $sFilePath
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idExit
                Exit
            Case $idbtnGetState
                MsgBox(0, "", BitAND(GUICtrlRead($idViewStatusItem), $GUI_CHECKED) ? "Checked" : "Not Checked")

            Case $idInfoItem
                MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")

            Case $idFileItem
                $sFilePath = FileOpenDialog("Choose a file...", @TempDir, "All (*.*)")
                If @error Then
                    ContinueLoop
                EndIf
                GUICtrlCreateMenuItem($sFilePath, $idRecentFilesMenu)

            Case $idViewStatusItem
                ;Do Nothing. It Check/Uncheck itself.


        EndSwitch
    WEnd
EndFunc   ;==>Example

Saludos

 

Posted (edited)

Thanks works fine.

Using your example I just create this Modified/Simpler example:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

Example()

Func Example()
    GUICreate("My GUI menu", 300, 200)

    Local $idViewMenu = GUICtrlCreateMenu("View", -1, 1) ; Is created before "?" menu
    Local $idViewStatusItem = GUICtrlCreateMenuItem("Radio Item", $idViewMenu, -1, 1)

    Local $idbtnGetState = GUICtrlCreateButton("Get [View->Radio Item] State", 50, 130, 200, 20)
    GUICtrlSetState(-1, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $idbtnGetState
                MsgBox(0, "", BitAND(GUICtrlRead($idViewStatusItem), $GUI_CHECKED) ? "Checked" : "Not Checked")
        EndSwitch
    WEnd
EndFunc   ;==>Example

 

Hm.... so this is something bad on my side, in one of my project. I must review them .... :(

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...