Autor Beitrag
Flamefire
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 16.01.07 15:08 
Ist es möglich, ein Element mithilfe der Position zu finden?
Am besten relative Koordinaten zu einem anderem.
Also etwas in der Richtung:
GetKomponente(x,y:Integer;Rel:TObject):TObject

ich will nur wissen, ob an einer bestimmten Stelle ein Label ist.
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Di 16.01.07 15:18 
Hi Flamefire,

So sollte es gehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function getComponent(left, top: Integer; Component: TControl): boolean;
begin
 if (left = Component.Left) and (top = Component.Top) then
  Result := True
 else
  Result := False;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 if getComponent(200, 100, Label1) = True then // Koordinaten an denen du suchen willst / Label, das du suchen willst
  ShowMessage('Ja')
 else
  ShowMessage('Nein');
end;


Gruß

Saubäär


Zuletzt bearbeitet von Saubäär am Di 16.01.07 15:47, insgesamt 1-mal bearbeitet
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 16.01.07 15:37 
hmm nee
hast mich falsch verstanden
ich will wissen, ob an position x,y sich ein objekt des types TLabel befindet, wobei x und y nicht unbedingt den Top und Left attribut entspricht
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Di 16.01.07 15:40 
Hi Flamefire,

welche Position meinst du denn wenn nicht die auf der Form???

Gruß

Saubäär
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.01.07 15:47 
ausblenden Delphi-Quelltext
1:
if FindDragTarget(Mouse.CursorPos, True) is TLabel then					

Meinst du sowas?

Geht nur in deinem eigenen Programm, sonst musst du Screen.ControlAt oder so ähnlich nehmenm dann kannst du aber is nicht mehr verwenden.
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 16.01.07 16:02 
also: gegeben: relative Position zu einer Kompo
gesucht: Typ der Kompo an dieser Position

Erklärung: In einem Groupbox werden Label erzeugt (Scrollbox.Parent:=Groupbox; Lab.Parent:=Scrollbox)
diese sind untereinander angeordnet (top:=lab.height*i)
jetzt werden welche gelöscht-->Lücken
suche alle Lücken: for i:=0 to 1000 do if(findcompo(1,lab.height*i+1) is TLabel) then ...;
Code stimmt nicht ganz aber so in der Art wird er...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.01.07 16:52 
Na dann ist ja das, was ich geschrieben habe, genau das richtige...
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 16.01.07 17:24 
ok...wie benutz ich die TPos?
is ja ne packed record...kann ich da einfach
var pos:Tpos
pos.y:=100;
machen?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.01.07 17:30 
TPos? TPoint nehme ich an, aber sonst: Ja.
Und diese TPoint-Variable kannst du dann statt der Mausposition übergeben.
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 16.01.07 17:47 
ja mein ich doch ^^
wie kriege ic jetzt die Position des Elements raus?
Ich brauch ja die Koordinaten auf dem Bildschirm, nicht im Form
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.01.07 19:19 
Jede Komponente hat die Methode ClientToScreen...
Die rechnet Koordinaten innerhalb der Komponente in Bildschirmkoordinaten um.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 16.01.07 19:27 
Moin!

Warum einfach, wenn´s auch kompliziert geht... :D

Du hast ja offensichtlich dynamische Labels, also vermutlich auch eine Liste mit Referenzen. Warum setzt du die Position in deinem Referenz-Array nicht einfach auf NIL und gehst nachher das Ref-Array durch, um die Labels neu anzuordnen? ;) Wozu das Gehampel mit Koordinatenumrechnen, Komponentenfinden, etcpp... :roll:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Di 16.01.07 20:59 
hmm weil ich zwar dynamische labels habe aber die referenzen nicht speicher...die sind mir auch wurst...^^
d.h. ich brauch danach nicht drauf zugreifen, der einzige zugriff ist eben der hier und events...und da krieg ich ja das label geliefert...

Habs aber gefunden:
ausblenden Delphi-Quelltext
1:
Pos:=ScreenToClient(ClientToScreen(myelement.ClientOrigin));					


Danke nochmal...
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Fr 19.01.07 11:11 
ok problem:
mit finddragtarget muss das form, wo sich die kompo befindet sichtbar und im vordergrund sein...
ich möchte aber auch von einem anderem form drauf zugreifen...
mein ansatz:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
      Form1.Top:=Form2.Top;
      Form1.Left:=Form2.Left;
      Form1.visible:=true;
      Form2.visible:=false;
      move(Form1,h,ct,ScreenToClient(ClientToScreen(mya.ClientOrigin)));
      Form2.visible:=true;
      Form1.visible:=false;

aber dadurch flackert das bild kurz (oder lange, je nachdem wie lange der pc braucht)
kann ich das umgehen?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 19.01.07 11:35 
user profile iconNarses hat folgendes geschrieben:
Warum setzt du die Position in deinem Referenz-Array nicht einfach auf NIL und gehst nachher das Ref-Array durch, um die Labels neu anzuordnen? ;)

_________________
There are 10 types of people - those who understand binary and those who don´t.
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Fr 19.01.07 13:12 
user profile iconNarses hat folgendes geschrieben:
Warum setzt du die Position in deinem Referenz-Array nicht einfach auf NIL und gehst nachher das Ref-Array durch, um die Labels neu anzuordnen? ;)

darum
Zitat:
hmm weil ich zwar dynamische labels habe aber die referenzen nicht speicher...die sind mir auch wurst...^^
d.h. ich brauch danach nicht drauf zugreifen, der einzige zugriff ist eben der hier und events...und da krieg ich ja das label geliefert...
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Fr 19.01.07 13:17 
Hallo!

Noch eine Möglichkeit für alle WinControl-Nachfahren: ControlAtPos.

Cu,
Udontknow
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 19.01.07 13:38 
Moin!

@user profile iconFlamefire: Naja, du stehst halt auf unnütz komplizierte Lösungen, OK. :D

Alternative: Du könntest den Labels einen entsprechenden Namen geben und per FindComponent wieder aufsuchen.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.