' Popup Menu via Win32 DECLARE — TrackPopupMenu
#COMPILE EXE
#DIM ALL

DECLARE FUNCTION CreatePopupMenu LIB "USER32.DLL" () AS LONG
DECLARE FUNCTION AppendMenu LIB "USER32.DLL" ALIAS "AppendMenuA" (BYVAL hMenu AS LONG, BYVAL uFlags AS LONG, BYVAL uIDNewItem AS LONG, BYVAL lpNewItem AS ASCIIZ) AS LONG
DECLARE FUNCTION TrackPopupMenu LIB "USER32.DLL" (BYVAL hMenu AS LONG, BYVAL uFlags AS LONG, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL nReserved AS LONG, BYVAL hWnd AS LONG, BYVAL prcRect AS LONG) AS LONG

FUNCTION PBMAIN() AS LONG
    LOCAL hPopup AS LONG
    PRINT "Popup Menu via Win32 API:"
    hPopup = CreatePopupMenu()
    AppendMenu(hPopup, 0, 101, "Copy")
    AppendMenu(hPopup, 0, 102, "Paste")
    AppendMenu(hPopup, 0, 103, "Cut")
    PRINT "Popup menu created with 3 items"
    PRINT "Call TrackPopupMenu to display it"
    FUNCTION = 0
END FUNCTION
