Autor Beitrag
mike1337
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mi 27.10.04 17:14 
Hi ich bin neu im Formum und habe ein Problem :(

Ich will grade ein Programm schreiben der ein button nein hat, dieser button soll wenn ich über ihn mit der mouse fahre wegspringen und da liegt das problem, kann mir da jemand helfen? :(
Also es würde auch reichen das wenn man auf den button klickt das er dann wegspringt auf einen bestimmten punkt oder auf einen zufälligen!

Würde mich sehr freuen wenn ihr mir helfen könnt :)

danke im voraus ;)

mfg mike
MoD17
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 36

WinXP, RedHat 9
D7 pers, D6 pers
BeitragVerfasst: Mi 27.10.04 17:25 
hi
mit draufklicken ists sehr einfach:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
  button1.Left:=random(form1.Width);
  button1.top:=random(form1.height);
end;


der button springt an einen zufälligen punkt auf der form ( würde man z.b. random(100) schreiben gibts ne zufällige zahl zwischen 0 und 99 )
vielleicht musst du auch
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
  button1.Left:=random(form1.Width-button1.width);
  button1.top:=random(form1.height-button1.height);
end;

schreiben, um scrollbars zu vermeiden, musst mal n bisschen experimentieren

gruss
MoD17
mike1337 Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mi 27.10.04 17:26 
vielen dank ich teste mal :)
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Mi 27.10.04 17:39 
du musst aber wenn du das mit dem Überfahren machen möchtest das Button1.mousemove procedure verwenden!!
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 27.10.04 18:31 
LoL coole idee !

find ich lustig !

:D
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 27.10.04 19:11 
Is ja witzig. Genau das gleiche habe ich heute in einem meiner Programm eingebaut.
Wenn die Form ein Menü hat, sollte man aber statt Form1.width lieber Form1.ClientWidth benutzen. Entsprechendes gilt auch für Height.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 27.10.04 19:32 
Naja, fehlt nur noch, dass ihr OnCloseQuery CanClose auf False setzt unde den Task-Manager blockt, bzw. sofort bei einem Startversuch killt (oder jeden Aufruf der Toolapi auf eurer Anwendung feindlich gesinnten Code prüft) ;-) Wenn ihr das fertig habt, könnt ihr ja nochmal Bescheid geben ;-)

Neben ClientWidth und ClientHeight müsst ihr aber auch noch die Größe des Buttons beachten.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Mi 27.10.04 19:53 
das onclosequery hab ich schon gemacht^^aba wie kann man denn den Taskmanager, den sollte man ja vlt. noch aufrufen können, aber wie kann man dann dort das beenden verhindern??
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 27.10.04 22:45 
Kroni hat folgendes geschrieben:
aba wie kann man denn den Taskmanager, den sollte man ja vlt. noch aufrufen können, aber wie kann man dann dort das beenden verhindern??

Neue Frage - neues Topic!

Gruß
Tino
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 28.10.04 07:32 
BenBE hat folgendes geschrieben:
Neben ClientWidth und ClientHeight müsst ihr aber auch noch die Größe des Buttons beachten.

Steht doch so im Source von MoD17 :gruebel: :?!?:
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 28.10.04 14:54 
Warum lieber ClientWidth/height ?

:gruebel:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 28.10.04 14:56 
Wenn in der Form z.B. ein Menü ist, ist der Client-Bereich (nutzbare Fläche der Form) kleiner als die Form.
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: Do 28.10.04 15:18 
Ich teste das später mal nicht - das Ding startet sich noch selber nach dem Download
ohne das man es stoppen kann, was? :twisted: