Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>trackpopupmenu()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
TrackPopupMenu()
Display and activate a floating pop-up menu
------------------------------------------------------------------------------

Syntax
TrackPopupMenu( <aMenu>, [ <nFlags> ] , <nX>, <nY>, [ <nReserved> ] ,
               [ <hWnd> ] , [ <aRect> ] )   -->   lSuccess

Arguments
<aMenu> is the array describing the menu.  This array must
have been created originally by CreatePopupMenu().

<nFlags> is an optional numeric used to determine the position
of the menu and which mouse button affects the menu (use the
TPM_* values in WINDOWS.CH).  The default is TPM_LEFTALIGN +
TPM_LEFTBUTTON.

<nX>, <nY> specify the screen co-ordinates of the menu.

<nReserved> is an optional numeric value, reserved for future
use.  If specified, it should be zero (0).

<hWnd> is the handle to the window that owns the pop-up menu.
It defaults to the window that SelectWindow() returns.

<aRect> is an optional array specifying the screen co-ordinates
of a rectangle.  The user can click anywhere within this
rectangle without dismissing the pop-up menu.  The default is
the area of the floating pop-up menu.

Returns
If successful, logical TRUE (.T.) is returned, otherwise FALSE
(.F.) is returned.

Description
This function displays a floating pop-up menu on the screen,
tracks mouse movements, and allows the user to select an item
or dismiss the menu.

The menu must have been created by CreatePopupMenu(), and set
up using AppendMenu().

Example
hPopupMenu = CreatePopupMenu()
AppendMenu( hPopupMenu, "cut", MF_ENABLED + MF_STRING,      ;
            "Cu&t", { | c | DoCutCopy( c ) } )
AppendMenu( hPopupMenu, "copy", MF_ENABLED + MF_STRING,     ;
            "&Copy", { | c | DoCutCopy( c ) } )
AppendMenu( hPopupMenu, "paste", MF_ENABLED + MF_STRING,    ;
            "&Paste", { | | DoPaste() } )
AppendMenu( hPopupMenu, "", MF_SEPARATOR )
AppendMenu( hPopupMenu, "find", MF_GRAYED + MF_STRING,      ;
            "&Find", { | c | qout( c ) } )
AppendMenu( hPopupMenu, "replace", MF_GRAYED + MF_STRING,   ;
            "&Replace", { | c | qout( c ) } )
hPopup2Menu = CreatePopupMenu()
AppendMenu( hPopupMenu, "submenu", MF_ENABLED + MF_POPUP,   ;
            "&Submenu", hPopup2Menu)
AppendMenu( hPopup2Menu, "cut2", MF_ENABLED + MF_STRING,    ;
            "Cu&t", { | c | DoCutCopy( c ) } )
AppendMenu( hPopup2Menu, "copy2", MF_ENABLED + MF_STRING,   ;
            "&Copy", { | c | DoCutCopy( c ) } )
AppendMenu( hPopup2Menu, "paste2", MF_ENABLED + MF_STRING,  ;
            "&Paste", { | | DoPaste() } )
AppendMenu( hPopup2Menu, "", MF_SEPARATOR )
AppendMenu( hPopup2Menu, "find2", MF_GRAYED + MF_STRING,    ;
            "&Find", { | c | qout( c ) } )
AppendMenu( hPopup2Menu, "replace2", MF_GRAYED + MF_STRING, ;
            "&Replace", { | c | qout( c ) } )
do case
case nEvent == EVENT_RCLICK
     // display and activate a floating menu at the position
of the right click
     aPt = { _LastLolParam(), _LastHilParam() }
     ClientToScreen( hWnd, aPt )
     TrackPopupMenu( hPopupMenu,  , aPt[1], aPt[2],  , hWnd )
// . . .
endcase
DestroyMenu( hPopup2Menu )
DestroyMenu( hPopupMenu )


See Also: ClientToScreen() CreatePopupMenu() DestroyMenu()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson