-
AutoIt
(
http://forum.oszone.net/forumdisplay.php?f=103)
работа с _GUIImageList_Create, обработка событий
Не могу обработать событие о том что выбран какой-то элемент..
то есть создаю _GUICtrlListView_Create
потом, _GUIImageList_Create
добавляю _GUICtrlListView_InsertItem
после этого мне необходимо проверять что выбран какойто элемент.
Код:
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
exit
Case ??????
MsgBox(0,"","ok")
EndSelect
WEnd
|
Цитата:
Цитата andr_mozg
необходимо проверять что выбран какойто элемент »
|
Тут Case'ом не обойтись.
Нужно делать так:
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
Global $bItemChanged = False
$hGUI = GUICreate("(Internal) ListView Get Item Text", 400, 300)
$hListView = _GUICtrlListView_Create($hGUI, "Items", 2, 2, 394, 268)
_GUICtrlListView_InsertItem($hListView, "Item 1")
_GUICtrlListView_InsertItem($hListView, "Item 2")
_GUICtrlListView_InsertItem($hListView, "Item 3")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
If $bItemChanged Then
$bItemChanged = False
$iIndx = _GUICtrlListView_GetSelectedIndices($hListView)
ConsoleWrite('Item changed: ' & _GUICtrlListView_GetItemText($hListView, Number($iIndx)) & @LF)
EndIf
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_HOTTRACK; Sent by a list-view control when the user moves the mouse over an item
Case $LVN_ITEMCHANGED, $NM_CLICK ; An item has changed/clicked
$bItemChanged = True
Case $LVN_ITEMCHANGING; An item is changing
;Return True; prevent the change
;Return False; allow the change
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
|
спасибо..все заработало...
|
Время: 07:48.
© OSzone.net 2001-