Jump to content
Sign in to follow this  
Delta01

Please help - Gui REcreation

Recommended Posts

Delta01

Ok, first, let me explain what my script is doing. Once it opens the top group has two radios which are for selecting one of two clients. When Client 1 is selected, the GUI for client one is created, when client 2 is created the gui is deleted then recreated with the settings for client 2. When the "Set" button is pressed it saves the information in the combobox and replaces it with a disabled text box (have to save it so when i delete the GUI the current selection isn't lost.)

In the more tab it's much the same to the first, but creating different parts of the Gui.

Now to my issue, in the "More" tab when I select Client 2 it doesn't open that gui and just does the client one. In the first tab after I save the info it errors out. For example, if two was in the combo box it would rename the group to "Two" and in the Client 2 radio, it would change the word "Set" (on the button) to "Two"

Below is my code and I understand there is probably much wrong with it, so PLEASE help me, I really need it.

NOTE: This is only the related code, not the full one.

#Include <GuiConstants.au3>
$Character1 = "2"
$Character2 = "1"
$C1Main = GuiCreate("My app", 240, 550)
GuiCtrlCreateTab(10, 7, 220, 530, -1)
$C1MainTab = GuiCtrlCreateTabItem("Main")
$C1Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C1Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
$C1Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($C1Chars, $Character2)
$C1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
GuiCtrlCreateTabItem("More")
$MoreC1Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC1Chars, $Character2)
$MoreC1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 190, 70)
$C1MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C1MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState()
GuiCtrlSetState($C1Client1, $GUI_CHECKED)
GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)

$C2Main = GuiCreate("My app C2", 240, 550)
GuiCtrlCreateTab(10, 7, 220, 530, -1)
$MainTab = GuiCtrlCreateTabItem("Main")
$C2Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C2Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
$C2Chars = GuiCtrlCreateCombo($Character2, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($C2Chars, $Character1)
GuiCtrlCreateTabItem("More")
$MoreC2Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC2Chars, $Character2)
$MoreC2Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 190, 70)
$C2MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C2MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState(@SW_HIDE, $C2Main)
$C2C1Flag = 1
$C1C2Flag = 1
$C1C1Flag = 1
$C2C2Flag = 1
$MoreC2C1 = 1
$MoreC1C2 = 1
$MoreC1C1 = 1
$MoreC2C2 = 1

While 1
    $msg = GuiGetMsg()
Select 
    Case $msg = $GUI_EVENT_CLOSE
    Exit
Case BitAnd(GUICtrlRead($C2Client2),$GUI_CHECKED) = 1
    If $C2C2Flag = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2Client2, $GUI_CHECKED)
    GuiCtrlSetState($C1Client2, $GUI_UNCHECKED)
    $C2C1Flag = 1
    $C2C2Flag = 2
    $C1C2Flag = 1
    $C1C1Flag = 1
EndIf
Case BitAnd(GUICtrlRead($C1Client1),$GUI_CHECKED) = 1
    If $C1C1Flag = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1Client1, $GUI_CHECKED)
    GuiCtrlSetState($C1Client2, $GUI_UNCHECKED)
    $C2C1Flag = 1
    $C2C2Flag = 1
    $C1C2Flag = 1
    $C1C1Flag = 2
EndIf
Case BitAnd(GUICtrlRead($C1Client2),$GUI_CHECKED) = 1
    If $C1C2Flag = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2Client2, $GUI_CHECKED)
    GuiCtrlSetState($C1Client2, $GUI_UNCHECKED)
    $C2C1Flag = 1
    $C1C2Flag = 2
    $C2C2Flag = 1
    $C1C1Flag = 1
EndIf
Case BitAnd(GUICtrlRead($C2Client1),$GUI_CHECKED) = 1
    If $C2C1Flag = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1Client1, $GUI_CHECKED)
    GuiCtrlSetState($C2Client1, $GUI_UNCHECKED)
    $C2C1Flag = 2
    $C1C2Flag = 1
    $C2C2Flag = 1
    $C1C1Flag = 1
EndIf
Case BitAnd(GUICtrlRead($C2MoreClient2),$GUI_CHECKED) = 1
    If $MoreC2C2 = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2MoreClient2, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient2, $GUI_UNCHECKED)
    $MoreC2C1 = 1
    $MoreC2C2 = 2
    $MoreC1C2 = 1
    $MoreC1C1 = 1
