Hello,
There are many possible solutions to the feature you want to implement. Here is one of the more easier ones (besides buying a set of third party components that have that functionality ;P):
Ingredients
2 x TSpeedButton
1 x TPopupMenu component
n x TMenuItem (for your different 'button' options)
Recipe
Place the 2 buttons side-by-side. Make the second button just wide enough to hold the down arrow image. Depending on how you want to display the 'selected' event/action for the button, you can fiddle around with the size of the first button. On your second button click event, you will to do something like:
procedure SecondButtonClickEvent(Sender : TObject);
begin
MyPopupMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
end;
In your menu item events, make sure you have a line of code that goes something like this:
procedure SetupMyFirstButton(SelectedItem : TMenuItem);
begin
FirstSpeedButton.OnClick := SelectedItem.OnClick;
end;
procedure SomeMenuItemOnClickEvent(Sender : TObject);
begin
if (Sender is TMenuItem) then
begin
SetupMyFirstButton(TMenuItem(Sender));
end;
end;
By doing this, you can make sure you have your 'last selected' menu item is always linked to the first button. In addition, you can assign a 'default' event to the first button when you initialise the form that you are building this on like so:
SetupMyFirstButton(TheMenuItemYouWantToBeDefault);
DISCLAIMER: This is by no means the 'most correct' way of doing this. I take no responsiblity if this code, for some or other reason, causes the lifecycle of the common sea cucumber to become irrevocably broken... :-D