Sign in to follow this  
Followers 0
MyEarth

$NM_RCLICK on item

20 posts in this topic

#1 ·  Posted (edited)

Hi, how to detect on a GUICtrlCreateListView usign WM_NOTIFY - $NM_RCLICK ( right click ) if is clicked on item or on a empty space? I want to create a GUICtrlCreateContextMenu but only in the right click was on a item of the ListView, how to do that?

If is possible, please provide an example. Thanks ;)

Edited by MyEarth

Share this post


Link to post
Share on other sites



GUICtrlCreateContextMenu ( the listview controlID goes here )


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Sorry but you don't have understand. If i'll use your way, the rigth click work everyware inside the list, but i want to open the menu only in the right click was on a item, the first item, the second etc.

I have only one column with items. I hope was more clear now ;)

Share this post


Link to post
Share on other sites

MyEarth,

Look at the example for _GUICTRLListView_Create in the help file. It shows how to detect a right click and determine which item/subitem was under the mouse. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi melba, that example on WM_NOTIFY is similar to the internal GUICtrlCreateListView but i don't have understand how to check if a item is pressed or the click is in a "empty" zone.

Thanks

Share this post


Link to post
Share on other sites

MyEarth,

You provide some code to create your ListView and I will try and amend it to illustrate how it is done. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Code snippet to avoid invoking popupmenu (on right click) if clicked outside of data (item) area

Global $item, $subitem ; for sending more parametres from WM_NOTIFY

$lv_context_id = GUICtrlCreateDummy()


While 1
    Switch GuiGetMsg()

        Case $lv_context_id
            $subitem = GUICtrlRead($lv_context_id) ; set glob. variable for later using after invoke some commands
            OnListViewRightClick($subitem)
...

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam

    If $hWndGUI = $Form1 Then
        $NMHDR = DllStructCreate($tagNMHDR , $lParam)
        $hWndFrom = DllStructGetData($NMHDR, 'hWndFrom')
        $event = DllStructGetData($NMHDR, 'Code')

        If $wParam = $ListView1 And $event = $NM_RCLICK Then
            $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
            $item = DllStructGetData($NMLISTVIEW, 'Item') ; global var
            $subitem = DllStructGetData($NMLISTVIEW, 'SubItem') ; global var
;~             ConsoleWrite('wm_notify: ' & $item & ' ' & $subitem & @CRLF)
            GUICtrlSendToDummy($lv_context_id, $subitem)
        EndIf
...

; note: item,subitem - zero based a -1 outside of data area
; item finally sent over global variable
Func OnListViewRightClick($subitem)
;~     $item = _GUICtrlListView_GetNextItem($ListView1) ; current selected
;~     ConsoleWrite('OnRClick: ' & $item & ' ' & $subitem & @CRLF)

    ; on rclick outside of data area don't show context menu
    If $item = -1 Then Return

...

    TrackPopupMenu(...)
Edited by Zedna

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I have tested the snippet of Zedna but not work like expected ( maybe for my mistake )

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Global $item, $listview, $Form1 ; for sending more parametres from WM_NOTIFY

$lv_context_id = GUICtrlCreateDummy()

Example()

Func Example()
    $Form1 = GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)

    $listview = GUICtrlCreateListView("col1", 10, 10, 200, 150);,$LVS_SORTDESCENDING)
    $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("item2", $listview)
    $item2 = GUICtrlCreateListViewItem("item1", $listview)
    $item3 = GUICtrlCreateListViewItem("item3", $listview)
    GUICtrlCreateInput("", 20, 200, 150)
    GUISetState()

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $button
                MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2)
            Case $msg = $listview
                MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
            Case $msg = $lv_context_id
                $subitem = GUICtrlRead($lv_context_id) ; set glob. variable for later using after invoke some commands
                OnListViewRightClick($subitem)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func OnListViewRightClick($subitem)
    $item = _GUICtrlListView_GetNextItem($listview) ; current selected
    If $item = -1 Then Return
    ConsoleWrite('OnRClick: ' & _GUICtrlListView_GetItemText($listview, $item) & @CRLF)
 Local $contextmenu = GUICtrlCreateContextMenu($listview)
    GUICtrlCreateMenuItem("text", $contextmenu)
    GUICtrlCreateMenuItem("Open", $contextmenu)
    GUICtrlCreateMenuItem("Save", $contextmenu)
EndFunc   ;==>OnListViewRightClick

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam

    If $hWndGUI = $Form1 Then
        $NMHDR = DllStructCreate($tagNMHDR, $lParam)
        $hWndFrom = DllStructGetData($NMHDR, 'hWndFrom')
        $event = DllStructGetData($NMHDR, 'Code')

        If $wParam = $listview And $event = $NM_RCLICK Then
            $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
            $item = DllStructGetData($NMLISTVIEW, 'Item') ; global var
;~             ConsoleWrite('wm_notify: ' & $item & ' ' & $subitem & @CRLF)
            GUICtrlSendToDummy($lv_context_id, $item)
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_Notify_Events