EndIf
Case BitAnd(GUICtrlRead($C1MoreClient1),$GUI_CHECKED) = 1
    If $MoreC1C1 = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient2, $GUI_UNCHECKED)
    $MoreC2C1 = 1
    $MoreC2C2 = 1
    $MoreC1C2 = 1
    $MoreC1C1 = 2
EndIf
Case BitAnd(GUICtrlRead($C1MoreClient2),$GUI_CHECKED) = 1
    If $MoreC1C2 = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2MoreClient2, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient2, $GUI_UNCHECKED)
    $MoreC2C1 = 1
    $MoreC1C2 = 2
    $MoreC2C2 = 1
    $MoreC1C1 = 1
EndIf
Case BitAnd(GUICtrlRead($C2MoreClient1),$GUI_CHECKED) = 1
    If $MoreC2C1 = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)
    GuiCtrlSetState($C2MoreClient1, $GUI_UNCHECKED)
    $MoreC2C1 = 2
    $MoreC1C2 = 1
    $MoreC2C2 = 1
    $MoreC1C1 = 1
EndIf
EndSelect
WEnd
Edited by Delta01

Share this post


Link to post
Share on other sites
martin

Ok, first, let me explain what my script is doing. Once it opens the top group has two radios which are for selecting one of two clients. When Client 1 is selected, the GUI for client one is created, when client 2 is created the gui is deleted then recreated with the settings for client 2. When the "Set" button is pressed it saves the information in the combobox and replaces it with a disabled text box (have to save it so when i delete the GUI the current selection isn't lost.)

In the more tab it's much the same to the first, but creating different parts of the Gui.

Now to my issue, in the "More" tab when I select Client 2 it doesn't open that gui and just does the client one. In the first tab after I save the info it errors out. For example, if two was in the combo box it would rename the group to "Two" and in the Client 2 radio, it would change the word "Set" (on the button) to "Two"

Below is my code and I understand there is probably much wrong with it, so PLEASE help me, I really need it.

NOTE: This is only the related code, not the full one.

#include <GuiConstants.au3> 
Global $C2Set, $MoreC2Set, $C2Chars, $MoreC2Chars
        $Character1 = "2"
        $Character2 = "1"
        
$main = GuiCreate("App's name", 240, 550)
GuiCtrlCreateTab(10, 7, 220, 530, -1)
$MainTab = GuiCtrlCreateTabItem("Main")
$Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
$C1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
$Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($Chars, $Character2)
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
$MoreTab = GuiCtrlCreateTabItem("More")
$MoreC1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 190, 70)
$MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
$MoreC1Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC1Chars, $Character2)
GuiSetState()

GuiCtrlSetState($Client1, $GUI_CHECKED)
GuiCtrlSetState($MoreClient1, $GUI_CHECKED)


$Flag1 = 2
$Flag2 = 1
$MoreFlag1 = 2
$MoreFlag2 = 1

$C1SetAs = $Character1
$C1SetAs2 = $Character2
$C2SetAs = $Character1
$C2SetAs2 = $Character2
$C1Lock = 2
$C2Lock = 2
$MoreC1SetAs = $Character1
$MoreC1SetAs2 = $Character2
$MoreC2SetAs = $Character1
$MoreC2SetAs2 = $Character2
$MoreC1Lock = 2
$MoreC2Lock = 2
    
