Mega Code Archive

 
Categories / Delphi / VCL
 

EasyToolBarMenuEditor

Title: EasyToolBarMenuEditor Question: This article contains the unit EasyToolBarMenuEditor. This is used together with the EasyToolBar to get right click menus inside Delphi. NOTE! You need the other posts to be able to compile this components. You must disable the Compiled Resources (*.dcr) to compile this components. I'll send the dcr's to the admins and tell them to attach them. Answer: Unit EasyToolBarMenuEditor; Interface Uses {$IFDEF Ver140} DesignEditors, DesignIntf, {$ELSE} dsgnintf, {$ENDIF} Classes, Controls, Dialogs, EasyToolBar, EasyToolBarButtons ; Type TEasyToolBarEditor = class(TComponentEditor) Public Function GetVerbCount : Integer; override; Function GetVerb(Index : Integer) : String; override; Procedure ExecuteVerb(Index : Integer); override; End; Procedure Register; Implementation Uses Forms; Procedure Register; Begin RegisterComponentEditor(TEasyToolBar, TEasyToolBarEditor); End; (******************************************************************************) (******************************************************************************) (******************************************************************************) Function TEasyToolBarEditor.GetVerbCount : Integer; Begin Result := 3; End; Function TEasyToolBarEditor.GetVerb(Index : Integer) : String; Begin Case Index of 0 : Result := 'Add Button'; 1 : Result := 'About'; End; End; Procedure TEasyToolBarEditor.ExecuteVerb(Index : Integer); Var NewButton : TEasyToolBarButton; Begin Case Index of 0 : Begin NewButton := TEasyToolBarButton( Designer.CreateComponent(TEasyToolBarButton, Component, 0, 0, 24, 24) ); IF ((Component as TEasyToolBar).Direction = tbHorizontal) Then Begin NewButton.Align := alRight; NewButton.Align := alLeft; End Else Begin NewButton.Align := alBottom; NewButton.Align := alTop; End; Designer.Modified; End; 1 : MessageDLG('TEasyToolBar by EasyWare.org', mtInformation, [mbOk], 0); End; End; (******************************************************************************) (******************************************************************************) (******************************************************************************) End.