
resimde görüldüğü gibi button 1 sağ saola gidecek mouse ile button 2 ise panalenin kenarlarına çarpacak ve button 1den sekecek ama ben bir türlü yapamadım
yardımcı olursanız sevinirim
Kod: Tümünü seç
panel2.Left:=Mouse.CursorPos.X-form1.Left-panel1.Left-round(panel2.Width/2);
Kod: Tümünü seç
procedure TForm1.Timer1Timer(Sender: TObject);
Const
{$j+}
x : Integer = 1;
y : Integer = 1;
{$j-}
Adim = 5;
begin
Shape1.Left := Shape1.Left + (x*Adim);
Shape1.Top := Shape1.Top + (y*Adim);
If Shape1.Left + (x*Adim) >= (Panel1.Width - Shape1.Width ) then x := x*(-1);
If Shape1.Top + (y*Adim) >= (Panel1.Height - Shape1.Height) then y := y*(-1);
If Shape1.Left + (x*Adim) <= 0 then x := x*(-1);
If Shape1.Top + (y*Adim) <= 0 then y := y*(-1);
end;
Kod: Tümünü seç
then x := x*(-1);
then y := y*(-1);
Çözümü paylaşsaydınızertaneker yazdı:yardıma gerek kalmadı olayı çözdüm arkadaşlar
Kod: Tümünü seç
implementation
{$R *.dfm}
var
ilkx,ilky,a:Integer;
Kod: Tümünü seç
procedure TForm1.img2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ilkx:=X;
ilky:=Y;
a:=1;
end;
Kod: Tümünü seç
procedure TForm1.img2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if a=1 then
begin
IF (img2.Left<0) then
BEGIN
img2.left:=0;
end;
IF (img2.Left>(Form1.ClientWidth-img2.Width)) then
begin
img2.Left:=(Form1.ClientWidth-img2.Width);
end;
IF (img2.TOP<0) then
begin
img2.Top:=0;
end;
IF img2.Top>(Form1.ClientHeight-img2.Height) then
BEGIN
img2.Top:=(Form1.ClientHeight-img2.Height);
end
else
begin
img2.top:=img2.top+Y-ilky;
img2.left:=img2.left+X-ilkx;
end;
end;
Kod: Tümünü seç
procedure ButtonClick(Sender: TObject);
begin
ShowMessage('Kendi yarattığın '+(Sender as TButton).Name+' adlı butona tıkladın.');
//..
end;
Kod: Tümünü seç
var
Btn: TButton;
begin
Btn:=TButton.Create(Owner);
//..
//..
Btn.OnClick:=ButtonClick;