Here is the code for this task to complete in Borland Delphi.
case PopupMenu1.Items.Count ofBitBtn1 is the button to be pressed, PopupMenu1 contains the menu items to pop up. If there's no menu items, a message is shown, if only one menu item, it is launched by default, if more - popup menu appears.
0 : // no menu items
begin
MessageDlg( _( 'No items to show' ), mtInformation, [mbOK], 0 );
exit;
end;
1 : // only one item - execute
PopupMenu1.Items[0].Click;
else
with BitBtn1, ClientToScreen( Point( 0, Height ) ) do
PopupMenu1.Popup( X, Y );
end;
No comments:
Post a Comment