Jump to content
Sign in to follow this  

Edit Read-Only

Recommended Posts


How can I make an edit read-only?

Share this post

Link to post
Share on other sites

use this style


check example

GUICreate ("TEST", 220, 120)
GUICtrlCreateEdit ("This is a test text line 1" & @CRLF & "This is line 2" , 10 , 10 , 200 , 100 , $ES_READONLY)
GUICtrlSetFont (-1,10, 600)
GUISetState ()
While 1
    $MSG = GUIGetMsg ()
Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Share this post

Link to post
Share on other sites

Why newbies not just look at help to find styles?

I can do signature me.

Share this post

Link to post
Share on other sites

If you want to turn it on and off, and have the backcolor different other than grayed:

#include <GuiConstants.au3>

Global Const $WM_COMMAND = 0x0111
Global Const $EN_CHANGE = 0x300
Global Const $EN_SETFOCUS = 0x100
Global Const $EN_KILLFOCUS = 0x200
Global Const $DebugIt = 1
Global $changed = 0

GUICreate("My GUI combo")  ; will create a dialog box that when displayed is centered

$edit = GUICtrlCreateEdit("This is a test, this is only a test", 80, 50, 270, 170) ; create first item
$btn_exit = GUICtrlCreateButton("Exit", 40, 230, 60, 20)
$btn_readonly = GUICtrlCreateButton("Read-Only", 120, 230, 60, 20)
GUICtrlSetBkColor($edit, 0xFFFFFF)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $btn_exit
        Case $btn_readonly
            If GUICtrlRead($btn_readonly) == "Read-Only" Then
                GUICtrlSetData($btn_readonly, "Edit")
                GUICtrlSendMsg($edit, $EM_SETREADONLY, True, 0)
                GUICtrlSetData($btn_readonly, "Read-Only")
                GUICtrlSendMsg($edit, $EM_SETREADONLY, False, 0)

Func _Edit_Changed()
    If $DebugIt Then _DebugPrint("Edit Changed:" & GUICtrlRead($edit))
    If $DebugIt Then _DebugPrint(StringLen(GUICtrlRead($edit)))
EndFunc   ;==>_Edit_Changed

Func _Edit_GotFocus()
    If $DebugIt Then _DebugPrint("Edit Got Focus")
EndFunc   ;==>_Edit_GotFocus

Func _Edit_LostFocus()
    If $DebugIt Then _DebugPrint("Edit Lost Focus")
EndFunc   ;==>_Edit_LostFocus

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    Switch $nID
        Case $edit
            Switch $nNotifyCode
                Case $EN_CHANGE
                Case $EN_SETFOCUS
                Case $EN_KILLFOCUS
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
EndFunc   ;==>MY_WM_COMMAND

Func _DebugPrint($s_Text, $line = @ScriptLineNumber, $file = @ScriptName)  
    ConsoleWrite( _
   "!===========================================================" & @LF & _
   "+======================================================" & @LF & _
   "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_Text & @LF & _
   "+======================================================" & @LF)
EndFunc   ;==>_DebugPrint

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

SciTE for AutoItDirections for Submitting Standard UDFs


Don't argue with an idiot; people watching may not be able to tell the difference.


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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.