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

AutoIT Help part 49 ppsx

6 234 0
Tài liệu đã được kiểm tra trùng lặp

Đ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 65,95 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

$msg = GUIGetMsg Select Case $msg = $button MsgBox0, "listview item", GUICtrlReadGUICtrlRead$listview, 2 Case $msg = $listview MsgBox0, "listview", "clicked=" & GUICtrlGetState$list

Trang 1

$msg = GUIGetMsg()

Select

Case $msg = $button

MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2) Case $msg = $listview

MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2) EndSelect

Until $msg = $GUI_EVENT_CLOSE

EndFunc ;==>Example

Function Reference

GUICtrlCreateListViewItem

tạo một ListView item

GUICtrlCreateListViewItem ( "text", listviewID )

Parameters

text dòng chữ hiện thị

listviewID controlID của ListView

Return Value

Success: trả lại ControlID

Failure: Returns 0

Remarks

Trang 2

This function creates the individual ListView items that can be selected The items function as normal controls and can be set with GUICtrlSetData

Items can be deleted as with any other control by using GUICtrlDelete

ListView items can be dragged and drop into an Edit or Input control with a

$GUI_DROPACCEPTED state

See GUICtrlCreateListView about resizing of the column

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines

The odd lines will get the color set by GUICtrlSetBkColor of the Listview control The even lines will get the color set by GUICtrlSetBkColor of the ListviewItem control

Related

GUICtrlCreateListView, GUICtrlSetData, GUICtrlSetState, GUICtrlDelete,

GUIGetMsg, GUICtrlRead, GUIDataSeparatorChar (Option)

Example

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()

Local $listview, $button, $item1, $item2, $item3, $input1, $msg

GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color

$listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200,

150);,$LVS_SORTDESCENDING)

$button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)

$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)

$item2 = GUICtrlCreateListViewItem(" item1|col12|col13", $listview) $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)

Trang 3

$input1 = GUICtrlCreateInput("", 20, 200, 150)

GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping GUISetState()

GUICtrlSetData($item2, "|ITEM1")

GUICtrlSetData($item3, "||COL33")

GUICtrlDelete($item1)

Do

$msg = GUIGetMsg()

Select

Case $msg = $button

MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2) Case $msg = $listview

MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2) EndSelect

Until $msg = $GUI_EVENT_CLOSE

EndFunc ;==>Example

Function Reference

GUICtrlCreateMenu

Tạo một Menu control for the GUI

GUICtrlCreateMenu ( "submenutext" [, menuID [, menuentry]] )

Parameters

submenutext The submenu text

menuID [optional] If defined, allows you to create a submenu in the

referenced menu If equal -1 it refers to first level menu

menuentry [optional] Allows you to define the entry number to be created The

entries are numbered starting at 0

Trang 4

Return Value

Success: trả lại ControlID

Failure: Returns 0

Remarks

để thay đổi các thuộc tính ta dùng GUICtrlSet

Related

GUICtrlSetState, GUIGetMsg, GUICtrlCreateMenuItem, GUICtrlGetHandle

Example

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()

Local $defaultstatus = "Ready", $status, $filemenu, $fileitem

Local $helpmenu, $saveitem, $infoitem, $exititem, $recentfilesmenu

Local $separator1, $viewmenu, $viewstatusitem, $okbutton, $cancelbutton Local $statuslabel, $msg, $file

GUICreate("My GUI menu", 300, 200)

$filemenu = GUICtrlCreateMenu("&File")

$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)

GUICtrlSetState(-1, $GUI_DEFBUTTON)

Trang 5

$helpmenu = GUICtrlCreateMenu("?")

$saveitem = GUICtrlCreateMenuItem("Save", $filemenu)

GUICtrlSetState(-1, $GUI_DISABLE)

$infoitem = GUICtrlCreateMenuItem("Info", $helpmenu)

$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)

$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1)

$separator1 = GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)

GUICtrlSetState(-1, $GUI_CHECKED)

$okbutton = GUICtrlCreateButton("OK", 50, 130, 70, 20)

GUICtrlSetState(-1, $GUI_FOCUS)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20)

$statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 165, 300, 16,

BitOR($SS_SIMPLE, $SS_SUNKEN))

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $fileitem Then

$file = FileOpenDialog("Choose file ", @TempDir, "All (*.*)")

If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu) EndIf

If $msg = $viewstatusitem Then

If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) =

$GUI_CHECKED Then

GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)

GUICtrlSetState($statuslabel, $GUI_HIDE)

Else

GUICtrlSetState($viewstatusitem, $GUI_CHECKED)

Trang 6

GUICtrlSetState($statuslabel, $GUI_SHOW)

EndIf

EndIf

If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg =

$exititem Then ExitLoop

If $msg = $infoitem Then MsgBox(0, "Info", "Only a test ")

WEnd

GUIDelete()

Ngày đăng: 02/07/2014, 17:21

TỪ KHÓA LIÊN QUAN