Sign in to follow this  
Followers 0
covaks

Radio buttons and tab controls

11 posts in this topic

I'm having a problem with a prog I'm working on. I've re-created the problem below. When I hide radio button controls on a tab item, then show them with a combobox selection, they appear greyed out.. I have to click on another tab, and click back to have them not grayed out.

So, run the program. then click on the Combobox and choose Test2. At that point the 2 radio buttons below will be become visible, but they are grayed out. I have to click on the second tab, then click back so I can use them. Am I doing something wrong?

#include <GuiConstants.au3>

GuiCreate("Test")
GUICtrlCreateTab(1,1)
GUICtrlCreateTabItem("Tab1")

$Combo1 = GUICtrlCreateCombo("",5,30,50)
GUICtrlSetData($Combo1,"Test|Test2","Test")


$Radio1 = GUICtrlCreateRadio("Radio 1",20,80)
$Radio2 = GUICtrlCreateRadio("Radio 2",20,100)

GUICtrlSetState($Radio1, $GUI_HIDE)
GUICtrlSetState($Radio2, $GUI_HIDE)

GUICtrlCreateTabItem("Tab2")


GuiSetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Combo1 Then
        MyFunc()
    EndIf
    
Wend

Func MyFunc()
    GUICtrlSetState($Radio1, $GUI_SHOW)
    GUICtrlSetState($Radio2, $GUI_SHOW)
EndFunc

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>
GuiCreate("Test")
GUICtrlCreateTab(1,1)
GUICtrlCreateTabItem("Tab1")

$Combo1 = GUICtrlCreateCombo("",5,30,50)
GUICtrlSetData($Combo1,"Test|Test2","Test")


$Radio1 = GUICtrlCreateRadio("Radio 1",20,80)
$Radio2 = GUICtrlCreateRadio("Radio 2",20,100)


GUICtrlCreateTabItem("Tab2")


GuiSetState(@SW_SHOW)

GUICtrlSetState($Radio1, $GUI_HIDE)
GUICtrlSetState($Radio2, $GUI_HIDE)
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Combo1 Then
        MyFunc()
    EndIf
    
Wend

Func MyFunc()
    GUICtrlSetState($Radio1, $GUI_SHOW)
    GUICtrlSetState($Radio2, $GUI_SHOW)
EndFunc

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you for the response. When I run it now, it is not grayed out at first. however, if I switch to tab2 first, then back to 1, then bring up the combobox and select Test2 to show the radio buttons, they are grayed out again. And I again have to cycle the tabs to get it back.

Is there a logic to this that I'm not seeing?

I modified it a bit so it more accurately reflects what I'm trying to do in my main program.

#include <GuiConstants.au3>
GuiCreate("Test")
GUICtrlCreateTab(1,1)
GUICtrlCreateTabItem("Tab1")

$Combo1 = GUICtrlCreateCombo("",5,30,50)
GUICtrlSetData($Combo1,"Test|Test2","Test")


$Radio1 = GUICtrlCreateRadio("Radio 1",20,80)
$Radio2 = GUICtrlCreateRadio("Radio 2",20,100)


GUICtrlCreateTabItem("Tab2")


GuiSetState(@SW_SHOW)

GUICtrlSetState($Radio1, $GUI_HIDE)
GUICtrlSetState($Radio2, $GUI_HIDE)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Combo1 Then
        MyFunc()
    EndIf
    
Wend

Func MyFunc()
    If GUICtrlRead($Combo1) == "Test2" Then
        GUICtrlSetState($Radio1, $GUI_SHOW)
        GUICtrlSetState($Radio2, $GUI_SHOW)
    Else
        GUICtrlSetState($Radio1, $GUI_HIDE)
        GUICtrlSetState($Radio2, $GUI_HIDE)
    EndIf
EndFunc
Edited by covaks

Share this post


Link to post
Share on other sites

Hi,

Try this:

#include <GuiConstants.au3>
GuiCreate("Test")
GUICtrlCreateTab(1,1)
GUICtrlCreateTabItem("Tab1")

$Combo1 = GUICtrlCreateCombo("",5,30,50)
GUICtrlSetData($Combo1,"Test|Test2","Test")


$Radio1 = GUICtrlCreateRadio("Radio 1",20,80)
$Radio2 = GUICtrlCreateRadio("Radio 2",20,100)

GUICtrlSetState($Radio1, $GUI_HIDE)
GUICtrlSetState($Radio2, $GUI_HIDE)

GUICtrlCreateTabItem("Tab2")

GuiSetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Combo1 Then
        MyFunc()
    EndIf
    
Wend

Func MyFunc()
    If GUICtrlRead($Combo1) == "Test2" Then
        GUICtrlSetState($Radio1, $GUI_SHOW+$GUI_ENABLE)
        GUICtrlSetState($Radio2, $GUI_SHOW+$GUI_ENABLE)
    Else
        GUICtrlSetState($Radio1, $GUI_HIDE)
        GUICtrlSetState($Radio2, $GUI_HIDE)
    EndIf
