Sign in to follow this  
Followers 0
Lars

_GUICtrlListView_Create (EX) with icons and contextmenu

4 posts in this topic

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

Share this post


Link to post
Share on other sites



Hmmz,

Gonna need to studie some I guess :D

tnx

Share this post


Link to post
Share on other sites

Works now!!

tnx great

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0