PDA

Показать полную графическую версию : [решено] GUICtrlCreateListView - отмена выделения


-TRM-
09-11-2018, 12:38
Приветствую, возможно ли сделать так, чтобы при нажатии на пункт элемент и элементы всей строки не выделялись (синим фоном) ?

Creat0R
10-11-2018, 19:53
Возможно.
Нужно отслеживать системные сообщения о выделений (фокус).

-TRM-
12-11-2018, 11:48
Creat0R, Это через WM_COMMAND ? Если ДА-без него никак?

Creat0R
13-11-2018, 02:19
-TRM-,
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Global $hListView

GUICreate("WM_NOTIFY Demo", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)

_GUICtrlListView_SetColumnWidth($hListView, 0, 90)
_GUICtrlListView_AddColumn($hListView, "Items", 100)
_GUICtrlListView_AddItem($hListView, "Item 1")
_GUICtrlListView_AddItem($hListView, "Item 2")
_GUICtrlListView_AddItem($hListView, "Item 3")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView

$hWndListView = $hListView

If Not IsHWnd($hListView) Then
$hWndListView = GUICtrlGetHandle($hListView)
EndIf

$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)

$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")

Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_ITEMCHANGING; An item is changing
;Return True; prevent the change
;Return False; allow the change
Return 1
Case $LVN_BEGINDRAG, $LVN_BEGINRDRAG ;A drag-and-drop operation involving the left/right mouse button is being initiated
Return 1
EndSwitch
EndSwitch

Return $GUI_RUNDEFMSG
EndFunc

Creat0R
03-03-2019, 04:06
без него никак? »
Можно использовать GUICtrlSetState($hListView, $GUI_DISABLE), но тогда будет видно что элемент неактивный.
Или так:

#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GuiConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <WindowsConstants.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GuiListView.au3>

Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $hListView

GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("UnSelect", 400, 300)
$hListView = GUICtrlCreateListView (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateListView.htm)("", 2, 2, 394, 268)

_GUICtrlListView_SetColumnWidth (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_SetColumnWidth.htm)($hListView, 0, 90)
_GUICtrlListView_AddColumn (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_AddColumn.htm)($hListView, "Items", 100)
_GUICtrlListView_AddItem (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_AddItem.htm)($hListView, "Item 1")
_GUICtrlListView_AddItem (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_AddItem.htm)($hListView, "Item 2")
_GUICtrlListView_AddItem (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_AddItem.htm)($hListView, "Item 3")

GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()
AdlibRegister (http://www.autoitscript.com/autoit3/docs/functions/AdlibRegister.htm)('_UnSelect_LV', 10)

Do (http://www.autoitscript.com/autoit3/docs/keywords.htm#Do)
Until (http://www.autoitscript.com/autoit3/docs/keywords.htm#Until) GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)() = $GUI_EVENT_CLOSE

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _UnSelect_LV()
_GUICtrlListView_SetItemSelected (http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_SetItemSelected.htm)($hListView, -1, False (http://www.autoitscript.com/autoit3/docs/keywords.htm#False), True (http://www.autoitscript.com/autoit3/docs/keywords.htm#True))
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)

но и тут не всё идеально, будет заметно выделение на долю секунды.




© OSzone.net 2001-2012