Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Multiple ListViews


  • Please log in to reply
4 replies to this topic

#1 crystalburner

crystalburner

    Adventurer

  • Active Members
  • PipPip
  • 144 posts

Posted 08 December 2007 - 01:52 PM

Hi Guys

I've written an app that has two listviews on one gui, they show the file contents of two different folders.

The two listviews are called $paidview and $unpaid view

Inside the gui msg loop, I use this to open the document that you have selected

        $x=number(_GUICtrlListView_GetSelectedIndices ($paidView))         run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($paidview, $x,4)),@ScriptDir,@SW_HIDE)


Now this is all good, but here is the problem.

I am only working with the $paidview guilist. I have no idea how I can determine first which guilist you have selected, because actually both guilists have selected indices.

Ideally I need something like this

                $l=_Getlastclickedguilist         $x=number(_GUICtrlListView_GetSelectedIndices ($l))         run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($l, $x,4)),@ScriptDir,@SW_HIDE)


But obviously thats just a dream! Maybe someone can help make my dream come true today?!

N







#2 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,313 posts

Posted 08 December 2007 - 08:32 PM

Hi Guys

I've written an app that has two listviews on one gui, they show the file contents of two different folders.

The two listviews are called $paidview and $unpaid view

Inside the gui msg loop, I use this to open the document that you have selected

        $x=number(_GUICtrlListView_GetSelectedIndices ($paidView))         run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($paidview, $x,4)),@ScriptDir,@SW_HIDE)


Now this is all good, but here is the problem.

I am only working with the $paidview guilist. I have no idea how I can determine first which guilist you have selected, because actually both guilists have selected indices.

Ideally I need something like this

                $l=_Getlastclickedguilist         $x=number(_GUICtrlListView_GetSelectedIndices ($l))         run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($l, $x,4)),@ScriptDir,@SW_HIDE)


But obviously thats just a dream! Maybe someone can help make my dream come true today?!

N


You could use
$CursorInfo = GuiGetCursorInfo
inside a while loop maybe. From this you can see if the mouse button is down and the control the mouse is over.

If $CursorInfo[2] then;if primary down   if $CursorInfo[4] = $paidview or $cursorInfo[4] = $unpaid then $LastselectedLV = $CursorInfo[4];set to component mouse is over endif

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

#3 crystalburner

crystalburner

    Adventurer

  • Active Members
  • PipPip
  • 144 posts

Posted 09 December 2007 - 06:18 PM

Firstly, thank you - thats actually an answer I can understand for once :)

It works well but with 1 flaw; timing.

Seems like 'If $CursorInfo[2] then' is a bit hit and miss, depends if you click right at the point it runs in the loop below. Clicking several times on the item you want ensures that you get the right result but is obviously not great..

Not sure where to go now with this one...

GUISetState(@SW_SHOW) do     $msg = GUIGetMsg()         $CursorInfo = GuiGetCursorInfo ($invoicegui)     If $CursorInfo[2] then;if primary down         if $CursorInfo[4] = $paidview or $cursorInfo[4] = $unpaidview then $ncursorresult = $CursorInfo[4];set to component mouse is over     EndIf     If $msg = $opendoc And $ncursorresult = $unpaidview Then         $x=number(_GUICtrlListView_GetSelectedIndices ($unpaidview))     ;run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($unpaidview, $x,4)),@ScriptDir,@SW_HIDE)         msgbox(262144,'', _GUICtrlListView_GetItemText ($unpaidview, $x,4))     EndIf     If $msg = $opendoc And $ncursorresult = $paidview Then         $x=number(_GUICtrlListView_GetSelectedIndices ($PaidView))     ;run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($Paidview, $x,4)),@ScriptDir,@SW_HIDE)         msgbox(262144,'', _GUICtrlListView_GetItemText ($paidview, $x,4))     EndIf until $msg = $GUI_EVENT_CLOSE


#4 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,313 posts

Posted 09 December 2007 - 09:28 PM

Firstly, thank you - thats actually an answer I can understand for once :)

It works well but with 1 flaw; timing.

Seems like 'If $CursorInfo[2] then' is a bit hit and miss, depends if you click right at the point it runs in the loop below. Clicking several times on the item you want ensures that you get the right result but is obviously not great..

