Autor Beitrag
GR-Thunderstorm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Mi 31.05.06 10:57 
Ich will mit Hilfe einer IF-Funktion überprüfen, ob mein Bild innerhalb eines bestimmten Bereichs liegt.
Es funktioniert ja soweit, aber nur, wenn das Shape innerhalb des linken oberen Form-Viertels liegt. Wenn ich es z.B. unten rechts in die Ecke schiebe funktioniert nichts mehr... :(

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin

case key of
'e': begin
if (image1.left in [shape1.Left..shape1.left+shape1.Width]) and (cha.Top in [shape1.Top..shape1.Top+shape1.Height]) then
shape2.visible:=not shape2.visible;
end;
end;
end;
end;


Ich sitze grade in der Schule und wir haben hier kein ZIP oder RAR, drum muss ich die beiden .EXE leider so anhängen (falls sie sich einer angucken will - is aber nix besonderes).
Beide haben exakt den selben (den oben genannten) Quellcode, nur dass das Shape1 an einer anderen Position ist.
Bewegen könnt ihr das image1 mit AWSD.
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von GR-Thunderstorm am Mi 31.05.06 11:07, insgesamt 1-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 31.05.06 11:03 
ausblenden Delphi-Quelltext
1:
2:
if (image1.left in [shape1.Left..shape1.left+shape1.Width]) and (cha.Top in [shape1.Top..shape1.Top+shape1.Height]) then   
shape2.visible:=not shape2.visible;

Was ist Cha? Müsste da nicht auch image1 stehen?

_________________
We are, we were and will not be.
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Mi 31.05.06 11:12 
oops ja... ich nenn die ganzen Sachen hier im Forum immer wieder um, damit jeder weiß was was ist.

cha = image1 (steht für character)


ausblenden Delphi-Quelltext
1:
2:
if (image1.left in [shape1.Left..shape1.left+shape1.Width]) and (image1.Top in [shape1.Top..shape1.Top+shape1.Height]) then     
shape2.visible:=not shape2.visible;


So ist es richtig...
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Mi 31.05.06 11:19 
Hi,
das Shape soll, wenn die Figur auf dem Shape ist, sichtbar werden, wenn es unsichtbar ist und unsichtbar, wenn es sichtbar ist?
Ich will dich nicht beunruhigen oder so, aber bei mir funktioniers bei beiden files nicht. :nixweiss:

Gruss
Daniel
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mi 31.05.06 11:39 
user profile iconGR-Thunderstorm hat folgendes geschrieben:
oops ja... cha = image1 (steht für character)

[OT]Und warum heisst das dann nicht auch 'Character'? [/OT]

_________________
Na denn, dann. Bis dann, denn.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mi 31.05.06 11:55 
[ot]weil man dann mehr tippen muss? ^^ Ich kanns gut verstehen.[/ot]

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Mi 31.05.06 19:40 
user profile iconDanny87 hat folgendes geschrieben:
Hi,
das Shape soll, wenn die Figur auf dem Shape ist, sichtbar werden, wenn es unsichtbar ist und unsichtbar, wenn es sichtbar ist?
Ich will dich nicht beunruhigen oder so, aber bei mir funktioniers bei beiden files nicht. :nixweiss:

Gruss
Daniel


Hast du auch 'e' gedrückt?
Bei mir gehts eben wie gesagt nur bei der "oben links.exe"...
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Do 01.06.06 09:29 
Ich hab das jetzt nochmal in Delphi nachgemacht, dann könnt ihr den Quellcode direkt betrachten.
Einloggen, um Attachments anzusehen!
raiguen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 374

WIN 2000prof, WIN XP prof
D7EP, MSSQL, ABSDB
BeitragVerfasst: Do 01.06.06 11:49 
Moin :)

Sind die Werte für Shape1.Top bzw Shape1.Left grösser 255 gibt es Probleme, da anscheinend der  in [Wert1..Wert2] nur für den Wertebereich 0..255 zulässig ist.
Mit anderen Worten: Code etwas umbauen, auch wenn's umständlich sein mag, aber das funzt auf jeden Fall:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TFormShapes.FormKeyPress(Sender: TObject; var Key: Char);
begin
   case Key of
     'a' : Image1.Left := Image1.Left -5;
     'w' : Image1.Top := Image1.Top -5;
     's' : Image1.Top := Image1.Top +5;
     'd' : Image1.Left := Image1.Left +5;
     'e' : if (Image1.Top >= Shape3.Top)  and
              (Image1.Top <= (Shape3.Top+Shape3.Height)) and
              (Image1.Left >= Shape3.Left) and 
              (Image1.Left <= (Shape3.Left+Shape3.Width)) then
             Shape2.Visible:=  not Shape2.Visible;               
   end;
end;
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Fr 02.06.06 11:25 
Dass das nur bis 255 geht macht mir nen ziemlichen Strich durch meine Vorüberlegungen..
Hatte gehofft den Quellcode möglichst klein zu halten und derartig viele Vergleiche für eine einzige Sache zu vermeiden aber wenns nich anders geht.. :(
Trotzdem danke!
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Sa 03.06.06 11:54 
Ich hab das jetzt auf folgende Weise gelöst:

ausblenden Delphi-Quelltext
1:
if (image1.left - shape1.Left in [1..shape1.width]) and (image1.Top - shape1.top in [1..shape1.height]) then					


So funktioniert es auch. :D
raiguen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 374

WIN 2000prof, WIN XP prof
D7EP, MSSQL, ABSDB
BeitragVerfasst: Sa 03.06.06 15:14 
user profile iconGR-Thunderstorm hat folgendes geschrieben:

So funktioniert es auch. :D

supi :zustimm: