FaridAgl Posted August 19, 2013 Share Posted August 19, 2013 (edited) Here is a simple example: #include <GUIConstantsEx.au3> GUICreate("ListView", 600, 400) Global $lvwListView = GUICtrlCreateListView("Test 1|Test 2|Test 3", 10, 10, 580, 380) Global $mnuListView = GUICtrlCreateContextMenu($lvwListView) GUICtrlCreateMenuItem("ListView MenuItem 1", $mnuListView) GUICtrlCreateMenuItem("ListView MenuItem 2", $mnuListView) GUICtrlCreateMenuItem("", $mnuListView) GUICtrlCreateMenuItem("ListView MenuItem 3", $mnuListView) GUISetState() Do Until (GUIGetMsg() = $GUI_EVENT_CLOSE) I just want to see no context menu when right-clicking on the header. Any one solved this before? Edited August 19, 2013 by D4RKON3 http://faridaghili.ir Link to comment Share on other sites More sharing options...
FireFox Posted August 19, 2013 Share Posted August 19, 2013 Yes we did. yutijang 1 Link to comment Share on other sites More sharing options...
Solution FireFox Posted August 19, 2013 Solution Share Posted August 19, 2013 (edited) This will work on listview items only (not on the blank part), I can do it but too much tired for today sorry. Of course if someone else wants to share his solution, I let my place expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GUIListView.au3> #include <GUIMenu.au3> ;>> Global Enum $_CM_ITEM1 = 1, $_CM_ITEM2 GUICreate("ListView", 600, 400) Global $lvwListView = GUICtrlCreateListView("Test 1|Test 2|Test 3", 10, 10, 580, 380) For $i = 1 To 10 GUICtrlCreateListViewItem("1|2|3", $lvwListView) Next ; >> Global $iDyContextMenu = GUICtrlCreateDummy() GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") GUISetState() While 1 Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iDyContextMenu _Dummy_ContextMenu() EndSwitch WEnd ; >> GUIDelete() Func _Dummy_ContextMenu() Switch GUICtrlRead($iDyContextMenu) Case $_CM_ITEM1 MsgBox($MB_SYSTEMMODAL, "", "Item1 clicked.") Case $_CM_ITEM2 MsgBox($MB_SYSTEMMODAL, "", "Item2 clicked.") EndSwitch EndFunc ;==>_Dummy_ContextMenu Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $aCurInfo = GUIGetCursorInfo($hWnd) If $aCurInfo[4] <> $lvwListView Then Return $GUI_RUNDEFMSG Local $aHit = _GUICtrlListView_HitTest($iwParam) If $aHit[0] = -1 Then Return $GUI_RUNDEFMSG _GUICtrlListView_SetItemSelected($iwParam, $aHit[0]) Local $hMenu = 0, $iMenuID = 0 $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_AddMenuItem($hMenu, "ListView MenuItem 1", $_CM_ITEM1) _GUICtrlMenu_AddMenuItem($hMenu, "") _GUICtrlMenu_AddMenuItem($hMenu, "ListView MenuItem 2", $_CM_ITEM2) $iMenuID = _GUICtrlMenu_TrackPopupMenu($hMenu, $iwParam, -1, -1, 1, 1, 3) If $iMenuID Then GUICtrlSendToDummy($iDyContextMenu, $iMenuID) _GUICtrlMenu_DestroyMenu($hMenu) Return $GUI_RUNDEFMSG EndFunc ;==>WM_CONTEXTMENU Br, FireFox. Edited August 19, 2013 by FireFox Link to comment Share on other sites More sharing options...
FaridAgl Posted August 20, 2013 Author Share Posted August 20, 2013 Well, thank you and yes, that's quite nice, ignoring the right-click on no item is great. Selecting the first item on header right-click is a tricky way, but I'm more interested to disable the right-click for the header. Any idea? http://faridaghili.ir Link to comment Share on other sites More sharing options...
FireFox Posted August 20, 2013 Share Posted August 20, 2013 It's not an issue, it redirects the right click on the first listview item.I will take a look at it. Link to comment Share on other sites More sharing options...
FireFox Posted August 20, 2013 Share Posted August 20, 2013 I tried some WM handling but I got nothing concluding.You can create a listview with just the header and another listview without header and handle the column resize so that it looks like only one listview.Br, FireFox. Link to comment Share on other sites More sharing options...
FaridAgl Posted August 20, 2013 Author Share Posted August 20, 2013 OK, thank you. It's somehow solved. Thanks. http://faridaghili.ir 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