Try this:
PHP Code:
POINT pt;
HWND hWnd /* (the hWnd of the window that contains the menu) */ ;
LONG lRes;

GetCursorPos(&pt);
lRes SendMessage(hWndWM_NCHITTESTNULLPOINTTOPOINTS(pt));

if(
lRes == HTMENU)
    
// woo 
Enjoy