Sign in to follow this  
Followers 0
newguy2015

Need help with combobox

3 posts in this topic

I need input boxes to change and reflect values of a combobox selection. this is what I have so far.

If you build the project you will see a drop down menu with 2 items. Driver and Wood. When selecting driver or wood the input values will be different as they are different clubs. I need the input boxes to generate the # upon selecting one of the items.

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>

Opt("GUIResizeMode", $GUI_DOCKAUTO)
Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKWIDTH)
Opt("GUIResizeMode", $GUI_DOCKRIGHT+$GUI_DOCKTOP)

$hGUI = GUICreate("Assistant", 279, 476, -1, -1, -1, BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE));program title + create gui
GUISetFont(8, 400, 0, "Arial");set title font
$Tab1 = GUICtrlCreateTab(0, 0, 281, 475);create tabs

$TabSheet1 = GUICtrlCreateTabItem("Auto Swing") ; TAB 1 SELECTION
$Label1 = GUICtrlCreateLabel("Select Club", 10, 35, 160, 20) ;Combobox Label
$Combo1 = GUICtrlCreateCombo("", 10, 50, 169, 25,  $CBS_DROPDOWN);Combobox
GUICtrlSetData(-1, "Driver|Wood") ;Combox Inputs
_GUICtrlComboBox_SetCurSel($Combo1, 0) ;select driver at start

global $driver100var, $driver100var2, $wood100var, $wood100var2 ;global vars

$driver100power = IniRead("Swing.ini", "Driver", "100% Power", "")
$driver100delay = IniRead("Swing.ini", "Driver", "100% Delay", "")
$wood100power = IniRead("Swing.ini", "Wood", "100% Power", "")
$wood100delay = IniRead("Swing.ini", "Wood", "100% Delay", "")

Local $button100    = GUICtrlCreateButton("100", 10, 80, 35, 20) ;static button
Global Const $100driverpowerinput = GUICtrlCreateInput($driver100power, 55, 81, 35, 18)
Global Const $100driverdelayinput = GUICtrlCreateInput($driver100delay, 100, 81, 35, 18)



$TabSheet2 = GUICtrlCreateTabItem("Calculator"); TAB 2 SELECTION
$TabSheet3 = GUICtrlCreateTabItem("Settings"); TAB 2 SELECTION

GUISetState(@SW_SHOW, $hGUI) ;SET GUI PROPERTIES

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $Combo1
         If GUICtrlRead($Combo1) = "Driver" Then
            GUICtrlRead($driver100var)

         EndIf

      Case $Combo1
         If GUICtrlRead($Combo1) = "Wood" Then

         EndIf

   EndSwitch
WEnd

Share this post


Link to post
Share on other sites



Not sure of what you're trying to achieve, but maybe this?

 

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>

Opt("GUIResizeMode", $GUI_DOCKAUTO)
Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKWIDTH)
Opt("GUIResizeMode", $GUI_DOCKRIGHT+$GUI_DOCKTOP)

$hGUI = GUICreate("Assistant", 279, 476, -1, -1, -1, BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE));program title + create gui
GUISetFont(8, 400, 0, "Arial");set title font
$Tab1 = GUICtrlCreateTab(0, 0, 281, 475);create tabs

$TabSheet1 = GUICtrlCreateTabItem("Auto Swing") ; TAB 1 SELECTION
$Label1 = GUICtrlCreateLabel("Select Club", 10, 35, 160, 20) ;Combobox Label
$Combo1 = GUICtrlCreateCombo("", 10, 50, 169, 25,  $CBS_DROPDOWN);Combobox
GUICtrlSetData(-1, "Driver|Wood") ;Combox Inputs
_GUICtrlComboBox_SetCurSel($Combo1, 0) ;select driver at start

global $driver100var, $driver100var2, $wood100var, $wood100var2 ;global vars

