Jump to content

combo and checkbox


Em4gdn1m
 Share

Recommended Posts

Hey everyone, I'm curious if there is a way to incorporate a checkbox with a combo GUICtrl?

so for instance I have a GUI that has a bunch of checkboxes that allow me to open certain programs as needed.  (this is just some parsing of my code, sorry, noob here and not sure what the preferred method of displaying code is, please enlighten me)


    $L0742 = GUICtrlCreateCheckbox("L07 4.2", 110, 320, 100)
    $L07502 = GUICtrlCreateCheckbox("L07 5.0.2", 110, 350, 100)
    $GenComm = GUICtrlCreateCheckbox("GenComm", 110, 380, 100)
    $Templates = GUICtrlCreateCheckbox("Templates", 110, 410, 100)
    $MCT = GUICtrlCreateCheckbox("MCT", 110, 440, 100)
    $Desktop_Shortcuts = GUICtrlCreateCheckbox("Desktop Shortcuts by Tester", 110, 470, 200)

 

...

Case $msg = $RunBtn
            RunPrograms()

 

...

Func RunPrograms()

    if GUICtrlRead($L0742) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel4.2\viva\viva.exe", "")
    if GUICtrlRead($L07502) = $GUI_CHECKED then Run("C:\Program Files\Varian\Paxscan\L07 Rel5\viva\viva.exe", "")
    if GUICtrlRead($GenComm) = $GUI_CHECKED then Run("\\Fpanelfs1\FPShared\Desktop_Shortcuts_by_Tester\Matt\CPI Generator\CPI Generator Windows 7 64 Bit\GenComm\GenComm.NET.exe", "")
    if GUICtrlRead($Templates) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\FPProjects\Documentation Controlled\Test_Templates")
    if GUICtrlRead($MCT) = $GUI_CHECKED then Run("\\Fpanelfs1\FPProjects\Documentation Controlled\Manufacturing Software\MCT\MCT.exe","")
    if GUICtrlRead($Desktop_Shortcuts) = $GUI_CHECKED then ShellExecute("\\Fpanelfs1\fpshared\Desktop_Shortcuts_by_Tester")
EndFunc

 

so i click some checkboxes, and hit a run button and the programs which are checked run, great.

BUT i want to add a bunch of options under one checkbox. A combo that will list a bunch of versions of a program that can be opened. something like this... but I want that program to be part of a checkbox

$ViVAComboBox = GUICtrlCreateCombo("L01 Rel 13", 110, 320, 100)

GUICtrlSetData($ViVAComboBox, "L04|L05|L07 Rel 4.2|L07 Rel 5.0.2|L09", "L07 Rel 4.2")

 

is this possible? is there another GUICtrl that does this better that i am not aware of?

 

 

Link to comment
Share on other sites

There isn't a control that combines a checkbox and a combobox, but you could put a checkbox next to one and disable the combo until that check box has been checked.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

so basically I added

While 1

GUICtrlRead($ViVACheckBox)

if GUICtrlRead($ViVACheckBox) = $GUI_CHECKED then GUICtrlSetState($ViVAComboBox, $GUI_ENABLE)

if GUICtrlRead($ViVACheckBox) = $GUI_UNCHECKED then GUICtrlSetState($ViVAComboBox, $GUI_DISABLE)

WEnd

and then

if GUICtrlRead($ViVAComboBox) == "L07 Rel 4.2" then Run("The L07 Rel 4.2 destination here", "")
if GUICtrlRead($ViVAComboBox) == "L01 Rel 13" then Run("The L01 Rel 13 destination here", "")
...

but it's not caring if the combobox is enabled or not. it still just runs the program

and also, the constant checking of the state of the checkbox is kinda weird... id image there is some way to only check the state if the state changes?

Link to comment
Share on other sites

This might help clean up the code a bit and make it easier to add additional items later on to the combo box.

While 1
    Switch GUICtrlRead($ViVACheckBox)
        Case $GUI_CHECKED
            GUICtrlSetState($ViVAComboBox, $GUI_ENABLE)
        Case Else
            GUICtrlSetState($ViVAComboBox, $GUI_DISABLE)
    EndSwitch
WEnd
Switch GUICtrlRead($ViVAComboBox)
    Case "L07 Rel 4.2"
        Run("The L07 Rel 4.2 destination here", "")
    Case "L01 Rel 13"
        Run("The L01 Rel 13 destination here", "")
    Case ...
EndSwitch

As to the combo being read regardless of whether it's enabled or not, that's normal. You have to code the script so that it checks whether it needs to read that combobox or not when you go to run your programs.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

While 1
    Switch GUICtrlRead($ViVACheckBox)
        Case $GUI_CHECKED
            GUICtrlSetState($ViVAComboBox, $GUI_ENABLE)
        Case Else
            GUICtrlSetState($ViVAComboBox, $GUI_DISABLE)
    EndSwitch
WEnd

This part seems to do nothing with the constant checking of the state, and likewise, nothing different than what I had, though definitely a lot prettier which I like. but there is this constant flashing of the combo box that began when i added my while statement, and didn't stop with yours.

11 minutes ago, BrewManNH said:

 

As to the combo being read regardless of whether it's enabled or not, that's normal. You have to code the script so that it checks whether it needs to read that combobox or not when you go to run your programs.

I tried  doing

if GUICtrlRead($ViVAComboBox) = $GUI_ENABLE & "L07 Rel 4.2" then Run("FILE", "")

;and 

if GUICtrlRead($ViVAComboBox) == $GUI_ENABLE & "L07 Rel 4.2" then Run("file", "")

but neither seemed to work. not sure what to try. I want it to only run if the ViVACheckbox is checked... so

if GUICtrlRead($ViVACheckBox)= $GUI_CHECKED then ;IDK NOW

 

Link to comment
Share on other sites

 

neither

If GUICtrlRead($ViVACheckBox) = $GUI_ENABLE then
    Switch GUICtrlRead($ViVAComboBox)
        Case "L01 Rel 13"
            Run("C:\Program Files\Speccy\Speccy64.exe", "")
        Case "L04"
            Run("The L01 Rel 13 destination here", "")
        Case "L05"
            Run("The L01 Rel 13 destination here", "")
        Case "L07 Rel 4.2"
            Run("The L01 Rel 13 destination here", "")
        Case "L07 Rel 5.0.2"
            Run("The L01 Rel 13 destination here", "")
        Case "L09"
            Run("The L01 Rel 13 destination here", "")
    EndSwitch
EndIf

nor

If GUICtrlRead($ViVAComboBox) = $GUI_ENABLE then
...

works at opening a program at all

Link to comment
Share on other sites

actually...

If GUICtrlRead($ViVACheckBox) = $GUI_CHECKED then
        Switch GUICtrlRead($ViVAComboBox)
            Case "L01 Rel 13"
                Run("C:\Program Files\Speccy\Speccy64.exe", "")
            Case "L04"
                Run("The L01 Rel 13 destination here", "")
            Case "L05"
                Run("The L01 Rel 13 destination here", "")
            Case "L07 Rel 4.2"
                Run("The L01 Rel 13 destination here", "")
            Case "L07 Rel 5.0.2"
                Run("The L01 Rel 13 destination here", "")
            Case "L09"
                Run("The L01 Rel 13 destination here", "")
        EndSwitch
    EndIf

worked, now it's just the constant checking of the checkbox. any ideas on that?

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

×
×
  • Create New...