Jump to content

_GUICtrlListBox and ContextMenu wont work


Markus21
 Share

Recommended Posts

Hi, I was in need of a listbox, where I can select several items.

The solution was _GUICtrlListBox, but now the problem is, that I cant assign a Contextmenu to it.

Is there any alternative or is there something wrong (It works for normal list..)?

$usersinuo = _GUICtrlListBox_Create($GUI, "", 300, 20, 100, 200, $LBS_EXTENDEDSEL) 
_GUICtrlListBox_AddString($usersinuo, "Michael")
_GUICtrlListBox_AddString($usersinuo, "Hans")

$contextmenu2 = GUICtrlCreateContextMenu($usersinuo)
$submenu2 = GUICtrlCreateMenu("Move To", $contextmenu2)

Thanks for help!

Bye,

Markus

Link to comment
Share on other sites

Markus21

Example:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>

$GUI = GUICreate("Test GUI", 300, 200)

$hListBox = GUICtrlCreateList("", 10, 10, 280, 180, $LBS_EXTENDEDSEL)
_GUICtrlListBox_AddString($hListBox, "Michael")
_GUICtrlListBox_AddString($hListBox, "Hans")

$contextmenu2 = GUICtrlCreateContextMenu($hListBox)
$submenu2 = GUICtrlCreateMenuItem("Move To", $contextmenu2)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $submenu2
            $Index = _GUICtrlListBox_GetCurSel($hListBox)
            If $Index <> -1 Then ConsoleWrite('!> String: "' & _GUICtrlListBox_GetText($hListBox, $Index) & '" has moved' & @LF)
    EndSwitch
WEnd
Link to comment
Share on other sites

Markus21

Controls created with functions GUICtrlCreateList() and _GUICtrlListBox_Create() is window with ListBox style. You can send messages to this window, so:

For native listbox control

_SendMessage(GuiCtrlGetHandle($hListBox), $LB_GETCURSEL)
;Or
GUICtrlSendMsg($hWnd, $LB_GETCURSEL, 0, 0)

for UDF listbox

_SendMessage($hListBox, $LB_GETCURSEL)

:)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...