Jump to content

Recommended Posts

Posted

The below code updates an input field to show how many listviewitems are selected. The problem is that the $GUI_EVENT_PRIMARYUP doesn't fire when clicking on a listviewitem - only on part of the listview itself (scrollbar, emptyspace, column header, etc). I have searched the forums and there are lots of people who aparently have something similar to this working. Not sure what the problem is.

$listView= GUICtrlCreateListView("Email Lists",120+$halignInput,190+$valignInput,220,115,BitOR($LVS_REPORT, $LVS_SORTASCENDING,$LVS_NOCOLUMNHEADER))

;Then a function that adds listview items based on folder contents
;Other stuff
;Then my msg loop

        Case $msg = $GUI_EVENT_PRIMARYUP
            $pos = GUIGetCursorInfo()
            If ($pos[4] = $listView) Then
                GUICtrlSetData($inputField,_GUICtrlListViewGetSelectedCount($listView))
            EndIf
Posted

Yep, I have the same problem.

Would like to know a solution too.

Anyone ?

D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
Posted

why not use a click event instead of trying to get primary up?

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

Global $ListView
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 0

;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))

$input = GUICtrlCreateInput("",5,10,120,20)

$ListView = GUICtrlCreateListView("Email Lists", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL))
_GUICtrlListViewSetColumnWidth ($ListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("E-Mail Name 1", $ListView)
GUICtrlCreateListViewItem("E-Mail Name 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    ConsoleWrite (_DebugHeader ("$NM_CLICK"))
    ;----------------------------------------------------------------------------------------------
    GUICtrlSetData($input,_GUICtrlListViewGetItemText ($ListView))
EndFunc   ;==>ListView_Click

Func ListView_DoubleClick()
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader ("$NM_DBLCLK"))
    ;----------------------------------------------------------------------------------------------
    MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText ($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
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_Notify_Events

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

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...