Jump to content

Help with RadioButton (Group) Menu [Radio Group Menu Items never are triggered/selected]


DaRam
 Share

Recommended Posts

Hi, This is driving me nuts :)

Appreciate any help with this. Thanks.

#NoTrayIcon
#include <GUIConstants.au3>

Const $Views[4] = ["Icons", "Small Icons", "List", "Details"]
Dim $GUI_Main, $MenuView1, $MenuView1Views[4], $MenuView2, $MenuView2Views[4]
$GUI_Main = GUICreate("Radio Group Menu Items Problem", 300, 200)

$MenuView1 = GUICtrlCreateMenu("&View-1")
For $I = 0 to 3
        $MenuView1Views[$I] = GUICtrlCreateMenuItem("&" & $Views[$I], $MenuView1)
        If $I = 0 Then GUICtrlSetState(-1, $GUI_CHECKED)
Next;$I

$MenuView2 = GUICtrlCreateMenu("&View-2")
For $I = 0 to 3
        $MenuView2Views[$I] = GUICtrlCreateMenuItem("&" & $Views[$I], $MenuView2, -1, 1); menuradioitem
        If $I = 0 Then GUICtrlSetState(-1, $GUI_CHECKED)
Next;$I

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
             Exit
    Case $MenuView1Views
             Msgbox(64, "$MenuView1Views Clicked !", "This is never Triggered. Otherwise, have to find Index?")
    Case $MenuView1Views[0]
             Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 0)
    Case $MenuView1Views[1]
             Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 1)
    Case $MenuView1Views[2]
             Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 2)
    Case $MenuView1Views[3]
             Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 3)

    Case $MenuView2Views
             Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Otherwise, have to find Index?")
    Case $MenuView2Views[0]
             Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 0)
    Case $MenuView2Views[1]
             Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 1)
    Case $MenuView2Views[2]
             Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 2)
    Case $MenuView2Views[3]
             Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 3)
    EndSwitch
WEnd

Edit: Changed topic description.

Edited by DaRam
Link to comment
Share on other sites

Hi, This is driving me nuts :)

Appreciate any help with this. Thanks.

CODE
#NoTrayIcon

#include <GUIConstants.au3>

Const $Views[4] = ["Icons", "Small Icons", "List", "Details"]

Dim $GUI_Main, $MenuView1, $MenuView1Views[4], $MenuView2, $MenuView2Views[4]

$GUI_Main = GUICreate("Radio Group Menu Items Problem", 300, 200)

$MenuView1 = GUICtrlCreateMenu("&View-1")

For $I = 0 to 3

$MenuView1Views[$I] = GUICtrlCreateMenuItem("&" & $Views[$I], $MenuView1)

If $I = 0 Then GUICtrlSetState(-1, $GUI_CHECKED)

Next;$I

$MenuView2 = GUICtrlCreateMenu("&View-2")

For $I = 0 to 3

$MenuView2Views[$I] = GUICtrlCreateMenuItem("&" & $Views[$I], $MenuView2, -1, 1); menuradioitem

If $I = 0 Then GUICtrlSetState(-1, $GUI_CHECKED)

Next;$I

GUISetState(@SW_SHOW)

While 1

Switch GUIGetMsg()

Case $GUI_EVENT_CLOSE

Exit

Case $MenuView1Views

Msgbox(64, "$MenuView1Views Clicked !", "This is never Triggered. Otherwise, have to find Index?")

Case $MenuView1Views[0]

Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 0)

Case $MenuView1Views[1]

Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 1)

Case $MenuView1Views[2]

Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 2)

Case $MenuView1Views[3]

Msgbox(64, "$MenuView1Views Clicked !", "Index = " & 3)

Case $MenuView2Views

Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Otherwise, have to find Index?")

Case $MenuView2Views[0]

Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 0)

Case $MenuView2Views[1]

Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 1)

Case $MenuView2Views[2]

Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 2)

Case $MenuView2Views[3]

Msgbox(64, "$MenuView2Views Clicked !", "This is never Triggered. Index would have been = " & 3)

EndSwitch

WEnd

I'm assuming you're using AutoIt v3.2.12.0 (the code you provided worked fine for me w/ 3.2.10.0, but I could reproduce your error with 3.2.12.0). If I had to guess, I'd say it's related to the fact that the GUIConstants.au3 is no longer technically in use in the way that it was before the update. The file exists, but in its current state, all it does is include GUIConstantsEx.au3 (so, for this script, and all future scripts, you may want to start using GUIConstantsEx.au3 so you don't get hosed when the old one is phased out).

How it works now, instead of your program getting bloated with all of the unnecessary extras (eg, including all of the backend stuff for Listboxes, etc, even when your GUI doesn't use any), you have to include the relevant includes (~)individually for the different classes of items you'd be using.

That being said, I can't find which include would be relevant here. I've trolled through some of them, and even tried including all of the #include entries from the way it was done in 3.2.10.0, but without success.

All in all, I'm unsure if this is just a matter of identifying the right #include file, or a bug, as the help file entry for GUICtrlCreateMenuItem() didn't specify one (this includes attempting to use the ones in the "example" script entry).

Edit:

Just for the sake of argument, I went back and ran it with every standard #include added (whole directory listing for autoit3\include) and it still failed to trigger on the radio-style entries.

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Thanks Monamo. Yes, I am using 3.2.12.0 - I would have never thought to associate the issue with the declares in the includes.

but I could reproduce your error with 3.2.12.0).

Just to clarify, the code I posted does not produce an error. Do you get an error with 3.2.12.0?

(so, for this script, and all future scripts, you may want to start using GUIConstantsEx.au3 so you don't get hosed when the old one is phased out).

Noted, good suggestion.

How it works now, instead of your program getting bloated with all of the unnecessary extras (eg, including all of the backend stuff for Listboxes, etc, even when your GUI doesn't use any), you have to include the relevant includes (~)individually for the different classes of items you'd be using.

I was under the impression unreferenced functions and constants were discarded during compile.

I've trolled through some of them, and even tried including all of the #include entries from the way it was done in 3.2.10.0, but without success.

Same here, I could not find a single example (even by a google search of the forum) of any script using the "radio" menu style (other than defining it).

All in all, I'm unsure if this is just a matter of identifying the right #include file, or a bug, as the help file entry for

Hoping some (more?) "Guru's" would chime in here. :):) Edited by DaRam
Link to comment
Share on other sites

Just to clarify, the code I posted does not produce an error. Do you get an error with 3.2.12.0?

In this case, by "error" I was referring to "no triggered notification via MsgBox"

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
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
 Share

  • Recently Browsing   0 members

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