Local menus are used to make it easy to use the mouse to display and choose from a menu. Popup menus are usually displayed in response to a right-button click. This is a by product of declaring the popup menu for the listbox in the Object Inspector. While the popup is displayed, the right-button click does not make a selection so you must first press the left button to select then press the right button to display the menu. You will add the right-button select to the standard popup menu display.
| The first step in creating a popup menu is to select the popup component |
|
void __fastcall TSDIAppForm::ListBox1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if(Button==mbRight) // Check to see if right button pressed
{
tagPOINT t;
t.x = X;
t.y = Y;
ListBox1->ItemIndex=ListBox1->ItemAtPos(t,true);
//Sets the index of item.
// If nothing selected deselects
}
} |
|
To get a complete example of the right-button listbox click here .