1. Trang chủ
  2. » Công Nghệ Thông Tin

AutoI Technology Curriculum Book part 50 ppsx

6 244 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 68 KB

Nội dung

;~ GUISetState () ; resize the control $n = GUICtrlSetPos($n, 50, 50, 200, 100) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFunc ;==>Example1 ; example 2 Func Example2() Local $msg $gui = GUICreate("test transparentpic", 200, 100) $pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui) GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 0, 0) GUISetState(@SW_SHOW, $pic) GUISetState(@SW_SHOW, $gui) HotKeySet("{ESC}", "main") HotKeySet("{LEFT}", "left") HotKeySet("{RIGHT}", "right") HotKeySet("{DOWN}", "down") HotKeySet("{UP}", "up") $picPos = WinGetPos($pic) $guiPos = WinGetPos($gui) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example2 Func main() $guiPos = WinGetPos($gui) WinMove($gui, "", $guiPos[0] + 10, $guiPos[1] + 10) EndFunc ;==>main Func left() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0] - 10, $picPos[1]) EndFunc ;==>left Func right() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0] + 10, $picPos[1]) EndFunc ;==>right Func down() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0], $picPos[1] + 10) EndFunc ;==>down Func up() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0], $picPos[1] - 10) EndFunc ;==>up ; example 3 PNG work araund by Zedna #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", 350, 301) ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("MAIN.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() ; Draw PNG image Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc Function Reference GUICtrlCreateProgress tạo một Progress control cho GUI. GUICtrlCreateProgress ( left, top [, width [, height [, style [, exStyle]]]] ) Parameters left X top Y width W height H style kiểu xem GUI Control Styles Appendix. exStyle kiểu mở rộng, xem Extended Style Table. Return Value Success: trả lại ControlID Failure: Returns 0. Remarks để lấy giá trị của control ta dùng GUICtrlRead. để đặt các thuộc tính cho control ta dùng GUICtrlSet để thay đổi giá trị ta dùng GUICtrlSetData. để sử dụng nhiều kiểu trong style ta dùng BitOr($GUI_SS_DEFAULT_PROGRESS, newstyle, ). để có thể dùng đc các biến trên ta cần phải khai báo thư viện #include <ProgressConstants.au3> in your script. Default resizing is $GUI_DOCKAUTO size and position will occur. Related GUICoordMode (Option), GUICtrlSetData, GUICtrlSet , GUIGetMsg Example #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m GUICreate("My GUI Progressbar", 220, 100, 100, 200) $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20) GUICtrlSetColor(-1, 32250); not working with Windows XP Style $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) $button = GUICtrlCreateButton("Start", 75, 70, 70, 20) GUISetState() $wait = 20; wait 20ms for next progressstep $s = 0; progressbar-saveposition Do $msg = GUIGetMsg() If $msg = $button Then GUICtrlSetData($button, "Stop") For $i = $s To 100 If GUICtrlRead($progressbar1) = 50 Then MsgBox(0, "Info", "The half is done ", 1) $m = GUIGetMsg() If $m = -3 Then ExitLoop If $m = $button Then GUICtrlSetData($button, "Next") $s = $i;save the current bar-position to $s ExitLoop Else $s = 0 GUICtrlSetData($progressbar1, $i) GUICtrlSetData($progressbar2, (100 - $i)) Sleep($wait) EndIf Next If $i > 100 Then ; $s=0 GUICtrlSetData($button, "Start") EndIf EndIf . ;~ GUISetState () ; resize the control $n = GUICtrlSetPos($n, 50, 50, 200, 100) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If. Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", 350, 301) ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("MAIN.png"). 100, 100, 200) $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20) GUICtrlSetColor(-1, 32 250) ; not working with Windows XP Style $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20,

Ngày đăng: 07/07/2014, 01:20