SerLanceloth

Need help with casing a combo box

3 posts in this topic

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

$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("Input1", 24, 48, 34, 17)
$Input1 = GUICtrlCreateInput("Input1", 64, 48, 121, 21)
$Edit1 = GUICtrlCreateEdit("", 16, 96, 577, 89)
$Combo1 = GUICtrlCreateCombo("Select Option", 16, 208, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "Option1|Option2|Option3")
$Edit2 = GUICtrlCreateEdit("", 16, 240, 585, 97)
$Button1 = GUICtrlCreateButton("Button1", 16, 368, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 104, 368, 75, 25)
GUISetState(@SW_SHOW)


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

        Case $Button1
           GUICtrlSetData($Edit1,"this part is working fine")
        EndSwitch
      Switch GUICtrlRead($Combo1)
      Case "Option1"
         GUICtrlSetData($Edit2,"Option1, i need this part to be editable instead of keep refreshing it self")
      Case "Option2"
         GUICtrlSetData($Edit2,"Option2,i need this part to be editable instead of keep refreshing it self")
      Case "Option3"
         GUICtrlSetData($Edit2,"Option3,i need this part to be editable instead of keep refreshing it self")
      EndSwitch
WEnd

hello all, today i need some help casing this combo box function, thing is that im able to auto refresh the combo box, when i select the option im looking for, but i need the edit where the data is set to be editable instead of refreshing every time it goes trough the loop, can someone please assist with this

 

Thank you in advance 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello, SerLanceloth.

You are switching the GUICtrlRead($Combo1), you should not do that because it would just use the switch and case everytime the application loops.

Instead, switch the object $Combo1 and use the Switch and Case method inside it. This way, it will execute only when the value on the ComboBox is clicked.

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

$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("Input1", 24, 48, 34, 17)
$Input1 = GUICtrlCreateInput("Input1", 64, 48, 121, 21)
$Edit1 = GUICtrlCreateEdit("", 16, 96, 577, 89)
$Combo1 = GUICtrlCreateCombo("Select Option", 16, 208, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "Option1|Option2|Option3")
$Edit2 = GUICtrlCreateEdit("", 16, 240, 585, 97)
$Button1 = GUICtrlCreateButton("Button1", 16, 368, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 104, 368, 75, 25)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
           GUICtrlSetData($Edit1,"this part is working fine")
        Case $Combo1
            Switch GUICtrlRead($Combo1)
              Case "Option1"
                 GUICtrlSetData($Edit2,"Option1, i need this part to be editable instead of keep refreshing it self")
              Case "Option2"
                 GUICtrlSetData($Edit2,"Option2,i need this part to be editable instead of keep refreshing it self")
              Case "Option3"
                 GUICtrlSetData($Edit2,"Option3,i need this part to be editable instead of keep refreshing it self")
            EndSwitch
      EndSwitch
WEnd

This is working fine, for example.

Edited by Annatsu
Grammar

Share this post


Link to post
Share on other sites

awesome thank your very much, little rookie mistakes :D

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