SCAR Code:
program New;
var
i, j, k, total: integer;
ax: TCOMPONENT;
TerminateBTN, DoSomethingBTN: TBUTTON;
pop: TPOPUPMENU;
popOpt1: TMenuItem;
DEAD: Boolean;
procedure updRes;
begin
GetApplication.MAINFORM.CAPTION := IntToStr(GetSelf.Height) + ' x ' + IntToStr(GetSelf.Width);
end;
procedure onRes(Sender: TObject);
var
vars: TVariantArray;
begin
ThreadSafeCall('updRes', vars);
end;
procedure doSomething(Sender: TObject);
begin
GetApplication.MESSAGEBOX('Something has been done!', 'CONGRATULATIONS!', 0);
end;
procedure Term(Sender: TObject);
begin
DEAD := true;
GetSelf.Invalidate;
end;
begin
ClearDebug;
GetSelf.ONRESIZE := @onRes;
total := GetApplication.MAINFORM.COMPONENTCOUNT;
writeln(inttostr(total));
for i := 0 to total - 1 do
begin
writeln(inttostr(i) + ': ' + GetApplication.MAINFORM.COMPONENTS[i].NAME);
if(GetApplication.MAINFORM.COMPONENTS[i].COMPONENTCOUNT > 0) then
for j := 0 to GetApplication.MAINFORM.COMPONENTS[i].COMPONENTCOUNT - 1 do
begin
writeln(' ' + GetApplication.MAINFORM.COMPONENTS[i].COMPONENTS[j].NAME);
// ax :=
end;
end;
DoSomethingBTN := TButton.Create(GetApplication.MAINFORM);//.FindComponent('Panel1'));
DoSomethingBTN.Parent := GetApplication.MAINFORM//.FindComponent('Panel1');
DoSomethingBTN.Left := 245;
DoSomethingBTN.Top := 1;
DoSomethingBTN.Width := 75;
DoSomethingBTN.Height := 20;
DoSomethingBTN.Caption := 'Do Something';
DoSomethingBTN.Visible := true;
DoSomethingBTN.ONCLICK := @DoSomething;
TerminateBTN := TButton.Create(GetApplication.MAINFORM);//.FindComponent('Panel1'));
TerminateBTN.Parent := GetApplication.MAINFORM//.FindComponent('Panel1');
TerminateBTN.Left := 201;
TerminateBTN.Top := 26;
TerminateBTN.Width := 121;
TerminateBTN.Height := 20;
TerminateBTN.Caption := 'Terminate';
TerminateBTN.Visible := true;
TerminateBTN.ONCLICK := @Term;
popOpt1 := TMenuItem.Create(GetApplication.MAINFORM);
popOpt1.Caption := 'Terminate';
popOpt1.ONCLICK := @Term;
pop := TPopUpMenu.Create(GetApplication.MAINFORM);
pop.ITEMS.ADD(popOpt1);
GetApplication.MAINFORM.POPUPMENU := pop;
repeat
wait(50);
GetApplication.PROCESSMESSAGES;
GetApplication.HANDLEMESSAGE;
until(DEAD)
try
pop.Free;
popOpt1.Free;
DoSomethingBTN.free;
TerminateBTN.Free;
except end;
end.
What it does:
- Extracts a list of all children components of the main SCAR form
- Adds two buttons and a right-click menu to SCAR
- Try resizing the window

SCAR 2.03
[Apparently I'm not allowed to link to SCAR...]