GUICtrlSetPos
调整控件在窗口中的位置和(或)大小.
GUICtrlSetPos ( controlID, left [, top [, width [, height]]] )
参数
controlID
|
使用 GUICtrlCreate...() 创建控件类函数返回的控件标识符, 或设置为 -1 使用前面创建的控件.
|
left
|
控件的左侧位置.
|
top
|
[可选] 控件的上方位置.
|
width
|
[可选] 控件的宽度.
|
height
|
[可选] 控件的高度.
|
返回值
备注
如果使用 Default 关键字, 则不改变当前值.
相关
GUICtrlCreate...
函数示例
示例 1
#include <GUIConstantsEx.au3>
Example()
Func Example()
GUICreate("My GUI position") ; will create a dialog box that when displayed is centered
GUISetFont(16)
Local $idLabel = GUICtrlCreateLabel("my moving label", 10, 20)
GUISetState(@SW_SHOW)
Local $idMsg, $bToggle = False
While 1
$idMsg = GUIGetMsg()
If $idMsg = $GUI_EVENT_CLOSE Then Exit
$bToggle = Not $bToggle
If $bToggle Then
GUICtrlSetPos($idLabel, 20, 20)
Else
GUICtrlSetPos($idLabel, 20, 30)
EndIf
Sleep(160)
WEnd
EndFunc ;==>Example
示例 2
#include <MsgBoxConstants.au3>
Example()
Func Example()
Local $iOldOpt = Opt("GUICoordMode", 1)
Local $hGUI = GUICreate("My GUI icon Race", 350, 74, -1, -1)
GUICtrlCreateLabel("", 331, 0, 1, 74, 5)
Local $idIcon1 = GUICtrlCreateIcon(@ScriptDir & '\Extras\dinosaur.ani', -1, 0, 0, 32, 32)
Local $idIcon2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 0, 40, 32, 32)
GUISetState(@SW_SHOW)
Local $a = 0, $b = 0
While ($a < 300) And ($b < 300)
$a += Random(0, 1, 1)
$b += Random(0, 1, 1)
GUICtrlSetPos($idIcon1, $a, 0)
GUICtrlSetPos($idIcon2, $b, 40)
Sleep(10)
WEnd
Opt("GUICoordMode", $iOldOpt)
If $a > $b Then
MsgBox($MB_SYSTEMMODAL, 'Race results', 'The dinosaur won', 0, $hGUI)
Else
MsgBox($MB_SYSTEMMODAL, 'Race results', 'The horse won', 0, $hGUI)
EndIf
EndFunc ;==>Example
----------------------------------------
|