Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TFormInstr = record
- Panel: TPanel;
- Control: TComboBox;
- Elements: array of TComboBox;
- end;
- var
- frm: TForm;
- addbtn, storeBtn: TButton;
- instr: array of TFormInstr;
- const
- CoreInstr = ['Withdraw', 'Deposit', 'Use', 'Cast'];
- MiscInstr = ['Object 1', 'Item 1', 'Item 2', 'Button 1'];
- function NewFormInstr(Parent: TComponent): TFormInstr;
- begin
- Result.Panel.Init(Parent);
- Result.Panel.SetParent(Parent);
- Result.Panel.SetAlign(alTop);
- Result.Panel.SetBevelOuter(bvNone);
- Result.Control.Init(Result.Panel);
- Result.Control.SetParent(Result.Panel);
- Result.Control.SetAlign(alRight);
- Result.Control.SetWidth(frm.GetWidth div 3);
- Result.Control.SetReadOnly(True);
- Instr += Result;
- end;
- function TFormInstr.NewCombo(): TComboBox;
- begin
- Result.Init(Self.Panel);
- Result.SetParent(Self.Panel);
- Result.SetAlign(alRight);
- Result.SetWidth(frm.GetWidth div 3);
- Result.SetReadOnly(True);
- Self.Elements += Result;
- end;
- function CreatePanel(Parent: TComponent): TFormInstr;
- var
- combo: TComboBox;
- i: Int32;
- begin
- Result := NewFormInstr(Parent);
- with Result.Control.GetItems() do
- for i:=0 to High(CoreInstr) do
- Add(CoreInstr[i]);
- with Result.NewCombo().GetItems() do
- for i:=0 to High(MiscInstr) do
- Add(MiscInstr[i]);
- with Result.NewCombo().GetItems() do
- for i:=0 to High(MiscInstr) do
- Add(MiscInstr[i]);
- Result.Panel.SetHeight(Result.Control.GetHeight());
- end;
- procedure Add(Self, Sender: TObject);
- begin
- CreatePanel(frm);
- end;
- procedure test;
- begin
- frm.init(nil);
- storeBtn.Init(frm);
- storeBtn.SetCaption('Save');
- storeBtn.setParent(frm);
- storeBtn.setAlign(alTop);
- storeBtn.setOnClick(@add);
- addBtn.Init(frm);
- addBtn.SetCaption('New instruction');
- addBtn.setParent(frm);
- addBtn.setAlign(alTop);
- addBtn.setOnClick(@add);
- createPanel(frm);
- frm.ShowModal;
- end;
- begin
- Sync(@test);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement