Thanks Frank,
I used your example to create a cascading popup menu, and fixed the menu placement, so it always appears at the cursor position
Here it is in a replacement WndProc:
function WndProc( hWnd, wMsg, wParam, lparam ) as sys, callback
'==============================================================
'
static sys hdc,hMenu,hMenuPopup,hCursorMenu
static String txt,szAppName
static rect crect
static POINT pt
static PaintStruct Paintst
sys id,hInst
static sys hGraphic
'
select wMsg
'==========
case WM_CREATE
'
szAppName="Menu Demo_rightClick popup"
'
SetWindowText hwnd,szAppName
'
hMenu = CreateMenu
hMenuPopup = CreateMenu
hMenuPopup1= CreateMenu
AppendMenu hMenuPopup1, MF_STRING, 4011, "Red"
AppendMenu hMenuPopup1, MF_STRING, 4012, "Green"
AppendMenu hMenuPopup1, MF_STRING, 4013, "Blue"
AppendMenu hMenuPopup ,MF_POPUP, hMenuPopup1, "&Colors"
'
hMenuPopup1= CreateMenu
AppendMenu hMenuPopup1, MF_STRING, 4021, "Sphere"
AppendMenu hMenuPopup1, MF_STRING, 4022, "Cube"
AppendMenu hMenuPopup1, MF_STRING, 4023, "Cone"
AppendMenu hMenuPopup1, MF_STRING, 4024, "Cylinder"
AppendMenu hMenuPopup ,MF_POPUP, hMenuPopup1, "&Shapes"
AppendMenu hMenuPopup , MF_SEPARATOR, 0, null
AppendMenu hMenuPopup , MF_STRING, 4005, "E&xit"
'
AppendMenu hMenu, MF_POPUP, hMenuPopup, "&Objects"
'
CheckMenuItem hMenu,4022, MF_CHECKED
EnableMenuItem hMenu,4024, MF_DISABLED or MF_GRAYED
'
hCursorMenu = GetSubMenu(hMenu, 0)
case WM_COMMAND
if wparam = 4005 then 'Exit
SendMessage hwnd, WM_CLOSE, 0, 0
end if
case %WM_LBUTTONDOWN
GetCursorPos pt
ScreenToClient (hWnd, pt)
print "here lButton: " + str(pt.x) + "," + str(pt.y)
case %WM_RBUTTONDOWN
GetCursorPos pt
TrackPopupMenu(hCursorMenu, %TPM_LEFTALIGN OR %TPM_LEFTBUTTON OR %TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL) 'BYVAL %NULL
case WM_DESTROY
'
PostQuitMessage 0
case WM_KEYDOWN
Select wParam
Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
End Select
case else
'
function=DefWindowProc hWnd,wMsg,wParam,lParam
'
end select
end function
.