EndFuncoÝ÷ Ø­¶¬ËÞ¯+-­©ày·¡jø¨º·è®g­ç(ÚèÈhºWg¢ÖÞv+nW§Û!£   Ú~׫èzÔ­j׺Ú"µÍÚ[ÛYH   ÑÝZPÛÛÝ[Ë]LÉÝÂÌÍÑÕRHHÕRPÜX]J ][ÝÕÝ    ][ÝÊBÕRPÝÜX]UXKJBÕRPÝÜX]UX][J   ][ÝÕXI][ÝÊBÌÍÔY[ÈHÕRPÝÜX]TY[Ê   ][ÝÔY[É][ÝË
BÕRPÝÙ]Ý]J  ÌÍÔY[Ë  ÌÍÑÕRWÒQJBÕRPÝÜX]UX][J  ][ÝÕX][ÝÊBÝZTÙ]Ý]J
BÕRPÝÙ]Ý]J  ÌÍÔY[Ë  ÌÍÑÕRWÔÒÕÊBÙÐÞ
    ][ÝÉ][ÝË    ][ÝÔY[È]ÛÈ[XYH ][ÝÈ  [ÈÛÛÛÛÛ[X[
    ÌÍÑÕRK  ][ÝÉ][ÝË    ÌÍÔY[Ë  ][ÝÒÑ[XY ][ÝÊJBÚ[HÕRQÙ]ÙÊ
H   ÉÝÈ  ÌÍÑÕRWÑUSÐÓÔÑBÙ[

But it happens only if we create a second tab.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

I can confirm, looks like a bug to me (WinXP Home SP2). Should maybe make an official report (don't just link to this thread, make sure to include some system details), in the meantime MsCreator's workaround should work.

Share this post


Link to post
Share on other sites

Thanks everyone. :-) I made a bug report as suggested.

And thank you MsCreatoR, that worked perfect. :-)

Share this post


Link to post
Share on other sites

Thanks everyone. :-) I made a bug report as suggested.

And thank you MsCreatoR, that worked perfect. :-)

Not sure it's a bug at all. It seems to me it's doing what you told it to. It showing/hiding the control. It's up to you to enable/disable it. I use several tabs with radio controls and I don't have the problem. What happens when you change

GUICtrlSetData($Combo1,"Test|Test2","Test")
to
GUICtrlSetData($Combo1,"Test|Test2")

I also never use the constants so that may have something to do with it. The values would be

GUICtrlSetState($Radio1, $GUI_HIDE) = GUICtrlSetState($Radio1, 160) ;; hidden and disabled

GUICtrlSetState($Radio1, $GUI_SHOW) = GUICtrlSetState($Radio1, 80) ;; Showing and enabled.

Also to avoid flicker is to use code like

If GUIGetState($Radio1) < 80 Then GUICtrlSetState($Radio1, 80)

In other words, check the state before you change it.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

@covaks

Tab definition closing

GUICtrlCreateTabitem ("")

is missing in your code.

Follow the manual and the problem is gone. Wonders of the world...


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

@covaks

Tab definition closing

GUICtrlCreateTabitem ("")

is missing in your code.

Follow the manual and the problem is gone. Wonders of the world...

Interesting. I have never yet closed my tabs. I do however place my radio controls within groups and close the groups.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

@covaks

Tab definition closing

GUICtrlCreateTabitem ("")

is missing in your code.

Follow the manual and the problem is gone. Wonders of the world...

Actually, it does not fix the problem.

*Edit: To clarify, follow these steps exactly:

1) Grab the script from post #3 and run it.

2) Select Tab2

3) Select Tab1

4) Change the combo box to Test2

> The two radio controls should appear - but they are disabled.

5) Select Tab2

6) Select Tab1

> The previously disabled radio controls should now be enabled.

To repeat the bug, select Test from the combobox then continue from step 2.

Edited by Saunders

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Not sure it's a bug at all. It seems to me it's doing what you told it to. It showing/hiding the control. It's up to you to enable/disable it.

If i "say" Show the control, control should be shown, not disabled as well.

The same with CheckBox don't "work":

#include <GuiConstants.au3>

$GUI = GUICreate("Test")

GUICtrlCreateTab(1, 1)

GUICtrlCreateTabItem("Tab 1")

$CheckBox = GUICtrlCreateCheckbox("CheckBox", 20, 80)
GUICtrlSetState($CheckBox, $GUI_HIDE)

GUICtrlCreateTabItem("Tab 2")

GuiSetState()

GUICtrlSetState($CheckBox, $GUI_SHOW)
MsgBox(64, "", "CheckBox is Enabled = " & ControlCommand($GUI, "", $CheckBox, "IsEnabled"))

While GUIGetMsg() <> $GUI_EVENT_CLOSE
Wend

So it must be something with mixing tabs and radio..

Edited by MsCreatoR

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

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  
Followers 0