While 1
    $msg = GuiGetMsg()
    If $msg = $C1Set Then
        $C1SetAs = GuiCtrlRead($Chars)
        $C1Lock = 1
    EndIf
    If $msg = $C2Set Then
        If WinExists("App's name 2") Then
        $C2SetAs = GuiCtrlRead($C2Chars)
        $C2Lock = 1
        EndIf
    EndIf
    If $msg = $MoreC1Set Then
        $MoreC1SetAs = GuiCtrlRead($MoreC1Chars)
        $MoreC1Lock = 1
    EndIf
    If $msg = $MoreC2Set Then
        If WinExists("App's name 2") Then
        $MoreC2SetAs = GuiCtrlRead($MoreC2Chars)
        $MoreC2Lock = 1
        EndIf
    EndIf
    
    If GuiCtrlRead($MoreClient1) = $GUI_CHECKED Then
        If $MoreFlag1 = 1 Then
            ;C2Save()
        If GuiCtrlRead($Client1) = $GUI_CHECKED Then $MainWhat = 1
        If GuiCtrlRead($Client2) = $GUI_CHECKED Then $MainWhat = 2
        GuiDelete($Main)
        If $MainWhat = 1 Then C1MainTab()
        If $MainWhat = 2 Then C2MainTab()
            C1MoreTab()
        ControlClick("App's name", "",  3, "left", 1, 67, 8)
        ControlClick("App's name", "",  3, "left", 1, 22, 7)    
        ControlClick("App's name", "",  3, "left", 1, 67, 8)
    ;   C1Save()
        If $MainWhat = 1 Then GuiCtrlSetState($Client1, $GUI_CHECKED)
        If $MainWhat = 2 Then GuiCtrlSetState($Client2, $GUI_CHECKED)
        $MoreFlag1 = 2
        $MoreFlag2 = 1
        EndIf
    EndIf
    
    If GuiCtrlRead($MoreClient2) = $GUI_CHECKED Then
        If $MoreFlag2 = 1 Then
        ;   C1Save()
        If GuiCtrlRead($Client1) = $GUI_CHECKED Then $MainWhat = 1
        If GuiCtrlRead($Client2) = $GUI_CHECKED Then $MainWhat = 2
        GuiDelete($Main)
        If $MainWhat = 1 Then C1MainTab()
        If $MainWhat = 2 Then C2MainTab()
            C2MoreTab()
        ControlClick("App's name", "",  3, "left", 1, 67, 8)
        ControlClick("App's name", "",  3, "left", 1, 22, 7)    
        ControlClick("App's name", "",  3, "left", 1, 67, 8)
    ;   C2Save() saves info
        If $MainWhat = 1 Then GuiCtrlSetState($Client1, $GUI_CHECKED)
        If $MainWhat = 2 Then GuiCtrlSetState($Client2, $GUI_CHECKED)
        $MoreFlag2 = 2
        $MoreFlag1 = 1
        EndIf
        EndIf
        
        
    If GuiCtrlRead($Client1) = $GUI_CHECKED Then
        If $Flag1 = 1 Then
            ;C2Save()
            If GuiCtrlRead($MoreClient1) = $GUI_CHECKED Then $MoreWhat = 1
            If GuiCtrlRead($MoreClient2) = $GUI_CHECKED Then $MoreWhat = 2
            GuiDelete($Main)
            C1MainTab()
            If $MoreWhat = 1 Then C1MoreTab()
            If $MoreWhat = 2 Then C2MoreTab()
            ControlClick("App's name", "",  3, "left", 1, 67, 8)
            ControlClick("App's name", "",  3, "left", 1, 22, 7)        
            ;C1Save()
            $Flag1 = 2
            $Flag2 = 1
            $Flag3 = 1
            GuiCtrlSetState($Client1, $GUI_CHECKED)
            GuiCtrlSetState($MoreClient1, $GUI_CHECKED)
        EndIf
    EndIf
    If GuiCtrlRead($Client2) = $GUI_CHECKED Then
        If $Flag2 = 1 Then
            ;C1Save()
            If GuiCtrlRead($MoreClient1) = $GUI_CHECKED Then $MoreWhat = 1
            If GuiCtrlRead($MoreClient2) = $GUI_CHECKED Then $MoreWhat = 2
            GuiDelete($Main)
            C2MainTab()
            If $MoreWhat = 1 Then C1MoreTab()
            If $MoreWhat = 2 Then C2MoreTab()
            If $MoreWhat = 2 Then C3MoreTab()
            ControlClick("App's name", "",  3, "left", 1, 67, 8)
            ControlClick("App's name", "",  3, "left", 1, 22, 7)    
           ; C2Save()           
            $Flag2 = 2
            $Flag1 = 1
            GuiCtrlSetState($Client2, $GUI_CHECKED)
            GuiCtrlSetState($MoreClient1, $GUI_CHECKED)
        EndIf
    EndIf   
                    
