创建编辑(Edit)控件.
GUICtrlCreateEdit ( "文本", 左距, 顶距 [, 宽度 [, 高度
[, 样式 [, 扩展样式]]]] )
文本 | 控件显示的文本. |
左距 | 控件左侧的位置. 若此值为 -1, 则根据 GUICoordMode 的设置计算左侧位置. |
顶距 | 控件上方的位置. 若此值为 -1, 则根据 GUICoordMode 的设置计算顶部位置. |
宽度 | [可选参数] 控件的宽度(默认使用先前的宽度). |
高度 | [可选参数] 控件的高度(默认使用先前的高度). |
样式 | [可选参数] 控件的样式. 查看附录 GUI
控件样式表. 默认样式 ( -1) : $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL 强制样式 : $ES_MULTILINE, $WS_TABSTOP, 仅当没有 $ES_READONLY 时 |
扩展样式 | [可选参数] 控件的扩展样式. 查看附录 扩展样式表. |
成功: | 返回控件标识符(控件ID). |
失败: | 返回 0. |
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
Global $oMyError
Example()
RichEditExample()
Func Example()
Local
$myedit,
$msg
GUICreate("我的编辑 GUI") ;
创建居中显示的 GUI 窗口
$myedit = GUICtrlCreateEdit("首行文本" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUISetState()
Send("{END}")
;
追加数据别忘了添加第三个参数
GUICtrlSetData($myedit, "第二行文本", 1)
; 运行 GUI, 直到
GUI 被关闭
While
1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
EndFunc ;==>Example
; 使用 GUICtrlCreateObj 创建 Richedit 编辑控件
; 脚本作者: K re Johansson
; AutoIt 版本: 3.1.1.55
; 描述: 很简单的例子, 嵌入 RichText 对象
; 必须: MSCOMCT2.OCX, 或许在 system32 内已经有了
; 日期: 2005-07-03
Func RichEditExample()
Local
$oRP, $TagsPageC, $AboutC, $PrefsC, $StatC, $GUIActiveX, $msg
$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$oRP
= ObjCreate("RICHTEXT.RichtextCtrl.1")
GUICreate("嵌入
RICHTEXT 控件测试", 320, 200, -1,
-1, BitOR($WS_OVERLAPPEDWINDOW,
$WS_CLIPSIBLINGS,
$WS_CLIPCHILDREN))
$TagsPageC = GUICtrlCreateLabel('访问标签页', 5, 180, 100, 15, $SS_CENTER)
GUICtrlSetFont($TagsPageC, 9, 400, 4)
GUICtrlSetColor($TagsPageC, 0x0000ff)
GUICtrlSetCursor($TagsPageC, 0)
$AboutC = GUICtrlCreateButton('关于...', 105,
177, 70, 20)
$PrefsC = GUICtrlCreateButton('字体大小', 175,
177, 70, 20)
$StatC = GUICtrlCreateButton('简单样式', 245,
177, 70, 20)
$GUIActiveX = GUICtrlCreateObj($oRP, 10, 10, 400, 260)
GUICtrlSetPos($GUIActiveX, 10, 10, 300, 160)
With
$oRP; 对象标志组
.OLEDrag()
.Font = 'Arial'
.text = "您好- Au3 支持类似 Richtext 的 ActiveX 组件.
感谢 SvenP" & @CRLF & '尝试写一些文字, 并退出后重新加载'
;.FileName = @ScriptDir & '\RichText.rtf' ;译注:
去掉此句前的注释,则文件产生在脚本目录
;.BackColor = 0xff00 ;译注: 去掉此句前的注释, 则更改背景色
EndWith
GUISetState();显示 GUI
While
1
$msg = GUIGetMsg()
Select
Case $msg
= $GUI_EVENT_CLOSE
$oRP.SaveFile(@ScriptDir & "\RichText.rtf", 0)
ExitLoop
Case $msg
= $TagsPageC
Run(@ComSpec & ' /c start
http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={3B7C8860-D78F-101B-B9B5-04021C009402}',
'', @SW_HIDE)
Case $msg
= $AboutC
$oRP.AboutBox()
Case $msg
= $PrefsC
$oRP.SelFontSize = 12
Case $msg
= $StatC
$oRP.SelBold = False
$oRP.SelItalic = False
$oRP.SelUnderline = False
$oRP.SelFontSize = 8
EndSelect
WEnd
GUIDelete()
EndFunc ;==>RichEditExample
Func MyErrFunc()
MsgBox(0, "AutoItCOM
测试", "截获的 COM 错误
!" & @CRLF & @CRLF & _
"错误描述: " &
@TAB &
$oMyError.description & @CRLF & _
"窗口错误描述:" &
@TAB &
$oMyError.windescription & @CRLF & _
"错误代码: " &
@TAB &
Hex($oMyError.number, 8) & @CRLF & _
"上次 dll 错误: " &
@TAB &
$oMyError.lastdllerror & @CRLF & _
"错误脚本行: " &
@TAB &
$oMyError.scriptline & @CRLF & _
"错误源: " &
@TAB &
$oMyError.source & @CRLF & _
"错误帮助文件: " &
@TAB &
$oMyError.helpfile & @CRLF & _
"错误帮助环境: " &
@TAB &
$oMyError.helpcontext _
, 5)
; 暂停 5
秒之后自动继续
Local
$err = $oMyError.number
If
$err = 0 Then $err = -1
SetError($err) ;
函数返回之后检查错误
EndFunc ;==>MyErrFunc
provider with jb51.net (unicode) |