Slipk Posted December 15, 2018 Posted December 15, 2018 Hello everyone, I have a problem that from the title may sound a little bit confusing. I have a listview interface with a context menu and as you know it's working only if GuiOnEventMode is enabled. However, I need a script that can check whenever the user right click on a listview item and automatically enable GuiOnEventMode to make the function run when he click menu item. I have some buttons next to listview that need to work while this is possible too. It this even can be done? Thank you and sorry for my bad english.
FrancescoDiMuro Posted December 15, 2018 Posted December 15, 2018 (edited) Hi @Slipk Control Events are handled from a Windows Message, so, if you want to capture the right click on a ListView item, you need to capture it through a WM_NOTIFY Windows Message. If you could post your code, then we can see how we can help you Edited December 15, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Slipk Posted December 15, 2018 Author Posted December 15, 2018 expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("GuiOnEventMode", 0) $Form1 = GUICreate("Form1", 615, 320, -1, -1) $ListView1 = GUICtrlCreateListView("#|Shopping list", 0, 0, 610, 254) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 25) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) $ListView1_0 = GUICtrlCreateListViewItem("1|Apples", $ListView1) $Button1 = GUICtrlCreateButton("Let me click", 16, 272, 99, 25) $SubMenu = GUICtrlCreateContextMenu($ListView1_0) GUICtrlCreateMenuItem("Check", $SubMenu) GUICtrlSetOnEvent(-1, "_Check") GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, "", "Hello") EndSwitch WEnd Func _Check() MsgBox(0,"","Check it's working!") EndFunc This is an example of my code. I want to work the GUI somehow while the menu from the item it's responsive too. I have tried several methods that almost working but you must click on the one of the menu options of the item in order to work, I want to make possible to cancel that, like if I close the menu back to change GuiOnEventMode on 0. I hope you understand. Thank you!
AutoBert Posted December 15, 2018 Posted December 15, 2018 (edited) 8 hours ago, Slipk said: I have a listview interface with a context menu and as you know it's working only if GuiOnEventMode is enabled. Where have you read this wrong statement? As you can see in this script: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("GuiOnEventMode", 0) $Form1 = GUICreate("Form1", 615, 320, -1, -1) $ListView1 = GUICtrlCreateListView("#|Shopping list", 0, 0, 610, 254) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 25) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlCreateListViewItem("1|Apples", $ListView1) GUICtrlCreateListViewItem("2|Peaches", $ListView1) $Button1 = GUICtrlCreateButton("Let me click", 16, 272, 99, 25) $SubMenu = GUICtrlCreateContextMenu($ListView1) $Check =GUICtrlCreateMenuItem("Check", $SubMenu) GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, "", "Hello") Case $Check ;MsgBox(0,"","Submenu Item Check it's working!") $sItem = StringReplace(StringTrimRight(GUICtrlRead(GUICtrlRead($ListView1)),1),'|', ' ') MsgBox(64, 'Selected: ', $sItem) EndSwitch WEnd are submenuitems also available with the GuiGetMsg mode! Edited December 15, 2018 by AutoBert Slipk 1
Slipk Posted December 15, 2018 Author Posted December 15, 2018 6 minutes ago, AutoBert said: Where have you read this wrong statement? As you can see in this script: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("GuiOnEventMode", 0) $Form1 = GUICreate("Form1", 615, 320, -1, -1) $ListView1 = GUICtrlCreateListView("#|Shopping list", 0, 0, 610, 254) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 25) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) $ListView1_0 = GUICtrlCreateListViewItem("1|Apples", $ListView1) $Button1 = GUICtrlCreateButton("Let me click", 16, 272, 99, 25) $SubMenu = GUICtrlCreateContextMenu($ListView1_0) $Check =GUICtrlCreateMenuItem("Check", $SubMenu) GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, "", "Hello") Case $Check MsgBox(0,"","Submenu Item Check it's working!") EndSwitch WEnd are submenuitems also available with the GuiGetMsg mode! Well, I can't believe I didn't tried that. Thank you a lot.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now