General information
Category:
Windows API functions
Title:
A right-click Windows pop-up
The problem: I want to create a Windows (95) pop-up (this is working) that returns
the value of the item clicked. I don't care if its the index value or the text value.
I can't find the API call for this. Please help.
Thanks,
Brent
Here's the code:
#DEFINE MF_DISABLED 2
#DEFINE MF_STRING 0
#DEFINE MF_ENABLED 0
#DEFINE RESERVED 0
#DEFINE MF_BYPOSITION 1024
#DEFINE MF_SEPARATOR 2048
#DEFINE MF_UNCHECKED 0
#DEFINE MF_CHECKED 8
#DEFINE MF_INSERT 0
#DEFINE MF_CHANGE 128
#DEFINE MF_APPEND 256
#DEFINE MF_DELETE 512
#DEFINE MF_REMOVE 4096
#DEFINE MF_UNHILITE 0
#DEFINE MF_HILITE 128
#DEFINE MF_POPUP 16
#DEFINE MF_BYCOMMAND 0
#DEFINE TPM_LEFTBUTTON 2
#DEFINE TPM_RIGHTBUTTON 0
#DEFINE TPM_LEFTALIGN 0
#DEFINE TPM_RIGHTALIGN 8
LOCAL nMenuHandle, flags, idNewItem, NEWITEM, nWindowHandle, cBuffer
STORE SPACE(50) TO cBuffer
DECLARE INTEGER CreatePopupMenu IN USER32
DECLARE INTEGER AppendMenu IN USER32 ;
INTEGER nMenuHandle, INTEGER flags, INTEGER idNewItem, STRING @NEWITEM
DECLARE INTEGER GetForegroundWindow IN USER32
DECLARE INTEGER SetMenu IN USER32 INTEGER nWindowHandle, INTEGER nMenuHandle
DECLARE INTEGER TrackPopupMenu IN USER32 INTEGER nMenuHandle, INTEGER flags, ;
INTEGER x, INTEGER Y, INTEGER nReserved, INTEGER nWindowHandle
DECLARE INTEGER GetMenuString IN USER32 INTEGER nMenuHandle, INTEGER wIDItem,;
STRING @cBuffer, INTEGER nMaxCount, INTEGER flag
DECLARE INTEGER GetMenuItemID IN USER32 INTEGER nMenuHandle, INTEGER nPos
DECLARE INTEGER GetMenuItemCount IN USER32 INTEGER nMenuHandle
CLEAR
nMenuHandle = 0
nWindowHandle = GetForegroundWindow()
nMenuHandle = CreatePopupMenu()
nNewMenuHandle = CreatePopupMenu()
AppendMenu(nNewMenuHandle, MF_ENABLED+MF_STRING, 0, "Smith")
AppendMenu(nMenuHandle, MF_ENABLED+MF_STRING+MF_POPUP, nNewMenuHandle, "Nick")
AppendMenu(nMenuHandle, MF_ENABLED+MF_STRING, 1, "Brent")
AppendMenu(nMenuHandle, MF_SEPARATOR, 2, "-")
AppendMenu(nMenuHandle, MF_ENABLED+MF_STRING, 3, "A Really Long Menu Item")
TrackPopupMenu(nMenuHandle, TPM_RIGHTALIGN+TPM_RIGHTBUTTON, 300, 300, RESERVED, nWindowHandle)
nCnt = GetMenuItemCount(nMenuHandle)
FOR i = 1 TO nCnt - 1
STORE SPACE(50) TO cBuffer
nPos = GetMenuItemID(nMenuHandle, i)
? "nPos = " + ALLTRIM(STR(nPos))
GetMenuString(nMenuHandle, nPos, @cBuffer, LEN(cBuffer)+1, MF_BYCOMMAND)
cBuffer = ALLTRIM(STRTRAN(cBuffer, CHR(0), ""))
?? ", cBuffer = " + cBuffer
NEXT
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only