czardas Posted December 30, 2011 Share Posted December 30, 2011 (edited) I have encountered a problem which I am struggling to overcome. My ListView Popup menu was working fine until I altered the number of rows in the test data. I started out with 3000 rows and had several working functions, all accessible from the menu which appears when you click on the column header. I didn't notice anything wrong until I tried 300 rows at which point clicking the the menu items stopped sending messages. The Help File example for _GUICtrlMenu_CreatePopup() uses WM_COMMAND messages and the menu appears as a context menu. I have altered that. The functions called from the menu all have multiple array parameters mainly status, undo/redo buffer action, occurence and type etc... I don't want to have to declare all these variables in the Global scope. For this reproducer I have replaced these functions with message boxes. To understand the problem I am experiencing, alter the 11th line by changing the For Loop repeat value to 300 instead of 1000. You will find the menu stops working. If anyone knows what I am doing wrong, please tell me because I have no idea! expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ;#include <Array.au3> #Include <GuiMenu.au3> ;#include <StaticConstants.au3> _Run() Func _SetData($hListView) For $i = 0 To 1000 ; <== Change this value to 300 GUICtrlCreateListViewItem( _ $i + 1 &"|"& _ "B_" & $i+Random(100,700, 1) &"|"& _ "C_" & $i+Random(100,700, 1) &"|"& _ "D_" & $i+Random(100,700, 1) &"|"& _ "M_" & $i+Random(100,700, 1) , $hListView) Next EndFunc Func _Run() Local $bStyle = BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX) Local $hDataBuzz = GUICreate(" AU3 Databuzz", @DesktopWidth*.9,@DesktopHeight*.8, Default, Default, $bStyle) Local $sHeadings = "Index" For $i = 1 To 4 $sHeadings &= "| " Next $hListView = GUICtrlCreateListView($sHeadings, 0, 0, @DesktopWidth*.9, @DesktopHeight*.8 -38, _ BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS)) _GUICtrlListView_SetExtendedListViewStyle($hListView, _ BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) GUICtrlSetResizing ($hListView, $GUI_DOCKBOTTOM) _GUICtrlListView_HideColumn($hListView, 0) _SetData($hListView) ; For Testing Local $iSelectedCol = 0 GUISetState(@SW_SHOW) Local $ahLVMenu[5] = [1000,1001,1002,1003,1004] ; Column popup menu ;================================================================================ While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $hListView Then $iSelectedCol = GUICtrlGetState($hListView) If $iSelectedCol > 0 Then _LV_PopUpMenu($hDataBuzz, $hListView, $iSelectedCol, $ahLVMenu) EndIf Switch $msg Case $ahLVMenu[0] MsgBox(0, "","Rename") Case $ahLVMenu[1] MsgBox(0, "", "Align") Case $ahLVMenu[2] MsgBox(0, "", "Sort") Case $ahLVMenu[3] MsgBox(0, "", "Move") Case $ahLVMenu[4] MsgBox(0, "", "Delete") EndSwitch WEnd ;=============================================================================== EndFunc Func _LV_PopUpMenu($hDataBuzz, $hListView, $iSelectedCol, $ahLVMenu) Local $aLVData = _GUICtrlListView_GetColumn($hListView, $iSelectedCol) Local $hMenu, $sHeader = $aLVData[5] If $sHeader = " " Then $sHeader = "Col " & $iSelectedCol $hMenu = _GUICtrlMenu_CreatePopup (40) _GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Renane " & $sHeader, $ahLVMenu[0]) _GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Align Right", $ahLVMenu[1]) _GUICtrlMenu_InsertMenuItem ($hMenu, 2, "Sort By " & $sHeader, $ahLVMenu[2]) _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Move " & $sHeader, $ahLVMenu[3]) _GUICtrlMenu_InsertMenuItem ($hMenu, 4, "Delete " & $sHeader, $ahLVMenu[4]) _GUICtrlMenu_TrackPopupMenu ($hMenu, $hDataBuzz) _GUICtrlMenu_DestroyMenu ($hMenu) Return True EndFunc ;==>_LV_PopUpMenu Edited December 30, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted December 30, 2011 Author Share Posted December 30, 2011 (edited) IGNORE! I believe I have solved this myself. The mistake I made was copying the Enum values in the example for _GUICtrlMenu_CreatePopup(). Instead of that I have changed $ahLVMenu to an array of Dummy Controls and it appears to have worked. If you wish to try the changes, replace the following line Local $ahLVMenu[5] = [1000,1001,1002,1003,1004] ; Column popup menu With these lines Local $ahLVMenu[5] ; Column popup menu For $i = 0 To 4 $ahLVMenu[$i] = GUICtrlCreateDummy() Next Edited December 30, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
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