Brug evt. top og left: procedure TForm1.Button1Click(Sender: TObject); var i : integer; begin i := 0; repeat Form1.top := i * 25; Form1.left := i * 25; i := i + 1; form1.refresh; MessageDlg('Tryk på OK', mtInformation,[mbOk], 0); until i > 5; end; Mvh Pjotre
1) Kopier Uniten der afslutter det her svar. 2) Overe i din mainUnit skla du uses UnitMoveForm; 3) Ret TForm1 = class(TForm) til TForm1 = class(TMovebleForm)
procedure TMovebleForm.DoMoveTimer(Sender: TObject); begin if (Left + Width >= Screen.Width) or (Top + Height >= Screen.Height) or (Top <= 0) or (Left <= 0) then begin if (Top <= 0) and (Left <= 0) then repeat Direction := Random(360); until (Direction > 270) else if (Top <= 0) and (Left + Width >= Screen.Width) then repeat Direction := Random(360); until (Direction > 180) and (Direction < 270) else if (Top + Height >= Screen.Height) and (Left + Width >= Screen.Width) then repeat Direction := Random(360); until (Direction > 90) and (Direction < 180) else if (Top + Height >= Screen.Height) and (Left < 0) then repeat Direction := Random(360); until (Direction < 90) else if (Top <= 0) then repeat Direction := Random(360); until (Direction > 180) else if (Left <= 0) then repeat Direction := Random(360); until (Direction < 90) or (Direction > 270) else if (Top + Height >= Screen.Height) then repeat Direction := Random(360); until (Direction < 180) else if (Left + Width >= Screen.Width) then repeat Direction := Random(360); until (Direction > 90) and (Direction < 270); end; Move(1); end;
procedure TMovebleForm.doDestroy; begin FreeAndNil(MoveTimer); inherited; end;
function TMovebleForm.GetTimerEnabled: Boolean; begin Result := MoveTimer.Enabled; end;
procedure TMovebleForm.SetTimerEnabled(const Value: Boolean); begin MoveTimer.Enabled := Value; end;
function TMovebleForm.GetInterval: Cardinal; begin Result := MoveTimer.Interval; end;
procedure TMovebleForm.SetInterval(const Value: Cardinal); begin MoveTimer.Interval := Value; end;
Stoney >> Tsk tsk tsk. Har du helt glemt din vector matematik ?
Jens B
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.