Sign in to follow this  
Followers 0
slaughter

GuiCtrlCreateListView

7 posts in this topic

Here is the problem what I have.

$listview = GUICtrlCreateListView ("some info |X|X|X",10,230,480,410)

$listview2 = GUICtrlCreateListView ("some info|X|X|X ",500,230,480,410)

if some of them is selected I nead to know witch of them was active before clicking some button

I tried testing eith thease

$lv1 = GUICtrlRead ( $listview, 1 ) & " " & GUICtrlGetState ( $listview )

$lv2 = GUICtrlRead ( $listview2, 1 ) & " " & GUICtrlGetState ( $listview2 )

MsgBox (1, "1", $lv1)

MsgBox (1, "2", $lv2)

Didint got anyting reasonable.

When no selected anyting on a list view GUICtrlRead say 0 but when i select someting on a second. The selection remain and on first one...

:/ How to determinate witch listwiev was selected last one before clicking button?

#include <GUIConstants.au3>
dim $list_item[100],$list_item2[100]
$gui=GUICreate("Some Gui", 1000, 650)
$listview = GUICtrlCreateListView ("some info |X|X|X",10,230,480,410)
$listview2 = GUICtrlCreateListView ("some info|X|X|X ",500,230,480,410)
$Button_3 = GUICtrlCreateButton ("Edit Smth...",  690, 193, 100)
For $nuo = 6 to 19 step 1
If $nuo < 10 Then
$laikas = "0" & $nuo & ":00"
$laikasx = "0" & $nuo & ":30"
EndIf
If $nuo >= 10 Then
$laikas = $nuo & ":00"
$laikasx = $nuo & ":30"
EndIf
$list_item[$nuo]=GUICtrlCreateListViewItem($laikas &"|",$listview)
$list_item[$nuo+24]=GUICtrlCreateListViewItem($laikasx &"|",$listview)

$list_item2[$nuo]=GUICtrlCreateListViewItem($laikas &"|",$listview2)
$list_item2[$nuo+24]=GUICtrlCreateListViewItem($laikasx &"|",$listview2)
Next

GUISetState (@SW_SHOW)

While 1
    $msg = GUIGetMsg($gui)
     If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Button_3 Then 
        Global $listview, $listview2
        $lv1 = GUICtrlRead ( $listview, 1 ) & "  " & GUICtrlGetState ( $listview )
        $lv2 = GUICtrlRead ( $listview2, 1 ) & "  " & GUICtrlGetState ( $listview2 )
        MsgBox (1, "1", $lv1)
        MsgBox (1, "2", $lv2)
    EndIf
Wend

Share this post


Link to post
Share on other sites



I found on forum

#include <GuiConstants.au3>

Global Const $WM_NOTIFY = 0x004E

Global $DoubleClicked = False

GUICreate("Double Click Demo", 400, 300)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$ListViewID = GuiCtrlCreateListView("List Column", 10, 20, 380, 250)

For $i = 1 To 10

GuiCtrlCreateListViewItem("Item " & $i, $ListViewID)

Next

GUISetState()

While GUIGetMsg() <> -3

Sleep(10)

If $DoubleClicked Then

DoubleClickFunc()

$DoubleClicked = False

EndIf

WEnd

Func DoubleClickFunc()

MsgBox(64, "OK", "Double Clicked: " & GUICtrlRead(GUICtrlRead($ListViewID)))

EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)

Local $tagNMHDR, $event, $hwndFrom, $code

$tagNMHDR = DllStructCreate("int;int;int", $lParam)

If @error Then Return 0

$code = DllStructGetData($tagNMHDR, 3)

If $wParam = $ListViewID And $code = -3 Then $DoubleClicked = True

Return $GUI_RUNDEFMSG

EndFunc

It wuld be a soliution if that wuld say with listwiev was dubleclicked <_<

I have problem understandind DLLStructure.... :/

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

Global Const $WM_NOTIFY = 0x004E
Global Const $NM_CLICK = -2
Global Const $NM_DBLCLK = -3

$Form1 = GUICreate("Test", 619, 200)
$ListView1 = GUICtrlCreateListView("X|X|X", 25, 33, 266, 118)
GUICtrlCreateListViewItem("1|1|1", $ListView1)
$ListView2 = GUICtrlCreateListView("Y|Y|Y", 328, 33, 261, 118)
GUICtrlCreateListViewItem("2|2|2", $ListView2)
GUISetState(@SW_SHOW, $Form1)
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event
        $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
        Select
        Case $wParam = $ListView1
            Select
                Case $event = $NM_CLICK
                    onclick1()
                Case $event = $NM_DBLCLK
                    OnDoubkleClick1()
            EndSelect
                    Case $wParam = $ListView2
            Select
                Case $event = $NM_CLICK
                    onclick2()
                Case $event = $NM_DBLCLK
                    OnDoubkleClick2()
            EndSelect
    EndSelect
EndFunc

Func onclick1()
    ConsoleWrite('click in ListView1' & @CRLF)
    ; some more code ...
EndFunc

Func OnDoubkleClick1()
    ConsoleWrite('doubleclick in ListView1' & @CRLF)
    ; some more code ...
EndFunc

Func onclick2()
    ConsoleWrite('click in ListView2' & @CRLF)
    ; some more code ...
EndFunc

Func OnDoubkleClick2()
    ConsoleWrite('doubleclick in ListView2' & @CRLF)
    ; some more code ...
EndFunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for solutin it works. But now i face second problem when i use guictrldelete($listviewitem[$smtg]) then dubleclick stops working.

Why is that?

I create array of listviewitem's and after some time i have update listview so i delete all items using GuiCtrlDelete and update them in the same wai i created first time after tht it stops working...

Func update()

Global $item_list1[50]

$state1 = GUICtrlGetState ( $listview )

If $state1 = -1 Then

$listview = GUICtrlCreateListView ("Data|X|X|X ",10,230,480,410)

Else

For $it = 0 to $item_list1[0] step 1

if $item_list1[$it] <> "" Then GUICtrlDelete($item_list1[$it])

Next

EndIf

_ArrayAdd( $item_list1, GUICtrlCreateListViewItem ( $smth[$for], $listview ))

_ArrayAdd( $item_list1, GUICtrlCreateListViewItem ( $smth[$for], $listview ))

_ArrayAdd( $item_list1, GUICtrlCreateListViewItem ( $smth[$for], $listview ))

_ArrayAdd( $item_list1, GUICtrlCreateListViewItem ( $smth[$for], $listview ))

EndFunc

Edited by slaughter

Share this post


Link to post
Share on other sites

Hi again. Well I noticed that if I delete gui Dubleclick stops from working on newly created listwiev's. well anyway i sorted that out in different action ;P modified script to delete items not listview <_<

Thanks all for help!!!!!! :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi again. Well I noticed that if I delete gui Dubleclick stops from working on newly created listwiev's. well anyway i sorted that out in different action ;P modified script to delete items not listview <_<

Thanks all for help!!!!!! :)

Don't do delete GUI, just do HIDE/SHOW instead.

Problems are possible because newly created GUI has diferrent window handle I think there should be 

done new GUIRegisterMsg() call.

Edited by Zedna

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0