Lars Posted June 10, 2009 Share Posted June 10, 2009 Hi there in one of the post firefox asked for a solution to _GUICtrlListView_Create with a contextmenu, then he changed the question. So I assume that that problem is solved. I am stuck on it for 2 days now, So how to do it? I really need _GUICtrlListView_Create becouse I use icons in my listview. Can anyone help me with it or send me an example? Below is some code from my test file (I know it crappy, thats what makes it a test file), there's way to many includes an 2 different approaches to the context menu but it just doesn't work for me... tnx Lars CODE#include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <TreeViewConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <ListViewConstants.au3> #include <ListBoxConstants.au3> ;Opt('MustDeclareVars', 1) Global $idOpen = 1000, $idSave = 1001, $idInfo = 1002 _Main() Func _Main() Local $hGUI ; Create GUI $hGUI = GUICreate("Menu", 400, 300) $groupTree = GUICtrlCreateTreeView(10, 10, 150, 200, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_SHOWSELALWAYS,$WS_GROUP,$WS_TABSTOP,$WS_BORDER)) $myItem = GUICtrlCreateTreeViewItem("Mijn Utopia", $groupTree) $userList = _GUICtrlListView_Create($hGUI, "Gebruiker|Omschrijving", 170, 10, 200, 200, BitOR($LVS_EDITLABELS, $LVS_REPORT,$LVS_AUTOARRANGE,$WS_VSCROLL), $WS_EX_CLIENTEDGE) _GuiCtrlListView_SetColumnWidth($userList,0,50) _GUICtrlListView_SetExtendedListViewStyle($userList, $LVS_EX_SUBITEMIMAGES) $hImage = _GUIImageList_Create(24, 24) _GUIImageList_AddBitmap ($hImage, @ScriptDir & "\jongen.bmp") _GUICtrlListView_SetImageList($userList, $hImage, 1) _GUICtrlListView_AddItem($userList, "lol entry",1) ; ---------------------------------- $buttoncontext = GUICtrlCreateContextMenu($groupTree) $buttonitem = GUICtrlCreateMenuItem("Lars button", $buttoncontext) ;----------------------------------- ; ---------------------------------- $buttoncontext2 = GUICtrlCreateContextMenu($userList) $buttonitem2 = GUICtrlCreateMenuItem("Lars button", $buttoncontext2) ;----------------------------------- GUISetState() ; Register message handlers ;GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ;GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") While 1 $nMsg = GUIGetMsg() ;If $nMsg > 0 Then MsgBox(0, "", $nMsg) Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $buttonitem MsgBox(0, "", "lol") EndSwitch WEnd EndFunc ;==>_Main ; Handle WM_COMMAND messages Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idOpen MsgBox (0, "","Open") Case $idSave MsgBox (0, "","Save") Case $idInfo MsgBox (0, "","Info") EndSwitch EndFunc ;==>WM_COMMAND ; Handle WM_CONTEXTMENU messages Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup () _GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Open", $idOpen) _GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Save", $idSave) _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Info", $idInfo) _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu ($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU Link to comment Share on other sites More sharing options...
GaryFrost Posted June 10, 2009 Share Posted June 10, 2009 You don't need to use _GUICtrlListView_Create to use icons SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Lars Posted June 10, 2009 Author Share Posted June 10, 2009 Hmmz, Gonna need to studie some I guess tnx Link to comment Share on other sites More sharing options...
Lars Posted June 10, 2009 Author Share Posted June 10, 2009 Works now!! tnx great 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