Autor Beitrag
Lemon
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Mo 22.03.04 21:23 
hallo,

habe hier im forum den quelltext fuer ein image mit over und out event vom timage gefunden.
geht bei mir irgendwie nicht:
fehler: irgendwas mit external und forward deklaration stimmt nicht.
hier mal ein teil des quelltexts:
ausblenden volle Höhe 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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
unit Unit1; 

interface 

uses 
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 
  Dialogs, StdCtrls, ExtCtrls; 

type 
  TOverImage = class(TImage) 
  private 
    procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER; 
    procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE; 
  end

  TForm1 = class(TForm) 
    Button1: TButton; 
    Image1: TImage; 
    procedure FormCreate(Sender: TObject); 
    procedure FormDestroy(Sender: TObject); 
  private 
    { Private-Deklarationen } 
    MyImg: TOverImage; 
  public 
    { Public-Deklarationen } 
  end

var 
  Form1: TForm1; 

implementation 

{$R *.dfm}             

...


vielen dank schon mal im vorraus!!!
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Di 23.03.04 15:59 
also mein problem hat sich mitlerwelie erledigt.
aber noch ne frage.
was wird als sender im onclick event uebergeben? timage oder toverimage.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 23.03.04 17:41 
Keins von beidem... TObject.. :roll: ;)
Ne, im Ernst... Im Normalfall wird immer das Objekt übergeben, das das Ereginis auslöst, dh. wenn das Objekt ein TOverImage ist, dann ist auch Sender ein TOverImage-Objekt.. du musst es nur noch entsprechend casten...!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Di 23.03.04 20:50 
ok, gut.
noch ne frage.
koennen die oben genannten prozeduren auch mehr parameter enthalten???
wenn ja, wie??
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 23.03.04 22:22 
Wie meinst du das..? :?

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Mi 24.03.04 17:05 
naja, dass z.b. auch der sender, d.h der name des ausloesenden objektes mituebergeben wird.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 24.03.04 22:25 
Der übergebene Sender ist eine Referenz auf das auslösende Objekt..! Dh. du hast alles was du von diesem Objekt brauchst..! Erklär einfach mal auf was du hinauswillst / was du vorhast...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Mi 24.03.04 22:50 
also,
ich will mehrere toverimage einfuegen, aber die sollen natuerlich alle andere images beinhalten.
jetzt will ich ueber den sender feststellen, welches overimage ueberfahren wurde, um dann das richtige image auszuwahlen!
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 24.03.04 22:58 
Ein einfacher Typecast nach TOverImage reicht bereits und du hast vollen Zugriff auf das Objekt das das Ereignis ausgelöst hat :)
ausblenden Delphi-Quelltext
1:
TOverImage(Sender)					

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Do 25.03.04 14:23 
sorry, aber soviel ahnung hab' ich von delphi nicht.
wo muss das mit dem typecast hin und wie geht das genau???
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Do 25.03.04 15:10 
Wenn du nur feststellen willst von welchem image das event kommt, dann brauchst du nichtmal einen typecast:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Procedure TForm1.OnOverOverImage1(sender:Tobject);
begin
  if Sender = OverImage1 then
  begin
     showMessage(TOverImage(sender).name); // bspl. für typeCast
  end 
  else if sender = voerImage2 then
  begin
    Beep;
  end;  // etc


end;


so nach dem chema!

_________________
mfg.
mâximôv
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Do 25.03.04 16:35 
das problem bei mir ist jetzt, dass ich immernoch keinen sender habe.
ich habe die toverimage ja dynamisch waehrend der laufzeit erstellt und dann kann ich ja so ne prozedur nicht erstellen!
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 25.03.04 16:39 
Lemon hat folgendes geschrieben:
das problem bei mir ist jetzt, dass ich immernoch keinen sender habe.
ich habe die toverimage ja dynamisch waehrend der laufzeit erstellt und dann kann ich ja so ne prozedur nicht erstellen!

Doch, auch das geht.. du musst nur eine Methode mit den entsprechenden Parametern erstellen und kannst diese dann zur laufzeit zuweisen... es gibt dazu schon genug Threads hier um Forum.. einfach mal suchen.. zb nach Suche in: Delphi-Forum, Delphi-Library LAUFZEIT EREIGNIS

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Fr 26.03.04 15:04 
so, das geht jetzt alles, aber ich hab' trotzdem noch ne frage.
weiter oben fragte ich, welcher objekttyp als sender uebergeben wird: timage oder toverimage

ich habe folgende if anweisung

ausblenden Delphi-Quelltext
1:
if (Sender is TImage) then ...					


und diese wird auch ausgefuehrt, wenn der sender ein toverimage ist. wieso???

Moderiert von user profile iconMotzi: BBCode aktiviert
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Fr 26.03.04 15:07 
Weil TOverimage ja auch TImage ist. Delphi liest es ungefähr so und du kannst es auch so schreiben:
ausblenden Delphi-Quelltext
1:
if Sender.inheritsFrom(TImage) then ...					

_________________
mfg.
mâximôv
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Fr 26.03.04 15:12 
alla hopp.

danke fuer die viele geduld, die ihr mit mir hattet!!!!!