If $msg = $GUI_EVENT_CLOSE then
    Exit
        Endif


Wend


Func C1MainTab()
$main = GuiCreate("App's name", 240, 550)
GuiCtrlCreateTab(10, 7, 220, 530, -1)
$MainTab = GuiCtrlCreateTabItem("Main")
$Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
If $C1Lock = 1 Then
    $CharLocked = GuiCtrlCreateInPut($C1SetAs, 20, 70, 150, 20)
    GuiCtrlSetState($CharLocked, $GUI_DISABLE)
Else
$Chars = GuiCtrlCreateCombo($C1SetAs, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($Chars, $C1SetAs2)
$C1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
EndIf
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
EndFunc

Func C1MoreTab()
GuiCtrlCreateTabItem("More")
If $MoreC1Lock = 1 Then
    $MoreCharLocked = GuiCtrlCreateInPut($MoreC1SetAs, 20, 70, 150, 20)
    GuiCtrlSetState($MoreCharLocked, $GUI_DISABLE)
Else
$MoreC1Chars = GuiCtrlCreateCombo($C1SetAs, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($Chars, $MoreC1SetAs2)
$MoreC1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
EndIf
GuiCtrlCreateGroup("MultiClient", 15, 30, 190, 70)
$MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState()
EndFunc

Func C2MainTab()
$main = GuiCreate("App's name 2", 240, 550)
GuiCtrlCreateTab(10, 7, 220, 530, -1)
$MainTab = GuiCtrlCreateTabItem("Main")
$Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
If $C2Lock = 1 Then
    $CharLockedC2 = GuiCtrlCreateInPut($C2SetAs, 20, 70, 150, 20)
    GuiCtrlSetState($CharLockedC2, $GUI_DISABLE)
Else
$C2Chars = GuiCtrlCreateCombo($C2SetAs, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($C2Chars, $C2SetAs2)
$C2Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
EndIf
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
EndFunc

Func C2MoreTab()
GuiCtrlCreateTabItem("More")
If $MoreC2Lock = 1 Then
    $MoreCharLocked = GuiCtrlCreateInPut($MoreC1SetAs, 20, 70, 150, 20)
    GuiCtrlSetState($MoreCharLocked, $GUI_DISABLE)
Else
$MoreC2Chars = GuiCtrlCreateCombo($C1SetAs, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC2Chars, $MoreC1SetAs2)
$MoreC2Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
EndIf
$MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState()
EndFunc

The first thing you need to do is to sort out your variable names. For example, you have $main as global and it is initially the id of the first gui. Then you destroy all reference to that gui by assigning $main to another gui in Func C1MainGuiTab().

ll the variables used must be unique for all the guis and all controls you want to refer to, and if you want to refer to them outside of the functions where they are created then they must be global.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Delta01

Oh, thank you. I'll try it

Share this post


Link to post
Share on other sites
Delta01

I've tried doing all that. Still, it won't work.

Can anyone give me an example?

Share this post


Link to post
Share on other sites
Delta01

Anybody know?

Share this post


Link to post
Share on other sites
PsaltyDS

Anybody know?

Do we know how you tried to fix the Global variables that martin already pointed out -- No. Post the fix you did.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
stampy

Wow, that's some intense code. I think I finally understand it. Not sure what it is used for so it's hard to help too much.

-Do you need to delete the GUI's or could you just hide them? The code would work better just hiding them, or even using the same GUI with different controls.

-It doesn't work on two because your referencing a control on a GUI you deleted.

-A case statement would work better than all the if's in the main loop.

-It'd be better to check the state of the radio's by using $msg = $client1 etc rather than using the flags as you are trying.

-You should check the state of the radios with the bitand statement explained in the helpfile for guictrlread=== BitAnd(GUICtrlRead($Item),$GUI_CHECKED)

-I'm not sure why you need the combo/input or what you are doing with it. Wouldn't a variable suffice?

If you didn't create and delete the flicker would go away. If you need two gui's just create them both. Then show / hide as necessary. And set the radio's as you show the gui's.

Hope it helps.

Share this post


Link to post
Share on other sites
Delta01

Thanks stampy, I took your advice and have it working, well mostly. It all works apart from the More tab. Below is my code, perhaps you could take a look at it?

#Include <GuiConstants.au3>
$Character1 = "2"
$Character2 = "1"
$C1Main = GuiCreate("My app", 240, 550)
GuiCtrlCreateTab(10, 7, 220, 530, -1)
$C1MainTab = GuiCtrlCreateTabItem("Main")
$C1Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C1Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
$C1Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($C1Chars, $Character2)
$C1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
GuiCtrlCreateTabItem("More")
$MoreC1Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC1Chars, $Character2)
$MoreC1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 190, 70)
$C1MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C1MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState()
GuiCtrlSetState($C1Client1, $GUI_CHECKED)
GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)

