Jump to content

Casing Buttons


Recommended Posts

hello everyone I need some urgent help I need to create a function that is based on buttons, that is setting data to Edits depending on the levels selected on the combobox, now I am able to use the buttons from the main guy where the function is only 1, but I need the same button to do different things depending of whats selected on the combobox thanks in advance for your help

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 229, 295, 192, 124)
$Combo1 = GUICtrlCreateCombo("Combo1", 8, 8, 169, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
   GUICtrlSetData($Combo1, "|Item 1|Item 2|Item 3")
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 40, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 0, 80, 193, 177)
GUICtrlSetData(-1, "Edit1")
GUISetState(@SW_SHOW)


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

 EndSwitch
WEnd

here is like an idea of flow of what im looking for
if GUICtrlRead($combo1) = "Item 1" Then $Button1 sets edit1 data to yes and $button2 sets edit1 data to no
   if GUICtrlRead($combo1) = "Item 2" Then $Button1 sets edit1 data to yes2 and $button2 sets edit1 data to no2
   if GUICtrlRead($combo1) = "Item 3" Then $Button1 sets edit1 data to yes3 and $button2 sets edit1 data to no3

Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

SerLanceloth,

Something like this should be what you want:

#include <GUIConstantsEx.au3>

Local $sButton1_Data = "", $sButton2_Data = ""

$Form1 = GUICreate("Form1", 229, 295, 192, 124)

$Combo1 = GUICtrlCreateCombo("", 8, 8, 169, 25) ; The required styles are the defaults
GUICtrlSetData($Combo1, "|Item 1|Item 2|Item 3")
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 40, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 0, 80, 193, 177)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Item 1"
                    $sButton1_Data = "yes1"
                    $sButton2_Data = "no1"
                Case "Item 2"
                    $sButton1_Data = "yes2"
                    $sButton2_Data = "no2"
                Case "Item 3"
                    $sButton1_Data = "yes3"
                    $sButton2_Data = "no3"
            EndSwitch

        Case $Button1
            GUICtrlSetData($Edit1, $sButton1_Data)
        Case $Button2
            GUICtrlSetData($Edit1, $sButton2_Data)
    EndSwitch

WEnd

And when you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

thanks melba you awesome, im trying to save and hit on next line, i manage for it to save it by adding the 1 after the coma at the end, but how can i make it write on next line?

#include <GUIConstantsEx.au3>

Local $sButton1_Data = "", $sButton2_Data = ""

$Form1 = GUICreate("Form1", 229, 295, 192, 124)

$Combo1 = GUICtrlCreateCombo("", 8, 8, 169, 25) ; The required styles are the defaults
GUICtrlSetData($Combo1, "|Item 1|Item 2|Item 3")
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 88, 40, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 0, 80, 193, 177)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Item 1"
                    $sButton1_Data = "yes1"
                    $sButton2_Data = "no1"
                Case "Item 2"
                    $sButton1_Data = "yes2"
                    $sButton2_Data = "no2"
                Case "Item 3"
                    $sButton1_Data = "yes3"
                    $sButton2_Data = "no3"
            EndSwitch



        Case $Button1
            GUICtrlSetData($Edit1, $sButton1_Data,1)
        Case $Button2
            GUICtrlSetData($Edit1, $sButton2_Data,1)
    EndSwitch

WEnd

 

Link to comment
Share on other sites

  • Moderators

SerLanceloth,

What do you think might make the edit control move down a line? What would you press if you were using a keyboard?

GUICtrlSetData($Edit1, $sButton1_Data & @CRLF, 1) ; Add an EOL

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...