Jump to content

Recommended Posts

Posted

Hello everybody,

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListViewEx.au3>

$Form1 = GUICreate("Form1", 539, 350, 192, 124)
$ListView1 = GUICtrlCreateListView("CLM1|CLM2", 0, 0, 538, 326)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)

Local $dynamic = GUICtrlCreateListViewItem("Example1|Example2", $ListView1)
$SubMenu = GUICtrlCreateContextMenu($dynamic)

$Run = GUICtrlCreateMenuItem("Run", $SubMenu)
$Edit = GUICtrlCreateMenuItem("Edit", $SubMenu)
$Delete = GUICtrlCreateMenuItem("Delete", $SubMenu)

Local $dynamic2 = GUICtrlCreateListViewItem("Example3|Example6", $ListView1)
$SubMenu = GUICtrlCreateContextMenu($dynamic2)

$Run = GUICtrlCreateMenuItem("Run", $SubMenu)
$Edit = GUICtrlCreateMenuItem("Edit", $SubMenu)
$Delete = GUICtrlCreateMenuItem("Delete", $SubMenu)

_GUIListViewEx_Init($ListView1, "", 0, 0, True, 64)
_GUIListViewEx_MsgRegister()

GUISetState(@SW_SHOW)

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

    EndSwitch
WEnd

I use GUIListViewEx.au3 for position of items in listview but when I move one the context menu disappear. Any solution of this?

Any method than array it is possible?

Thank you, appreciate it.

 

 

  • Moderators
Posted

Slipk,

Why are you creating the same menu for each item? For a start you are constantly overwriting the same variable with the new ControlIDs, which means that you will only ever get the menu to work. Just apply the context menu to the whole ListView and use _GUIListViewEx_ContextPos to determine which item was last right-clicked. Example 6 in the UDF zip shows you how to do it.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Posted

Hello Melba,

The problem is the next one.

 

This script above it's just an example. An user can create dynamically an infinite number of listviewitems that must have the context menu when you right click.

At all of them it has to do the same thing, so it's not a problem.

 

It's there any way to count all items from up to down after it moves them and attribute the context menu at every item without knowing the variable?

Thanks.

  • Moderators
Posted

Slipk,

Read what I said and run the example I mentioned. You create a context menu for the whole ListView and then the UDF will tell you which item was clicked so you can do whatever is necessary.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

  • Moderators
Posted

Slipk,

Glad I could help.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Posted

@M23: is there a similar method to use for edit controls on a gui?  I understand how listview elements can share a context menu. But what about controls on a gui?

For example, if I have 3 edit controls, I've been defining individual context menus that are essentially the same menu. What I want to avoid is having the context menu appear when I click elsewhere on the GUI (away from the edit controls).

Am I approaching this the wrong way?  Is this an instance where _GUICtrlMenu_TrackPopupMenu should be used?

Thanks.

  • Moderators
Posted

qwert,

No idea. I suggest opening a new thread as this one will not attract much attention from others given that its title refers to my UDF.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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
×
×
  • Create New...