Tải bản đầy đủ (.pdf) (6 trang)

Giáo Trình How To Use AutoIt A Professional Manner part 66 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (18.6 KB, 6 trang )


Return Value
Success:

Returns 1.
Failure:

Returns 0.

Remarks
None.
Related
GUICreate
Example

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
Local $msg

GUICreate("My GUI") ; will create a dialog box that when displayed is
centered

GUISetHelp("notepad") ; will run notepad if F1 is typed


GUISetState() ; will display an empty dialog box



; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc ;==>Example



Function Reference
GUISetIcon
Sets the icon used in a GUI window.
GUISetIcon ( iconfile [, iconID [, winhandle]] )
Parameters
iconfile used to display the icon in the title area.
iconID [optional] The ID of the icon in the iconfile. (Default is -1).
winhandle
[optional] Windows handle as returned by GUICreate (default is the
previously used window).

Return Value
Success:

Returns 1.
Failure:

Returns 0.


Remarks
Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have
icon extracted

just with negative numbers.
Related
GUICreate
Example

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt
v3\AutoIt", "InstallDir") & "\icons\filetype1.ico"
Local $msg

GUICreate("My GUI new icon") ; will create a dialog box that when displayed
is centered

GUISetIcon($sFile) ; will change icon

GUISetState(); will display an empty dialog box

; Run the GUI until the dialog is closed
While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc ;==>Example



Function Reference
GUISetOnEvent
Defines a user function to be called when a system button is clicked.
GUISetOnEvent ( specialID, "function" [, winhandle] )
Parameters
specialID See the Special ID table below.
function The name of the user function to call.
winhandle
[optional] Windows handle as returned by GUICreate (default is the
previously used window).

Return Value
Success:

Returns 1.
Failure:

Returns 0.

Remarks
OnEvent functions are only called when the option GUIOnEventMode is set to 1 -
when in this mode GUIGetMsg is NOT used at all.


If the option GUIEventOptions is set to 1 the minimize, restore and maximize
button will not do any action on the window just a simple notification.

If the function is an empty string "" the previous user-defined is disabled.

Special ID table
Special Id

Comments

$GUI_EVENT_CLOSE
dialog box being closed (either by defined
button or system menu).
$GUI_EVENT_MINIMIZE
dialog box minimized with Windows title
bar button.
$GUI_EVENT_RESTORE
dialog box restored by click on task bar
icon.
$GUI_EVENT_MAXIMIZE
dialog box maximized with Windows title
bar button.
$GUI_EVENT_MOUSEMOVE the mouse cursor has moved.
$GUI_EVENT_PRIMARYDOWN the primary mouse button was pressed.
$GUI_EVENT_PRIMARYUP the primary mouse button was released.
$GUI_EVENT_SECONDARYDOWN

the secondary mouse button was pressed.
$GUI_EVENT_SECONDARYUP the secondary mouse button was released.

$GUI_EVENT_RESIZED dialog box has been resized.
$GUI_EVENT_DROPPED
End of a Drag&Drop action
@GUI_DRAGID, @GUI_DRAGFILE
and @GUI_DROPID will be used to
retrieve the ID's/file corresponding to the
involve control.

Related
GUIOnEventMode (Option), GUIEventOptions (Option), GUICtrlSetOnEvent
Example

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
Local $parent1, $ok1, $cancel1

Opt("GUICoordMode", 2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

×