#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <GuiMenu.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
Global $idMenuItem [60]
Global $idLB = 100
Global $hwndLB = 0
$hGUI = GUICreate("Test", 400, 600, 0, 0)
$hwndLB = _WinAPI_CreateWindowEx ( _
BitOR ($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW), "ComboLBox", "", _
BitOR ($LBS_NOTIFY, $LBS_COMBOBOX, $WS_BORDER, $WS_CLIPSIBLINGS, $WS_CHILD, $WS_VSCROLL), _
450, 0, 250, 500, _
$hGUI, $idLB, _
_WinAPI_GetModuleHandle (0), _
0 _
)
_GUICtrlListBox_BeginUpdate($hwndLB)
For $i = 1 To 60
_GUICtrlListBox_AddString($hwndLB, StringFormat("%03d : Random string", Random(1, 100, 1)))
Next
_GUICtrlListBox_EndUpdate($hwndLB)
_WinAPI_SetParent ($hwndLB, 0)
#Region Button
$1bh = GUICtrlCreateButton("Test 1", 100, 118, 60, 40)
$1Context = GUICtrlCreateContextMenu($1bh)
For $i = 0 To UBound ($idMenuItem) - 1
$idMenuItem[$i] = GUICtrlCreateMenuItem(StringFormat ("Line Test %d", Random (1, 5)), $1Context)
Next
GUICtrlSetFont($1bh, 8.5, 500, 0, "")
#EndRegion Button
GUISetState(@SW_SHOW)
While 1
Sleep(10)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $1bh
_WinAPI_ShowWindow ($hwndLB, @SW_SHOWDEFAULT)
;ShowMenu($hGUI, $nMsg, $1Context)
Case $idMenuItem[0] To $idMenuItem[ UBound ($idMenuItem) - 1]
GUICtrlSetData($1bh, _GUICtrlMenu_GetItemText (GUICtrlGetHandle($1Context), $idMenuItem[$nMsg], 0))
EndSwitch
WEnd
#Region Func
Func ShowMenu($hWnd, $CtrlID, $nContextID)
Local $arPos, $x, $y
Local $hMenu = GUICtrlGetHandle($nContextID)
$arPos = ControlGetPos($hWnd, "", $CtrlID)
$x = $arPos[0]
$y = $arPos[1] + $arPos[3]
ClientToScreen($hWnd, $x, $y)
TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc ;==>ShowMenu
; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
Local $stPoint = DllStructCreate("int;int")
DllStructSetData($stPoint, 1, $x)
DllStructSetData($stPoint, 2, $y)
DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
$x = DllStructGetData($stPoint, 1)
$y = DllStructGetData($stPoint, 2)
; release Struct not really needed as it is a local
$stPoint = 0
EndFunc ;==>ClientToScreen
; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc ;==>TrackPopupMenu
#EndRegion Func
Alles anzeigen
Den Rest musst Du Dir zusammenbasteln ...