$C2Main = GuiCreate("My app C2", 240, 550)
GuiCtrlCreateTab(10, 7, 220, 530, -1)
$MainTab = GuiCtrlCreateTabItem("Main")
$C2Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C2Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
$C2Chars = GuiCtrlCreateCombo($Character2, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($C2Chars, $Character1)
GuiCtrlCreateTabItem("More")
$MoreC2Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC2Chars, $Character2)
$MoreC2Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 190, 70)
$C2MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C2MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState(@SW_HIDE, $C2Main)
$C2C1Flag = 1
$C1C2Flag = 1
$C1C1Flag = 1
$C2C2Flag = 1
$MoreC2C1 = 1
$MoreC1C2 = 1
$MoreC1C1 = 1
$MoreC2C2 = 1

While 1
    $msg = GuiGetMsg()
Select 
    Case $msg = $GUI_EVENT_CLOSE
    Exit
Case BitAnd(GUICtrlRead($C2Client2),$GUI_CHECKED) = 1
    If $C2C2Flag = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2Client2, $GUI_CHECKED)
    GuiCtrlSetState($C1Client2, $GUI_UNCHECKED)
    $C2C1Flag = 1
    $C2C2Flag = 2
    $C1C2Flag = 1
    $C1C1Flag = 1
EndIf
Case BitAnd(GUICtrlRead($C1Client1),$GUI_CHECKED) = 1
    If $C1C1Flag = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1Client1, $GUI_CHECKED)
    GuiCtrlSetState($C1Client2, $GUI_UNCHECKED)
    $C2C1Flag = 1
    $C2C2Flag = 1
    $C1C2Flag = 1
    $C1C1Flag = 2
EndIf
Case BitAnd(GUICtrlRead($C1Client2),$GUI_CHECKED) = 1
    If $C1C2Flag = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2Client2, $GUI_CHECKED)
    GuiCtrlSetState($C1Client2, $GUI_UNCHECKED)
    $C2C1Flag = 1
    $C1C2Flag = 2
    $C2C2Flag = 1
    $C1C1Flag = 1
EndIf
Case BitAnd(GUICtrlRead($C2Client1),$GUI_CHECKED) = 1
    If $C2C1Flag = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1Client1, $GUI_CHECKED)
    GuiCtrlSetState($C2Client1, $GUI_UNCHECKED)
    $C2C1Flag = 2
    $C1C2Flag = 1
    $C2C2Flag = 1
    $C1C1Flag = 1
EndIf
Case BitAnd(GUICtrlRead($C2MoreClient2),$GUI_CHECKED) = 1
    If $MoreC2C2 = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2MoreClient2, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient2, $GUI_UNCHECKED)
    $MoreC2C1 = 1
    $MoreC2C2 = 2
    $MoreC1C2 = 1
    $MoreC1C1 = 1
EndIf
Case BitAnd(GUICtrlRead($C1MoreClient1),$GUI_CHECKED) = 1
    If $MoreC1C1 = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient2, $GUI_UNCHECKED)
    $MoreC2C1 = 1
    $MoreC2C2 = 1
    $MoreC1C2 = 1
    $MoreC1C1 = 2
EndIf
Case BitAnd(GUICtrlRead($C1MoreClient2),$GUI_CHECKED) = 1
    If $MoreC1C2 = 1 Then
    GuiSetState(@SW_HIDE, $C1Main)
    GuiSetState(@SW_SHOW, $C2Main)
    GuiCtrlSetState($C2MoreClient2, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient2, $GUI_UNCHECKED)
    $MoreC2C1 = 1
    $MoreC1C2 = 2
    $MoreC2C2 = 1
    $MoreC1C1 = 1
