創(chuàng)建編輯(Edit)控件.
GUICtrlCreateEdit ( "文本", 左距, 頂距 [, 寬度 [, 高度
[, 樣式 [, 擴(kuò)展樣式]]]] )
文本 | 控件顯示的文本. |
左距 | 控件左側(cè)的位置. 若此值為 -1, 則根據(jù) GUICoordMode 的設(shè)置計(jì)算左側(cè)位置. |
頂距 | 控件上方的位置. 若此值為 -1, 則根據(jù) GUICoordMode 的設(shè)置計(jì)算頂部位置. |
寬度 | [可選參數(shù)] 控件的寬度(默認(rèn)使用先前的寬度). |
高度 | [可選參數(shù)] 控件的高度(默認(rèn)使用先前的高度). |
樣式 | [可選參數(shù)] 控件的樣式. 查看附錄 GUI
控件樣式表. 默認(rèn)樣式 ( -1) : $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL 強(qiáng)制樣式 : $ES_MULTILINE, $WS_TABSTOP, 僅當(dāng)沒有 $ES_READONLY 時(shí) |
擴(kuò)展樣式 | [可選參數(shù)] 控件的擴(kuò)展樣式. 查看附錄 擴(kuò)展樣式表. |
成功: | 返回控件標(biāo)識(shí)符(控件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") ;
創(chuàng)建居中顯示的 GUI 窗口
$myedit = GUICtrlCreateEdit("首行文本" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUISetState()
Send("{END}")
;
追加數(shù)據(jù)別忘了添加第三個(gè)參數(shù)
GUICtrlSetData($myedit, "第二行文本", 1)
; 運(yùn)行 GUI, 直到
GUI 被關(guān)閉
While
1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
EndFunc ;==>Example
; 使用 GUICtrlCreateObj 創(chuàng)建 Richedit 編輯控件
; 腳本作者: K re Johansson
; AutoIt 版本: 3.1.1.55
; 描述: 很簡(jiǎn)單的例子, 嵌入 RichText 對(duì)象
; 必須: MSCOMCT2.OCX, 或許在 system32 內(nèi)已經(jīng)有了
; 日期: 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 控件測(cè)試", 320, 200, -1,
-1, BitOR($WS_OVERLAPPEDWINDOW,
$WS_CLIPSIBLINGS,
$WS_CLIPCHILDREN))
$TagsPageC = GUICtrlCreateLabel('訪問標(biāo)簽頁(yè)', 5, 180, 100, 15, $SS_CENTER)
GUICtrlSetFont($TagsPageC, 9, 400, 4)
GUICtrlSetColor($TagsPageC, 0x0000ff)
GUICtrlSetCursor($TagsPageC, 0)
$AboutC = GUICtrlCreateButton('關(guān)于...', 105,
177, 70, 20)
$PrefsC = GUICtrlCreateButton('字體大小', 175,
177, 70, 20)
$StatC = GUICtrlCreateButton('簡(jiǎn)單樣式', 245,
177, 70, 20)
$GUIActiveX = GUICtrlCreateObj($oRP, 10, 10, 400, 260)
GUICtrlSetPos($GUIActiveX, 10, 10, 300, 160)
With
$oRP; 對(duì)象標(biāo)志組
.OLEDrag()
.Font = 'Arial'
.text = "您好- Au3 支持類似 Richtext 的 ActiveX 組件.
感謝 SvenP" & @CRLF & '嘗試寫一些文字, 并退出后重新加載'
;.FileName = @ScriptDir & '\RichText.rtf' ;譯注:
去掉此句前的注釋,則文件產(chǎn)生在腳本目錄
;.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
測(cè)試", "截獲的 COM 錯(cuò)誤
!" & @CRLF & @CRLF & _
"錯(cuò)誤描述: " &
@TAB &
$oMyError.description & @CRLF & _
"窗口錯(cuò)誤描述:" &
@TAB &
$oMyError.windescription & @CRLF & _
"錯(cuò)誤代碼: " &
@TAB &
Hex($oMyError.number, 8) & @CRLF & _
"上次 dll 錯(cuò)誤: " &
@TAB &
$oMyError.lastdllerror & @CRLF & _
"錯(cuò)誤腳本行: " &
@TAB &
$oMyError.scriptline & @CRLF & _
"錯(cuò)誤源: " &
@TAB &
$oMyError.source & @CRLF & _
"錯(cuò)誤幫助文件: " &
@TAB &
$oMyError.helpfile & @CRLF & _
"錯(cuò)誤幫助環(huán)境: " &
@TAB &
$oMyError.helpcontext _
, 5)
; 暫停 5
秒之后自動(dòng)繼續(xù)
Local
$err = $oMyError.number
If
$err = 0 Then $err = -1
SetError($err) ;
函數(shù)返回之后檢查錯(cuò)誤
EndFunc ;==>MyErrFunc
provider with jb51.net (unicode) |