Sign in to follow this  
Followers 0
dushkin

Working on context menu

3 posts in this topic

Hi all,

I am working on an application which has a list view, and can open a context menu on each one of the list item.

How can I get information about the menu?

I managed to go through the menu items by sending "down" commands. 

But how can I check for example the items text?

I tried this:

$hMenu = _GUICtrlMenu_GetMenu($hListViewHandle)
 
$itemtext =_GUICtrlMenu_GetItemText($hMenu, 1)
 
ConsoleWrite("Menu item text: " & $itemtext & @CRLF)
 
but $itemtext was empty.

 

I think my problem is getting the menu handler, because I am familiar with the _GUICtrlMenu functuions.

Thanks!

Share this post


Link to post
Share on other sites



dushkin,

Try this: :)

#include <WindowsConstants.au3>
#include "SendMessage.au3"
#Include <GuiMenu.au3>

Global $sCurr_Text

While 1

    If WinExists("[CLASS:#32768]") Then

        $hWnd = WinGetHandle("[CLASS:#32768]")

        $hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0)
        If _GUICtrlMenu_IsMenu($hMenu) Then
            $iCount = _GUICtrlMenu_GetItemCount($hMenu)
            For $j = 0 To $iCount - 1
                If _GUICtrlMenu_GetItemHighlighted($hMenu, $j) Then
                    $sText = _GUICtrlMenu_GetItemText($hMenu, $j)
                    If $sText <> $sCurr_Text Then
                        ConsoleWrite($sText & @CRLF)
                        $sCurr_Text = $sText
                    EndIf
                EndIf
            Next
        EndIf

    EndIf

    Sleep(10)

WEnd
It looks for a standard Windows popup and checks if it is a menu.  It works perfectly on standard Windows context menus - let us hope that your ListView uses the API to produce its context menus. ;)

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

Well Mel, your'e the greatest! Thanks!!! 

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