EndIf
Case BitAnd(GUICtrlRead($C2MoreClient1),$GUI_CHECKED) = 1
    If $MoreC2C1 = 1 Then
    GuiSetState(@SW_HIDE, $C2Main)
    GuiSetState(@SW_SHOW, $C1Main)
    GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)
    GuiCtrlSetState($C2MoreClient1, $GUI_UNCHECKED)
    $MoreC2C1 = 2
    $MoreC1C2 = 1
    $MoreC2C2 = 1
    $MoreC1C1 = 1
EndIf
EndSelect
WEnd
Edited by Delta01

Share this post


Link to post
Share on other sites
PsaltyDS

; ...

            If $MoreWhat = 1 Then C1MoreTab()
            If $MoreWhat = 2 Then C2MoreTab()
            If $MoreWhat = 2 Then C3MoreTab()

; ...
Is there supposed to be a C3MoreTab(), or is that a typo?

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Delta01

Is there supposed to be a C3MoreTab(), or is that a typo?

:D

Yeah, that's a typo. Originally there was going to be three but i decided against it, guess I forgot to take it out of the code.

Share this post


Link to post
Share on other sites
stampy

I'm a little confused. The radios just switch between the two guis. Is that correct? They have the same action no matter what tab your on?

Share this post


Link to post
Share on other sites
Delta01

I'm a little confused. The radios just switch between the two guis. Is that correct? They have the same action no matter what tab your on?

Ok, if you're on the first gui and Client 1 is checked, nothing will happen because Client 1 on all GUIs makes the first gui active. If you select Client 2 on the first GUI, it will make the second GUI active. If you select Client 1 on the second GUI, it will make the first gui active. I've got that working in the main tab, but can't get it working in the more tab, which I'm requesting help for. Hope that clears it up.

Edited by Delta01

Share this post


Link to post
Share on other sites
stampy

I was just thinking, if you click client1 on app2-main tab, you'll see app1. If you click client1 on app2-more tab, you'll see app1. It's the same thing. Seems that they should not be "contained" in the tabs since they are doing they same thing. That would cut the work load and confusing in half. Other than that, we are just mirroring the radios on the two different tabs.

Share this post


Link to post
Share on other sites
stampy

Ok, I reworked it and came up with this. I'd prefer one gui that the controls got changed, but it's not my project. I'd also prefer the the radio's to be off the tabs and just on the main gui, but again, it's not mine. See if this is more what your looking for.

#Include <GuiConstants.au3>
#Include <GuiTab.au3>

$Character1 = "2"
$Character2 = "1"

;;;;;;;;;;;;;;;; create GUI 1 ;;;;;;;;;;;;;;;;;;;;
$C1Main = GuiCreate("My app", 240, 550)
$C1TabControl = GuiCtrlCreateTab(10, 7, 220, 530, -1)
GuiCtrlCreateTabItem("Main")
$C1Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C1Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
$C1Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($C1Chars, $Character2)
$C1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
GuiCtrlCreateTabItem("More")
$MoreC1Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC1Chars, $Character2)
$MoreC1Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
$C1MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C1MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState()
GuiCtrlSetState($C1Client1, $GUI_CHECKED)
GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)

