Jump to content

use "GUICtrlSetStyle" to many Input


 Share

Go to solution Solved by Melba23,

Recommended Posts

  • Moderators

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

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

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
Link to comment
Share on other sites

  • Moderators
  • Solution

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...