Jump to content

GUICtrlCreateCombo


Recommended Posts

Can someone explain how to set variables with a Combo box? For example I have

$Combo2 = GUICtrlCreateCombo("", 12, 48, 117, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "640×480|800×600|1024×768|1152×864|1280×768|1280×960|1280×1024|1600×1200")

And I want it to set two variables when the user choses a resolution, so if they chose 1024×768, it would set $x to 1024, and $y to 768. Anyone got any ideas? Thanks :idea:

Link to comment
Share on other sites

Here is an example

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 249, 115, 211, 125)
$Combo_Screensize = GUICtrlCreateCombo("", 16, 24, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "640×480|800×600|1024×768|1152×864|1280×768|1280×960|1280×1024|1600×1200")
$hLabelX = GUICtrlCreateLabel("X = ", 16, 56, 150, 17)
$hLabelY = GUICtrlCreateLabel("Y = ", 16, 80, 150, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo_Screensize
            $sReadCombo = GUICtrlRead($Combo_Screensize)
            $aSplit = StringSplit($sReadCombo,"×")
            $iX = $aSplit[1]
            $iY = $aSplit[2]
            GUICtrlSetData($hLabelX, "X = " & $iX)
            GUICtrlSetData($hLabelY, "Y = " & $iY)
    EndSwitch
WEnd
GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

Here is an example

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 249, 115, 211, 125)
$Combo_Screensize = GUICtrlCreateCombo("", 16, 24, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "640×480|800×600|1024×768|1152×864|1280×768|1280×960|1280×1024|1600×1200")
$hLabelX = GUICtrlCreateLabel("X = ", 16, 56, 150, 17)
$hLabelY = GUICtrlCreateLabel("Y = ", 16, 80, 150, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo_Screensize
            $sReadCombo = GUICtrlRead($Combo_Screensize)
            $aSplit = StringSplit($sReadCombo,"×")
            $iX = $aSplit[1]
            $iY = $aSplit[2]
            GUICtrlSetData($hLabelX, "X = " & $iX)
            GUICtrlSetData($hLabelY, "Y = " & $iY)
    EndSwitch
WEnd

Thank you :idea:
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...