Sign in to follow this  
Followers 0
Der_Andi

Help: Doubleclick on ListViewItem with Timer

16 posts in this topic

Hi,

in my GUI i placed a ListView.

For testing, i created a dummy-item in this LV.

Normally, the action takes place, when you do a single click on such items.

With TimerInit (and something more) you can make the item react on a doublelclick.

The item ist linked to a function called "_edit".

I'm convinced, that the function should work, but it doesn't.

Can you see something?

So long...

Andi

Func _edit()
    If $timer = 0 Then
        $timer = timerinit()
    Else        
        If TimerDiff($timer) < 400 Then
            msgbox(0, "", "test")
        EndIf
        $timer = 0
    EndIf
EndFunc

Share this post


Link to post
Share on other sites



You should be able to adapt this for what your doing, this has a click/double click event

; Events - ListView
#include <GuiConstants.au3>;Inclusion file for the GUI interface controls
#include <GuiListView.au3>

#region  Global variables
Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1

;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
#endregion End Global variables

Opt("WinTitleMatchMode", 2)

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX))

$ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth ($ListView, 0, 100)
_GUICtrlListViewSetColumnWidth ($ListView, 1, 100)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("Name 1|Category 1", $ListView)
GUICtrlCreateListViewItem("Name 2|Category 2", $ListView)
GUISetState()

;Register WM_NOTIFY  events
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
   
   $msg = GUIGetMsg()
   
   Switch $msg
      
    ;-----------------------------------------------------------------------------------------
    ;This case statement exits and updates code if needed
      Case $GUI_EVENT_CLOSE
         Exit
         
         
       ;-----------------------------------------------------------------------------------------
       ;put all the misc. stuff here
        Case Else
            ;;;
   EndSwitch
WEnd

Func ListView_Click()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then    _DebugPrint("$NM_CLICK")
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>ListView_Click

Func ListView_DoubleClick()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then    _DebugPrint ("$NM_DBLCLK")
    ;----------------------------------------------------------------------------------------------
    MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText ($ListView, _GUICtrlListViewGetSelectedIndices($ListView)))
EndFunc   ;==>ListView_DoubleClick

;
; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
    Case $wParam = $ListView
        Select
            Case $event = $NM_CLICK
                ListView_Click ()
            Case $event = $NM_DBLCLK
                ListView_DoubleClick ()
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events

Func _DebugPrint($s_text)
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

well, thanks. i grabbed some parts of your code and that work's, too.

But how would my solution correctly look like?

Edited by Der_Andi

Share this post


Link to post
Share on other sites

Any Ideas?

Share this post


Link to post
Share on other sites

I have posted my code.

Look at my initial post on top of this thread.

See? :)

Share this post


Link to post
Share on other sites

The source in

http://www.autoitscript.com/forum/index.ph...c=33549&hl=

in the Scripta and scraps section has neat double click handling (I got it from somewhere else on the forum so credit to the original poster)


Wallpaper Rotatorwith overlay, Loop through a folder of wallpaper & another of overlay, then create a combined image and set it as the wallpaperE-Mail passthru, Send any file, even executables via e-mail as plain text. The recipient can then later re-construct them.Slideshow widget, A slideshow widget similar to the Vista onePredictive typing using the Numpad, Predictive typing using the numpad of a keyboar similar to that on a mobile phone (the key is the .t16 file).PSTools Front End, For Remote Admin. Just makes life a lot easier (Demonstrates executing external programs and passing parameters, tabbed form Handling STDIN/STDERR)FTP Helper application Up and Download files from an FTP server demonstrates this and Tooltray TipsShow a Map of your Post-codes/Zip Codes, Uses the Clipboard, Hotkeys, the system tray (incl. menus)Disc/CD/DVD Catalogue, Ideal for all those Covermount Discs (Demonstrates Array handling, executing DOS programs, handling STDIN/STDOUT recursive directory reads, file searching.)YAST , Yet another Stopwatch/Timer (Uses a hotkey, Copies to clipboard, handles multiple events and stays on top)Keyboard Status Indicator , Indicates status of NumLock, Caps Lock and Scroll Lock Keys, demonstrates API calling & System tray Icon Toggling

Share this post


Link to post
Share on other sites

The source in

http://www.autoitscript.com/forum/index.ph...c=33549&hl=

in the Scripta and scraps section has neat double click handling (I got it from somewhere else on the forum so credit to the original poster)

Look in post #2 here


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

GaFrost, what is the _DebugPrint for?


A decision is a powerful thing

Share this post


Link to post
Share on other sites

Debugging :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Haha. yeah :whistle:

ok how do you use that?! I'm always looking for debug methods

Thanks shevilie!! For direction this is great!


A decision is a powerful thing

Share this post


Link to post
Share on other sites

To check a variable ...

If $DebugIt Then    _DebugPrint("$NM_CLICK")

So whenever $DebugIt is set to true.. the program sends the vars to the console :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

THAT's FREAKING AWESOME!!

My apologies for overlooking any of the obvious. I need to drink some more tea and recharge or something. My brain is toast.

Thank you both for this. Seriously, Shevilie tons of good bits of knowledge and insight. I'm learning a ton even in my low mental state, which says a lot.

I'm excited to start using and experimenting with this debug method!

Edited by JohnBailey

A decision is a powerful thing

Share this post


Link to post
Share on other sites

I need to drink some more tea and recharge

Try Cult or Redbull :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

lol great now I'm laughing out loud at my computer while at work :whistle:


A decision is a powerful thing

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