Autor Beitrag
tommythe1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 14:55 
Hallo!

Ich möchte 120 Images erzeugen lassen darein ein Bild laden und bei Klick auf irgendeins der Images soll es unsichtbar werden!
Die Imeges habe ich erzuegt und angeordent etc, bild geladen soweit ok

Jetzt kommt das Problem:

Wie weise ich jedem das OnClick Ereignis zu das es bei Klick reagiert??

Ich hoffe ihr könnt mir helfen![highlight] :?: :?:
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 06.11.06 14:59 
Einfach <image>.onClick := <Methode>;
z.B. Images[100].onClick := Form1.imageonclick;

_________________
Markus Kinzler.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 06.11.06 14:59 
Moin!

Markier alle Images in der IDE und mach einen Doppelklick auf dem OnClick-Ereignis im Objektinspektor, dann wird das Ereignis für alle Images eingetragen.

Es wird dann allerdings das gleiche Ereignis für alle Images verwendet (was ja auch sinnvoll ist). Wie man dann trotzdem "sinnvoll" damit umgehen kann, kannst du hier sehen. ;)

cu
Narses

//EDIT: zu langsam... :|

_________________
There are 10 types of people - those who understand binary and those who don´t.
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 15:14 
user profile iconNarses hat folgendes geschrieben:


Markier alle Images in der IDE und mach einen Doppelklick auf dem OnClick-Ereignis im Objektinspektor, dann wird das Ereignis für alle Images eingetragen.



//EDIT: zu langsam... :|


Leider kann ich die Objekte nicht alle makieren, da sie während der Laufzeit erst erzeugt werden und somit vorher nichts zum makieren da ist!!
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 06.11.06 15:17 
Dann weiße deinen Images doch folgende Prozedur mit Hilfe einer Schleife zu, sofern du ein Array aus Imagen benutzt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.HideIt(Sender: TObject);
begin
 (TControl(Sender)).Hide;
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 06.11.06 15:23 
Moin!

Wenn du die Images sowieso dynamisch selbst anlegst, kannst du doch auch eine beliebige OnClick-Methode zuweisen... :?: :nixweiss: Wo ist das Problem? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 15:26 
user profile iconNarses hat folgendes geschrieben:
Moin!

Wenn du die Images sowieso dynamisch selbst anlegst, kannst du doch auch eine beliebige OnClick-Methode zuweisen... :?: :nixweiss: Wo ist das Problem? ;)

cu
Narses


Das Problem ist das ich 120 solche dynamisch erzeugten Objekte habe und ich dann für jedes eine eigene Procedure schreiben müsste und zuweisen. Wenn ich es immer der selben zuweise reagiert sie nur bei dem zuletzt erzeugten Element.
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 15:27 
user profile iconMarc. hat folgendes geschrieben:
Dann weiße deinen Images doch folgende Prozedur mit Hilfe einer Schleife zu, sofern du ein Array aus Imagen benutzt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.HideIt(Sender: TObject);
begin
 (TControl(Sender)).Hide;
end;


Ne ich benutze keine array also geht das schlecht
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 06.11.06 15:30 
Ich könnte mich jetzt wiederholen: www.delphi-forum.de/....php?p=398983#398983
Zitat:
Ne ich benutze keine array also geht das schlecht
Ich seh in diesem Code keinen Array.

Im Paramter sender erhältst du eine Referenz auf das auslösende Objekt.

_________________
Markus Kinzler.
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 15:40 
user profile iconmkinzler hat folgendes geschrieben:
Ich könnte mich jetzt wiederholen: www.delphi-forum.de/....php?p=398983#398983
Zitat:
Ne ich benutze keine array also geht das schlecht
Ich seh in diesem Code keinen Array.

Im Paramter sender erhältst du eine Referenz auf das auslösende Objekt.


Versteh zur zeit nur bahnhof!!!!!!!
Was los was soll ich machen??
Bitte mal für ganz dumme
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 06.11.06 15:47 
Zeig mal den Code der dynamischen Erzeugung

_________________
Markus Kinzler.
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 15:56 
user profile iconmkinzler hat folgendes geschrieben:
Zeig mal den Code der dynamischen Erzeugung
procedure


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
TMain.BilderErzeugen(Sender: TObject);
var i, j,b: Integer;
begin
  for j:= 0 to 1 do
    begin
      for i:= 0 to 9 do
        begin
          b:= i+j*10;
          imgMitarbeiter:= TMeinImage.Create(Main);
          imgMitarbeiter.Parent:= MAin;
          imgMitarbeiter.Picture.LoadFromFile('bild'+IntToStr(b)+'.bmp');
          imgMitarbeiter.Stretch:= TRUE;
          imgMitarbeiter.Index:= b;
          imgMitarbeiter.Top:= 1+110*j;
          imgMitarbeiter.Left:= 1+110*i;
          imgMitarbeiter.Show;

        end;
   end;
end;
[/delphi][list=a][*]
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 06.11.06 15:59 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
procedure TMain.ImageClick( Sender: TObject);
begin
   //Sender ist das Image das geklickt wurde
   (Sender as TImage).Hide; // versteckt geklicktes Image.
end;

procedure TMain.BilderErzeugen(Sender: TObject);
var i, j,b: Integer;
begin
  for j:= 0 to 1 do
    begin
      for i:= 0 to 9 do
        begin
          b:= i+j*10;
          imgMitarbeiter:= TMeinImage.Create(Main);
          imgMitarbeiter.Parent:= MAin;
          imgMitarbeiter.Picture.LoadFromFile('bild'+IntToStr(b)+'.bmp');
          imgMitarbeiter.Stretch:= TRUE;
          imgMitarbeiter.Index:= b;
          imgMitarbeiter.Top:= 1+110*j;
          imgMitarbeiter.Left:= 1+110*i;
          imgMitarbeiter.Show;
          imgMitarbeiter.onClick := ImageClick;
        end;
   end;
end;

_________________
Markus Kinzler.


Zuletzt bearbeitet von mkinzler am Mo 06.11.06 16:13, insgesamt 1-mal bearbeitet
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 16:03 
vielen dank werde ich probieren
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 16:10 
ja das klappt --> vielen dank

und wenn ich jetzt wieder bei klick auf ein anderes Objekt dieses das entsprechnde Image wieder sichbar wird
also das soll immer so im Wechsel erfolgen

das was sichtbar ist machjt das andere sichtbar und sich unsichtbar
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 06.11.06 16:15 
Zitat:
und wenn ich jetzt wieder bei klick auf ein anderes Objekt dieses das entsprechnde Image wieder sichbar wird
also das soll immer so im Wechsel erfolgen

das was sichtbar ist machjt das andere sichtbar und sich unsichtbar
In diesem Fall mußt du dir global merken, welches Image du versteckt hast un dieses dann wieder anzeigen.

_________________
Markus Kinzler.
tommythe1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18

WinXP
Delphi 6 Personal
BeitragVerfasst: Mo 06.11.06 16:57 
user profile iconmkinzler hat folgendes geschrieben:
Zitat:
und wenn ich jetzt wieder bei klick auf ein anderes Objekt dieses das entsprechnde Image wieder sichbar wird
also das soll immer so im Wechsel erfolgen

das was sichtbar ist machjt das andere sichtbar und sich unsichtbar
In diesem Fall mußt du dir global merken, welches Image du versteckt hast un dieses dann wieder anzeigen.



Kannst das mal genauer erläutern
Schamese
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Windows 2008 Server
Delphi 5 Ent., C# (Visual Studio 2008)
BeitragVerfasst: Mo 06.11.06 17:11 
du Solltest eine Globale Variable anlegen:
ausblenden Delphi-Quelltext
1:
var HiddenImage: TImage;					

un in der HideIt-Prozedur Folgendes noch Hinzufügen:
ausblenden Delphi-Quelltext
1:
HiddenImage.Show;					


Gruß, Christian.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 06.11.06 18:20 
Eine Ergänzung: Da HiddenImage am Anfang nil ist, musst du noch ne if-Abfrage machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if HiddenImage<>nil then HiddenImage.Show;

//oder

if Assigned(HiddenImage) then HiddenImage.Show;

(Assigned macht intern auch nichts anderes als die erste Version)

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.