$driver100power = IniRead("Swing.ini", "Driver", "100% Power", "")
$driver100delay = IniRead("Swing.ini", "Driver", "100% Delay", "")
$wood100power = IniRead("Swing.ini", "Wood", "100% Power", "")
$wood100delay = IniRead("Swing.ini", "Wood", "100% Delay", "")

Local $button100    = GUICtrlCreateButton("100", 10, 80, 35, 20) ;static button
Global Const $100driverpowerinput = GUICtrlCreateInput($driver100power, 55, 81, 35, 18)
Global Const $100driverdelayinput = GUICtrlCreateInput($driver100delay, 100, 81, 35, 18)



$TabSheet2 = GUICtrlCreateTabItem("Calculator"); TAB 2 SELECTION
$TabSheet3 = GUICtrlCreateTabItem("Settings"); TAB 2 SELECTION

GUISetState(@SW_SHOW, $hGUI) ;SET GUI PROPERTIES

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $Combo1
         If GUICtrlRead($Combo1) = "Driver" Then
            GUICtrlSetData($100driverpowerinput,1)
            GUICtrlSetData($100driverdelayinput,1)
        Else
            GUICtrlSetData($100driverpowerinput,2)
            GUICtrlSetData($100driverdelayinput,2)
         EndIf



   EndSwitch
WEnd

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

newguy2015,

I took out the $WS_EX_TRANSPARENCY extended style.

This populates the input controls with whatever is read from the INI file based on the combo control selection...

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>

Opt("GUIResizeMode", $GUI_DOCKAUTO)
Opt("GUIResizeMode", $GUI_DOCKAUTO + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKHCENTER + $GUI_DOCKWIDTH)
Opt("GUIResizeMode", $GUI_DOCKRIGHT + $GUI_DOCKTOP)

$hGUI = GUICreate("Assistant", 279, 476, -1, -1, -1, BitOR($WS_EX_OVERLAPPEDWINDOW, $WS_EX_WINDOWEDGE));program title + create gui
GUISetFont(8, 400, 0, "Arial");set title font
$Tab1 = GUICtrlCreateTab(0, 0, 281, 475);create tabs

$TabSheet1 = GUICtrlCreateTabItem("Auto Swing") ; TAB 1 SELECTION
$Label1 = GUICtrlCreateLabel("Select Club", 10, 35, 160, 20) ;Combobox Label
$Combo1 = GUICtrlCreateCombo("", 10, 50, 169, 25, $CBS_DROPDOWN);Combobox
GUICtrlSetData(-1, "Driver|Wood") ;Combox Inputs
_GUICtrlComboBox_SetCurSel($Combo1, 0) ;select driver at start

Global $driver100var, $driver100var2, $wood100var, $wood100var2 ;global vars

$driver100power = IniRead("Swing.ini", "Driver", "100% Power", "")
$driver100delay = IniRead("Swing.ini", "Driver", "100% Delay", "")
$wood100power = IniRead("Swing.ini", "Wood", "100% Power", "")
$wood100delay = IniRead("Swing.ini", "Wood", "100% Delay", "")

Local $button100 = GUICtrlCreateButton("100", 10, 80, 35, 20) ;static button
Global Const $100driverpowerinput = GUICtrlCreateInput($driver100power, 55, 81, 35, 18)
Global Const $100driverdelayinput = GUICtrlCreateInput($driver100delay, 100, 81, 35, 18)

$TabSheet2 = GUICtrlCreateTabItem("Calculator"); TAB 2 SELECTION
$TabSheet3 = GUICtrlCreateTabItem("Settings"); TAB 2 SELECTION

guictrlcreatetabitem('')                    ; <<<<----- Don't forget to close the tab structure definition.

GUISetState(@SW_SHOW, $hGUI) ;SET GUI PROPERTIES

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case 'Driver'
                    GUICtrlSetData($100driverpowerinput, $driver100power)
                    GUICtrlSetData($100driverdelayinput, $driver100delay)
                Case 'Wood'
                    ;
                    ; do wood stuff
                    ;
            EndSwitch

    EndSwitch
WEnd

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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