Delphi - Duplicate tpanel and tbuttons on second form

In my main form, I have buttons containing TPanels that act as toolbars. I want to clone / copy this toolbar and buttons and their functionality into a second form.

Cloning the menu was simple using newmenu.merge (mainmenu). It was a great shortcut for duplicating Tmainmenu.

But I don’t understand how easy it is to duplicate my toolbar without having to manually assign events and save a timer to compare and track the buttons that are on and off compared to the real main menu in the main form. Depending on what the application does, the buttons on the main toolbar will be turned on and off at different times.

Any ideas here? Thanks for any suggestions or tips to make this easier.

+3
source share
3 answers
  • Duplication of controls

    In the form designer, select the panel and click Ctrl+Cto copy it and all its children to the clipboard. Go to the second form and click Ctrl+Vto paste.

    If you are still working on a design and want to keep it compatible between both forms, create TFrameand create your toolbar layout there. Then place an instance of this frame on both shapes. Changes in the design of the frame will be reflected in the forms.

    See Working with frames in the help.

  • Make sure that both sets of buttons are connected in series.

    . TActionList. . OnUpdate. Enabled. , Action . . .

    , "OnExecute". OnClick, OnClick OnExecute. , , OnClick .

    Caption Hint TAction, . , . .

    . .

  • TToolbar. .

    , , TActionManager TActionToolbar TActionMainMenuBar. . .

+4

? , OnUpdate TActionList, , . , .

ActionList, , ActionList datamodule, .

+1

You can use the ClipBoard object to copy your panel.

Clipboard.SetComponent (Panel1);
Clipboard.GetComponent (Form2, GroupBox1);

0
source

Source: https://habr.com/ru/post/1731622/


All Articles