;;;;;;;;;;;;;;;;;; create GUI 2 ;;;;;;;;;;;;;;;;;;;
$C2Main = GuiCreate("My app C2", 240, 550)
$C2TabControl = GuiCtrlCreateTab(10, 7, 220, 530, -1)
GuiCtrlCreateTabItem("Main")
$C2Client1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C2Client2 = GuiCtrlCreateRadio("Client2", 75, 45)
$C2Chars = GuiCtrlCreateCombo($Character2, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($C2Chars, $Character1)
$C2Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
GuiCtrlCreateTabItem("More")
$MoreC2Chars = GuiCtrlCreateCombo($Character1, 20, 70, 150, 20, $CBS_DROPDOWNLIST)
GuiCtrlSetData($MoreC2Chars, $Character2)
$MoreC2Set = GuiCtrlCreateButton("Set", 175, 69, 35, 23)
GuiCtrlCreateGroup("MultiClient", 15, 30, 200, 70)
$C2MoreClient1 = GuiCtrlCreateRadio("Client1", 20, 45)
$C2MoreClient2 = GuiCtrlCreateRadio("Client2", 75, 45)
GuiSetState(@SW_HIDE, $C2Main)


;;;;;;;;;;;; start main GUI loop ;;;;;;;;;;;;;;;;;;;;
While 1
    $msg = GuiGetMsg(1)
    Select
        Case $msg[0] = $GUI_EVENT_CLOSE
            Exit
        Case $msg[0] = $C1Client2 And $msg[1] = $C1Main And BitAnd(GUICtrlRead($C1Client2),$GUI_CHECKED)
            Client2Click()
        Case $msg[0] = $C2Client1 And $msg[1] = $C2Main And BitAnd(GUICtrlRead($C2Client1),$GUI_CHECKED)
            Client1Click()
        Case $msg[0] = $C1MoreClient2 And $msg[1] = $C1Main And BitAnd(GUICtrlRead($C1MoreClient2),$GUI_CHECKED)
            Client2Click()
        Case $msg[0] = $C2MoreClient1 And $msg[1] = $C2Main And BitAnd(GUICtrlRead($C2MoreClient1),$GUI_CHECKED)
            Client1Click()
        Case $msg[0] = $C1Set And $msg[1] = $C1Main
            ;code for set btn on client1 main tab
        Case $msg[0] = $MoreC1Set And $msg[1] = $C2Main
            ;code for set btn on client1 more tab
        Case $msg[0] = $C2Set And $msg[1] = $C1Main
            ;code for set btn on client2 main tab
        Case $msg[0] = $MoreC2Set And $msg[1] = $C2Main
            ;code for set btn on client2 more tab
    EndSelect
WEnd

Func Client2Click()
    $tab = _GUICtrlTabGetCurFocus($C1TabControl)    ;;; get what tab we are on
    ;;; set state of gui 1
    GuiCtrlSetState($C1Client1, $GUI_UNCHECKED)
    GuiCtrlSetState($C1Client2, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient1, $GUI_UNCHECKED)
    GuiCtrlSetState($C1MoreClient2, $GUI_CHECKED)   
    GuiSetState(@SW_HIDE, $C1Main)
    
    ;;; set state of gui 2
    GuiCtrlSetState($C2Client1, $GUI_UNCHECKED)
    GuiCtrlSetState($C2Client2, $GUI_CHECKED)
    GuiCtrlSetState($C2MoreClient1, $GUI_UNCHECKED)
    GuiCtrlSetState($C2MoreClient2, $GUI_CHECKED)
    _GUICtrlTabSetCurFocus($C2TabControl,$tab)  ;;;set the tab on the newly viewed gui
    GuiSetState(@SW_SHOW, $C2Main)
    
    
EndFunc
Func Client1Click()
    $tab = _GUICtrlTabGetCurFocus($C2TabControl)    ;;; get what tab we are on
    
    ;;; set state of gui 2
    GuiCtrlSetState($C2MoreClient2, $GUI_UNCHECKED)
    GuiCtrlSetState($C2Client1, $GUI_CHECKED)
    GuiCtrlSetState($C2Client2, $GUI_UNCHECKED)
    GuiCtrlSetState($C2MoreClient1, $GUI_CHECKED)
    GuiSetState(@SW_HIDE, $C2Main)
    
    ;;;set state of gui 1
    GuiCtrlSetState($C1MoreClient2, $GUI_UNCHECKED)
    GuiCtrlSetState($C1Client2, $GUI_UNCHECKED)
    GuiCtrlSetState($C1Client1, $GUI_CHECKED)
    GuiCtrlSetState($C1MoreClient1, $GUI_CHECKED)
    _GUICtrlTabSetCurFocus($C1TabControl,$tab)  ;;;set the tab on the newly viewed gui
    GuiSetState(@SW_SHOW, $C1Main)
    
EndFunc

Share this post


Link to post
Share on other sites
Delta01

Ok, I reworked it and came up with this. I'd prefer one gui that the controls got changed, but it's not my project. I'd also prefer the the radio's to be off the tabs and just on the main gui, but again, it's not mine. See if this is more what your looking for.

Thanks a lot! Works great +)

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  

×