设置或删除只读样式 ($ES_READONLY)
#include <GuiEdit.au3>
_GUICtrlEdit_SetReadOnly($hWnd, $fReadOnly)
$hWnd | 控件的控件ID/句柄 |
$fReadOnly | 下方的值: True - 设置 $ES_READONLY 样式 False - 删除 $ES_READONLY 样式 |
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
$Debug_Ed = False ; 检查传递给 Edit 函数的类名, 设置为真并使用另一控件的句柄可以看出它是否有效
_Main()
Func _Main()
Local $hStatusBar, $hEdit, $hGUI
Local $sWow64 = ""
If @AutoItX64 Then $sWow64 = "\Wow6432Node"
Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
Local $aPartRightSide[4] = [120, 248, 378, -1]
; 创建 GUI
$hGUI = GUICreate("Edit Set Read Only", 400, 300)
$hEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
$hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
_GUICtrlStatusBar_SetIcon($hStatusBar, 3, 97, "shell32.dll")
GUISetState()
; 设置边距
_GUICtrlEdit_SetMargins($hEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)
; 添加文本
_GUICtrlEdit_SetText($hEdit, FileRead($sFile))
_GUICtrlEdit_LineScroll($hEdit, 0, _GUICtrlEdit_GetLineCount($hEdit) * - 1)
; 获取修改标志
_GUICtrlStatusBar_SetText($hStatusBar, "Modified: " & _GUICtrlEdit_GetModify($hEdit), 2)
; 设置为只读
_GUICtrlEdit_SetReadOnly($hEdit, True)
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main