Not sure where to go now with this one...

GUISetState(@SW_SHOW) do     $msg = GUIGetMsg()         $CursorInfo = GuiGetCursorInfo ($invoicegui)     If $CursorInfo[2] then;if primary down         if $CursorInfo[4] = $paidview or $cursorInfo[4] = $unpaidview then $ncursorresult = $CursorInfo[4];set to component mouse is over     EndIf     If $msg = $opendoc And $ncursorresult = $unpaidview Then         $x=number(_GUICtrlListView_GetSelectedIndices ($unpaidview)) ;run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($unpaidview, $x,4)),@ScriptDir,@SW_HIDE)         msgbox(262144,'', _GUICtrlListView_GetItemText ($unpaidview, $x,4))     EndIf     If $msg = $opendoc And $ncursorresult = $paidview Then         $x=number(_GUICtrlListView_GetSelectedIndices ($PaidView)) ;run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($Paidview, $x,4)),@ScriptDir,@SW_HIDE)         msgbox(262144,'', _GUICtrlListView_GetItemText ($paidview, $x,4))     EndIf until $msg = $GUI_EVENT_CLOSE


Try this
Plain Text         
#include <guiconstants.au3> #include <guilistview.au3> #include <constants.au3> Global $ncursorresult $invoicegui = guicreate("inv") $unpaidview = guictrlcreatelistview("unpaid",10,10,100,200) $item1=GUICtrlCreateListViewItem("item2|col22|col23",$unpaidview) $item2=GUICtrlCreateListViewItem("item1|col12|col13",$unpaidview) $item3=GUICtrlCreateListViewItem("item3|col32|col33",$unpaidview) $paidview = guictrlcreatelistview('paid',130,10,100,200) $item1=GUICtrlCreateListViewItem("item2|col22|col23",$paidview) $item2=GUICtrlCreateListViewItem("item1|col12|col13",$paidview) $item3=GUICtrlCreateListViewItem("item3|col32|col33",$paidview) $opendoc = GUICtrlCreateButton("opendoc",20,240,100,21) GUISetState(@SW_SHOW)     GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") do     $msg = GUIGetMsg()           If $msg = $opendoc And $ncursorresult = $unpaidview Then         consolewrite("1) msg = " & $msg & '$ncursorresult = ' & $ncursorresult & @LF)         $x=number(_GUICtrlListView_GetSelectedIndices ($unpaidview))            ;run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($unpaidview, $x,4)),@ScriptDir,@SW_HIDE)         msgbox(262144,'unpaid', _GUICtrlListView_GetItemText ($unpaidview, $x,0))     EndIf     If $msg = $opendoc And $ncursorresult = $paidview Then         consolewrite("2) msg = " & $msg & '$ncursorresult = ' & $ncursorresult & @LF)         $x=number(_GUICtrlListView_GetSelectedIndices ($PaidView))    ;run(@comspec & ' /c start /max ' & FileGetShortName( _GUICtrlListView_GetItemText ($Paidview, $x,4)),@ScriptDir,@SW_HIDE)         msgbox(262144,'paid', _GUICtrlListView_GetItemText ($paidview, $x,0))     EndIf until $msg = $GUI_EVENT_CLOSE Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)     Local $hWndFrom, $iCode, $tNMHDR, $hpaid, $hunpaid     $hpaid = GUICtrlGetHandle($paidview)     $hunpaid = GUICtrlGetHandle($unpaidview)     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))     $iCode = DllStructGetData($tNMHDR, "Code")      if $hWnd = $invoicegui and $iCode =  $NM_CLICK  Then                     if $hWndFrom = $hunpaid then $ncursorresult = $unpaidview                     if $hWndFrom = $hpaid then $ncursorresult = $paidview                     Return 0                             EndIf     Return $GUI_RUNDEFMSG EndFunc  ;==>WM_NOTIFY

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

#5 crystalburner

crystalburner

    Adventurer

  • Active Members
  • PipPip
  • 144 posts

Posted 09 December 2007 - 10:21 PM

WOW thanks! You saved me a lot of head scratching.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users