![]() |
OWLNext 7.0
Borland's Object Windows Library for the modern age
|
You can use TPopupMenu to create a pop-up menu that you can add to an existing menu structure or pop up anywhere in a window.
Like TSystemMenu, TPopupMenu is derived from TMenu and differs from it only in its constructor, which creates an empty pop-up menu. You can then add whatever menu items you like by using the TMenu::AppendMenu() function. After you have created a pop-up menu, you can use TMenu::TrackPopupMenu() to display it as a free-floating menu. TrackPopupMenu creates a pop-up menu at a particular location in your window. There are two forms of this function:
The following table describes the parameters:
Parameter | Explanation |
flags | Specifies the relative location of the pop-up menu. It can be one of the following values:
|
x and y | Specify the screen location of the pop-up menu. In the second form of TrackPopupMenu, point does the same thing, combining x and y into a single TPoint object. The menu is then created relative to this point, depending on the value of flags. |
rsvd | A reserved value that must be set to 0. |
wnd | The handle to the window that receives messages about the menu. |
rect | Defines the area that the user can click without dismissing the menu. |
The following example shows a window class that displays a pop-up menu in response to a right mouse button click: