ActnMgrBar (C++)
Description
This application requires a TPopupActionBar component already on the form. The application creates an action manager component and assigns an image list to some of its properties. Then, the popup action bar is customized and assigned to the form's PopupMenu property. Right click the form to show the popup menu.
Code
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// display an information message
ShowMessage("Right click the form to display the customized popup menu");
// create an image list
TImageList *images = new TImageList(32, 32);
Graphics::TBitmap *image = new Graphics::TBitmap;
image->Height = 32;
image->Width = 32;
image->Canvas->Font->Name = "Times New Roman";
image->Canvas->Font->Size = 22;
image->Canvas->TextOut((image->Width - image->Canvas->TextWidth('1')) / 2, 0, '1');
images->Add(image, NULL);
delete image;
// create a custom action manager and assign the image list to some of its properties
TCustomActionManager *actionManager = new TCustomActionManager(Form1);
actionManager->DisabledImages = images;
actionManager->LargeDisabledImages = images;
actionManager->LargeImages = images;
// add some items to the popup menu associated with the popup action bar
TMenuItem *option1 = new TMenuItem(Form1);
option1->Caption = "New";
PopupActionBar1->Items->Add(option1);
TMenuItem *option2 = new TMenuItem(Form1);
option2->Caption = "Save";
PopupActionBar1->Items->Add(option2);
// let the popup action bar be the form"s popup menu
Form1->PopupMenu = PopupActionBar1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PopupActionBar1GetControlClass(TCustomActionBar *Sender, TActionClient *AnItem,
TCustomActionControlClass &ControlClass)
{
// use a drop down button for each menu item in the popup action bar
ControlClass = GetTypeData(__typeinfo(TXPStyleDropDownBtn))->ClassType;
}
//---------------------------------------------------------------------------