I have the consolewrite if i click with the left of the rightmouse click

Edited by MyEarth

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hi,

Here is a simple example I just made, it's faster than to fix the one you already have.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>

Global Enum $_CM_OPEN = 1000, $_CM_SAVE, $_CM_INFO

Global $_iLastItemSelected = -1

#region GUI
Local $hGUI = GUICreate("MyGUI")

Global $_iLw1 = 0, $_hLw1 = 0, $_iDy1 = 0

$_iLw1 = GUICtrlCreateListView("Col1", 10, 10)
$_hLw1 = GUICtrlGetHandle($_iLw1)

GUICtrlCreateListViewItem("toto", $_iLw1)
GUICtrlCreateListViewItem("tata", $_iLw1)
GUICtrlCreateListViewItem("titi", $_iLw1)
GUICtrlCreateListViewItem("tutu", $_iLw1)

$_iDy1 = GUICtrlCreateDummy()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")

GUISetState(@SW_SHOW, $hGUI)
#endregion GUI

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $_iDy1
            _MyContextMenu()
    EndSwitch
    Sleep(10)
WEnd

GUIDelete($hGUI)

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $tNMHDR = 0, $iIDFrom = 0, $iCode = 0

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)

    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $iIDFrom
        Case $_iLw1
            Switch $iCode
                Case $NM_RCLICK
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    Local $iItem = DllStructGetData($tInfo, "Item")

                    $_iLastItemSelected = $iItem
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _MyContextMenu()
    Local $sItemTxt = _GUICtrlListView_GetItemText($_hLw1, $_iLastItemSelected)

    Switch GUICtrlRead($_iDy1)
        Case $_CM_OPEN
            _WinAPI_ShowMsg("Open " & $sItemTxt)
        Case $_CM_SAVE
            _WinAPI_ShowMsg("Save " & $sItemTxt)
        Case $_CM_INFO
            _WinAPI_ShowMsg("Info " & $sItemTxt)
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_MyContextMenu

Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam)
    If $_iLastItemSelected = -1 Then Return $GUI_RUNDEFMSG

    Local $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $_CM_OPEN)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $_CM_SAVE)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $_CM_INFO)
    GUICtrlSendToDummy($_iDy1, _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam, -1, -1, 1, 1, 2))
    _GUICtrlMenu_DestroyMenu($hMenu)

    Return True
EndFunc   ;==>WM_CONTEXTMENU
Edit: Added indents.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hi FireFox, i'd like to do simple things, your guys are too expert :D

This is what i have done:

#include <WindowsConstants.Au3>
#include <GUIConstantsEx.Au3>
#include <GuiListView.au3>

Global $Contex_Menu, $hListView, $Item

$hGUI = GUICreate("test", 400, 250, -1, -1)
$hListView = GUICtrlCreateListView("test", 25, 0, 177, 240)
$item1 = GUICtrlCreateListViewItem("item2", $hlistview)
$item2 = GUICtrlCreateListViewItem("item1", $hlistview)
$item3 = GUICtrlCreateListViewItem("item3", $hlistview)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $ilParam)
    $Item = DllStructGetData($NMLISTVIEW, 'Item')
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    If $Item <> -1 Then
                        _ContextMenu(1)
                    Else
                        _ContextMenu(0)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _ContextMenu($Active)
    If $Active = 0 Then
        GUICtrlDelete($Contex_Menu)
    ElseIf $Active = 1 Then
        $Contex_Menu = GUICtrlCreateContextMenu($hListView)
        $iInfo = GUICtrlCreateMenuItem("test", $Contex_Menu)
        ConsoleWrite('OnRClick: ' & _GUICtrlListView_GetItemText($hListView, $item) & @CRLF)
    EndIf
EndFunc   ;==>_ContextMenu

The only thing i don't have understad is how to "click" on GuiCtrlCreateMenuItem, some advice? And maybe clean up a bit that WM_NOTIFY

Thanks

Edited by MyEarth

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

You can set an event on your menu item with the GUICtrlSetOnEvent function but you will have to use the OnEvent option, and therefore change the GUIGetMsg part.

My sample shows how to use a single contextmenu for any item and retrieve the menu items clicked.

I suggest you to take a deeper look to it.

Edit: If you don't understand something, feel free to ask ;)

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I think i found a solution using Dummy's for the click  :thumbsup:

Please you can clean up my WM_NOTIFY so i can post my code? Many thanks

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

As you wish.

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom = 0 , $iCode = 0, $tNMHDR = 0, $hWndListView = 0

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

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

    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_RCLICK
                    Local $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    Local $iItem = DllStructGetData($tNMLISTVIEW, "Item")

                    If $iItem <> -1 Then _ContextMenu()
            EndSwitch
        EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _ContextMenu()
    If $Contex_Menu > 0 Then GUICtrlDelete($Contex_Menu)

    $Contex_Menu = GUICtrlCreateContextMenu($hListView)
    $iInfo = GUICtrlCreateMenuItem("test", $Contex_Menu)
    ConsoleWrite('OnRClick: ' & _GUICtrlListView_GetItemText($hListView, $Item) & @CRLF)
EndFunc   ;==>_ContextMenu
Edit: Added indents.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I rejoiced too soon

#include <WindowsConstants.Au3>
#include <GUIConstantsEx.Au3>
#include <GuiListView.au3>

Global $Contex_Menu, $hListView, $iItem

$hGUI = GUICreate("test", 400, 250, -1, -1)
$hListView = GUICtrlCreateListView("test", 25, 0, 177, 240)
$item1 = GUICtrlCreateListViewItem("item2", $hListView)
$item2 = GUICtrlCreateListViewItem("item1", $hListView)
$item3 = GUICtrlCreateListViewItem("item3", $hListView)

$iInfo = GUICtrlCreateDummy()
$iData = GUICtrlCreateDummy()
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iInfo
            MsgBox(0, 0, "info")
            $iInfo = GUICtrlCreateDummy()
        Case $iData
;~          MsgBox(0, 0, "data")
;~          $iData = GUICtrlCreateDummy()
    EndSwitch
WEnd


Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom = 0, $iCode = 0, $tNMHDR = 0, $hWndListView = 0

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

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

    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_RCLICK
                    $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    $iItem = DllStructGetData($NMLISTVIEW, 'Item')
                    If $iItem <> -1 Then
                        _ContextMenu(1)
                    Else
                        _ContextMenu(0)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _ContextMenu($Active)
    If $Active = 0 Then
        GUICtrlDelete($Contex_Menu)
    ElseIf $Active = 1 Then
        $Contex_Menu = GUICtrlCreateContextMenu($hListView)
        $iInfo = GUICtrlCreateMenuItem("info", $Contex_Menu)
        $iData = GUICtrlCreateMenuItem("data", $Contex_Menu)
        ConsoleWrite('OnRClick: ' & _GUICtrlListView_GetItemText($hListView, $iItem) & @CRLF)
    EndIf
EndFunc   ;==>_ContextMenu

The Dummy work but only for one element...why?

Edited by MyEarth

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

hm... You told me my example was not simple, however it works.

As I can see you don't understand how "yours" works, why are you re-creating a dummy control when this one is fired?

The schema is the following :

-Send a message to a dummy control with the GUICtrlSendToDummy function (will fire the event of this last).

-Get the dummy event with the GUIGetMsg function, and optionally read the message with the GUICtrlRead function.

For your case the message will be the menu item id clicked.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

A little note: You are using the same variables for the dummy controls and the menu item controls.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I don't have any doubt your works but i need something i can manage easily also in the future ;)

For the Dummy, If i don't recreate it i have infinite MsgBox :D

The only thing works (for me) is recreate the dummy control or put the $iInfo = -1, anyway works only if i have only one dummy but not 2 or more, really don't know why because they are two different $var.

P.S If i don't use the same variable for dummy's and menucontrol i can't "intercept" the messages

Edited by MyEarth

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I don't have any doubt your works but i need something i can manage easily also in the future ;)

The example you posted after Zedna's reply is bugged, as you said the dummy constantly fired.

You are editing it badly because you don't understand it and even if you manage to make it working, the code will be a total mess (not efficient code and dirty).

I advice you a second time to work a something which is correct and clean, because at the moment you're not providing something better.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Easier (without dummy) this example found somewhere on this forum

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $GUI = GUICreate("", 300, 450)
Global $hListView = GUICtrlCreateListView("A|B|C|D|E|F|G", 25, 25, 250, 400)
For $i = 0 To 20
    GUICtrlCreateListViewItem("A" & $i & "|B" & $i & "|C" & $i & "|D" & $i & "|E" & $i & "|F" & $i & "|G" & $i, $hListView)
Next

;Context Menu
Global $hCMenu = GUICtrlCreateContextMenu($hListView) 
Global $hCMenuText = GUICtrlCreateMenuItem("Get Text", $hCMenu) 
Global $sItemText     ;this will store the text of the last right-clicked item.

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

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $hCMenuText
            _ShowText()
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom      
        Case $hWndListView   
            Switch $iCode            
                Case $NM_RCLICK 
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)    
                    $Index = DllStructGetData($tInfo, "Index")
                    $SubItem = DllStructGetData($tInfo, "SubItem")
                    $sItemText =  _GUICtrlListView_GetItemText($hWndListView, $Index, $SubItem)   
             EndSwitch
        EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func _ShowText()
    If $sItemText <> "" Then MsgBox(0,"Test", $sItemText)
EndFunc

Share this post


Link to post
Share on other sites

I want to create a GUICtrlCreateContextMenu but only in the right click was on a item of the ListView

Furthermore, better note pasting a code with magic numbers (the -3 instead of $GUI_EVENT_CLOSE)

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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