dzlee

use "GUICtrlSetStyle" to many Input

5 posts in this topic

hi autoit developers
i would like to ask ..
if there is any way to use "GUICtrlSetStyle" function to set style "$ES_READONLY" for all inputs in my script

thanks

Share this post


Link to post
Share on other sites



dzlee,

You will have to set that style for each input as it is created. But you could shorten the process by using a wrapper function like this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cInput1 =_CreateInput("Input 1", 10, 10, 200, 20)                             ; Use the wrapper function to create the input
$cInput2 =_CreateInput("Input 2", 10, 50, 200, 20)
$cInput3 =_CreateInput("Input 3", 10, 90, 200, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _CreateInput($sText, $iX, $iY, $iW, $iH)
    Local $cID = GUICtrlCreateInput($sText, $iX, $iY, $iW, $iH)            ; Create input
    GUICtrlSetStyle($cID, BitOr($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))  ; Set required style
    Return $cID
EndFunc
How does that suit your requirements? :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Melba23
thanks for the fast reply
i have about 100 input in my script i would like to make all inputs read only when the user press a button
and restore them bake when the user press that button again

is there an easy way to do that ?

Edited by dzlee

Share this post


Link to post
Share on other sites

dzlee,

That is not what you asked the first time - please try and be specific when you ask questions so we do not waste our time writing code which will obviously not meet the requirement. ;)

I suggest you store the input ControlIDs in an array and then loop through it like this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

Global $aInput[3]

$hGUI = GUICreate("Test", 500, 500)

$aInput[0] =_CreateInput("Input 0", 10, 10, 200, 20)
$aInput[1] =_CreateInput("Input 1", 10, 50, 200, 20)
$aInput[2] =_CreateInput("Input 2", 10, 90, 200, 20)

$cToggle = GUICtrlCreateButton("Editable", 10, 200, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cToggle
            Switch GUICtrlRead($cToggle)
                Case "Editable"
                    For $i = 0 To 2
                        GUICtrlSetStyle($aInput[$i], BitOr($ES_LEFT, $ES_AUTOHSCROLL))
                    Next
                    GUICtrlSetData($cToggle, "Read Only")
                Case Else
                    For $i = 0 To 2
                        GUICtrlSetStyle($aInput[$i], BitOr($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
                    Next
                    GUICtrlSetData($cToggle, "Editable")
            EndSwitch

    EndSwitch
WEnd

Func _CreateInput($sText, $iX, $iY, $iW, $iH)
    Local $cID = GUICtrlCreateInput($sText, $iX, $iY, $iW, $iH)
    GUICtrlSetStyle($cID, BitOr($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
    Return $cID
EndFunc
Better? :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thanks , and sorry for unclear question
solved :thumbsup:

Edited by dzlee

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