Hola chavarias.
Código Delphi
[-]
function IsButtonInsideForm(const FormR, ButtonR: TRect): Boolean;
begin
Result := PtInRect(FormR, Point(ButtonR.Left, ButtonR.Top) ) and
PtInRect(FormR, Point(ButtonR.Left+ButtonR.Right, ButtonR.Top+ButtonR.Bottom))
end;
Ejemplo de uso:
Código Delphi
[-]
procedure TForm1.btnCrearClick(Sender: TObject);
var
i: Integer;
R: TRect;
begin
Randomize;
for i := 1 to 100 do
begin
R.Left := Random(1000);
R.Top := Random(800);
R.Right := 70;
R.Bottom := 21;
if IsButtonInsideForm(ClientRect, R) then
with TButton.Create(self) do
begin
Name := 'Button' + IntToStr(i);
Left := R.Left;
Top := R.Top;
Width := R.Right;
Height := R.Bottom;
Parent := Self;
end;
end
end;
...
Y por favor, no olvides leer nuestra guía de estilo como te sugirió
Casimiro.
Saludos
