Autor Beitrag
Supernova
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 108

WinXP
D7 Prof
BeitragVerfasst: Sa 10.01.04 22:12 
wie kann ich einen Mouseover effekt erstellen ??
ZB dass wenn ich über einen Text mit der maus fahre, dass der hintergrund dann gelb wird ??
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 11.01.04 07:30 
Was für eine Delphi Version. Ab D6: kuck dir mal die Ereignisse eines Labels im OI an. :roll:
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mo 12.01.04 16:54 
Hallo,

kann man auch "manuell" bei anderen Kompos machen: du musst eine Klasse ableiten und die Messages Suche in: Delphi-Forum, Delphi-Library CM_MOUSEENTER und Suche in: Delphi-Forum, Delphi-Library CM_MOUSELEAVE abfangen.

_________________
Life is a bad adventure, but the graphic is really good!
teebee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 109


D6 Prof
BeitragVerfasst: Di 13.01.04 11:58 
Alternativ kann man sich das Ableiten einer eigenen Klasse auch sparen und die besagten Messages direkt vom Formular abfangen lassen und je nach Sender reagieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
TForm1 = class(TForm)
...
  public
    { Public-Deklarationen }
    Procedure MouseEnter(Var Msg: TCMMOUSEENTER); message CM_MOUSEENTER;
    Procedure MouseLeave(Var Msg: TCMMOUSELEAVE); message CM_MOUSELEAVE;
end;

Procedure TForm1.MouseEnter(Var Msg: TCMMOUSEENTER);
Begin
 If ((Msg.Sender) is TLabel) Then ((Msg.Sender) as TLabel).Color := clYellow;
End;

Procedure TForm1.MouseLeave(Var Msg: TCMMOUSELEAVE);
Begin
 If ((Msg.Sender) is TLabel) Then ((Msg.Sender) as TLabel).Color := clBtnFace;
End;
Dazu braucht man natürlich noch die Nachrichtentypen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Type
  TCMMOUSEENTER = Record
    Msg : Cardinal;
    Unused : Integer;
    Sender : TControl;
    Result : Longint;
  End;
  TCMMOUSELEAVE = TCMMOUSEENTER;

Prinzipiell finde ich es aber schöner mit der eigenen Klasse, auch wenn man dann das Erzeugen und Positionieren selbst übernehmen muss (falls nicht als Komponente registriert).

Gruß, teebee
Supernova Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 108

WinXP
D7 Prof
BeitragVerfasst: Mo 09.02.04 19:06 
Die Lösung von Luckie funz net !!!!!!!!!!

_________________
Input - Output => Ganz Kaputt
*** MFG Supernova ***
Benedikt
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 09.02.04 21:08 
Hi,

ich denke Luckie meint das so:

Im OnMouseEnter vom Label setzt du z.B. den Hintergrund Gelb, im OnMouseLeave wieder normal.
Folgendes kleines Beispiel realisiert einen Hovereffekt mit Unterstreichung bei einem Label:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure Tform1.Label1MouseEnter(Sender: TObject);
begin
        Label1.Font.Style:=[fsUnderline];
end;

procedure Tform1.Label1MouseLeave(Sender: TObject);
begin
        Label1.Font.Style:=[];
end;