Autor Beitrag
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Mi 28.08.02 13:21 
hi,
2 fragen :
1.
wie kann ich einen Rollover effekt für ein einfaches label erstellen?
2.
wie kann ich wenn der user auf eine Taste drückt ( z.B. die [->] Taste), dass sich auch ein Objekt (z.B. ein Bild) um ca.10 pixel nach links bewegt?
DANKE !!
Blacked
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Fr 30.08.02 12:06 
Hi,

Also das Label hat bei den Eigenschaften ja ein OnMouseMove damit solltest du das mit dem MouseOver bequem hinbekommen und das mit dem verschieben des Label kannst du einfach mit dem OnKeyPress bei der Form machen.

Ein beispiel kann ich dir gerne zukommen lassen.

mfg Blacked
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Fr 30.08.02 14:44 
Hallo,

du musst dir eine eigene Label-Komponente anleiten und die Windowsnachrichten für MouseEnter und Mouse Leave abfangen.

So sollte das dann aussehen:
ausblenden volle Höhe 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:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
type
  toMouseOverLabel = class(TCustomLabel)
  private
    FOnMouseEnter : tNotifyEvent; // Windows Ereignis Maus bewegt sich in die Zelle
    FOnMouseLeave : tNotifyEvent; // Windows Ereignis Maus verlässt die Zelle
    procedure CMMouseEnter(var Message : tMessage); message CM_MouseEnter; // Behandlungsrotine für Maus enter
    procedure CMMouseLeave(var Message : tMessage); message CM_MouseLeave; // Behandlungsrotine für Maus Leave
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
  published
    property OnMouseEnter : tNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave : tNotifyEvent read FOnMouseLeave write FOnMouseLeave;
    // Standart Propertys
    property Align;
    property Alignment;
    property Anchors;
    property AutoSize;
    property BiDiMode;
    property Caption;
    property Color;
    property Constraints;
    property DragCursor;
    property DragKind;
    property DragMode;
    property Enabled;
    property FocusControl;
    property Font;
    property ParentBiDiMode;
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowAccelChar;
    property ShowHint;
    property Transparent;
    property Layout;
    property Visible;
    property WordWrap;
    property OnClick;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDock;
    property OnStartDrag;
  end;

implementation

{ toMouseOverLabel }

procedure toMouseOverLabel.CMMouseEnter(var Message: tMessage);
begin
  IF Assigned(OnMouseEnter) THEN // Wenn eine Ereignisbehandlungsrotine Definiert ist...
    OnMouseEnter(Self); // ...führe diese aus.
end;

procedure toMouseOverLabel.CMMouseLeave(var Message: tMessage);
begin
  IF Assigned(OnMouseLeave) THEN // Wenn eine Ereignisbehandlungsrotine Definiert ist...
    OnMouseLeave(Self); // ...führe diese aus.
end;


Das kannst du dir übrigens auch hier runterladen.

Gruß
Klabautermann