width [optional] The width of the control default is the previously used width.. height [optional] The height of the control default is the previously used height.. 'Document Objects' wi
Trang 1top The top of the control If -1 is used then top will be computed according to
GUICoordMode
width [optional] The width of the control (default is the previously used width) height [optional] The height of the control (default is the previously used height)
Return Value
Success: trả lại ControlID
Failure: Returns 0
Remarks
This function attempts to embed an 'ActiveX Control' or a 'Document Object'
inside the GUI
Not every control can be embedded They must at least support an 'IDispatch'
interface
'Document Objects' will only be visible if the Windows style
$WS_CLIPCHILDREN has been used in GUICreate()
The GUI functions GUICtrlRead and GUICtrlSet have no effect on this control The object can only be controlled using 'methods' or 'properties' on the $ObjectVar
Related
ObjCreate, ObjGet, ObjEvent, IsObj
Example
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Trang 2Example()
; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; See also:
http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/intern etexplorer.asp
Func Example()
Local $oIE, $GUIActiveX, $GUI_Button_Back, $GUI_Button_Forward
Local $GUI_Button_Home, $GUI_Button_Stop, $msg
$oIE = ObjCreate("Shell.Explorer.2")
; Create a simple GUI for our output
GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) /
2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW,
$WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$GUIActiveX = GUICtrlCreateObj ($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) $GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)
GUISetState() ;Show GUI
$oIE.navigate("http://www.autoitscript.com")
; Waiting for user to close the window
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Home
$oIE.navigate("http://www.autoitscript.com")
Case $msg = $GUI_Button_Back
$oIE.GoBack
Case $msg = $GUI_Button_Forward
$oIE.GoForward
Trang 3Case $msg = $GUI_Button_Stop
$oIE.Stop
EndSelect
WEnd
GUIDelete()
EndFunc ;==>Example
Function Reference
GUICtrlCreatePic
tạo một Picture control cho GUI
GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
Parameters
filename đường dẫn tới file ảnh
left tọa độ X
top tọa độ Y
width chiều rộng
height chiều cao
style
kiểu xem thêm GUI Control Styles Appendix
default (-1) : $SS_NOTIFY forced style : $SS_BITMAP exStyle kiểu mở rộng xem Extended Style Table
Return Value
Trang 4Success: trả lại ControlID
Failure: Returns 0
Remarks
để đặt các thuộc tính cho control ta dùng GUICtrlSet
để thay đổi ảnh hiện thị tao dùng GUICtrlSetImage
nếu bạn muốn kích thước control = kích thuwocs ảnh thì dùng width=height=0
To have a transparent picture it is needed to create the GUI window with
WS_EX_LAYERED extended style The left-top pixel will be used as the
transparency color If several pictures are created the last picture is defining the transparent color See example 2
để sử dụng nhiều kiểu trong style ta dùng BitOr($GUI_SS_DEFAULT_PIC,
newstyle, )
để có thể dùng đc các biến trên ta cần phải khai báo thư viện #include
<StaticConstants.au3> in your script
Default resizing is $GUI_DOCKSIZE
If a picture is set as a background picture, as the other controls will overlap, it's important to disable the pic control and create it after the others controls:
GuiCtrlSetState(-1,$GUI_DISABLE) This is not enough for Tab or Listview control which behave differently In this case you need to create the picture with the $WS_CLIPSIBLINGS style, GuiCtrlSetState(-1,$GUI_ONTOP) is necessary for the Tab or Listview control
The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that don't have a titlebar (no
$WS_CAPTION style in GUICreate)
mầu nền luôn luôn là trong suốt GUICtrlSetBkColor() ko có hiệu lực
PNG có thể sử dụng với GDI+ xem vd3
Trang 5Related
GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet , GUIGetMsg
Example
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global $gui, $guiPos, $pic, $picPos
Example1()
Example2()
; - example 1
Func Example1()
Local $n, $msg
GUICreate("My GUI picture", 350, 300, -1, -1, $WS_SIZEBOX +
$WS_SYSMENU) ; will create a dialog box that when displayed is centered
GUISetBkColor(0xE0FFFF)
$n = GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 50, 50, 200, 50)
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd