Autor Beitrag
OliverN_26
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 252

Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
BeitragVerfasst: Sa 26.01.08 22:39 
Hi!

Ist es irgendwie möglich, das wenn ich mit der Maus über einen BitBtn gehe, das Bild (Glyph) zu wechseln?

Danke
Leuchtturm
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 26.01.08 23:41 
Es gibt bei BitBtn eine Ereignis MouseOver oder so ähnlich, dort dann einfach ein neues Glyph laden

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
OliverN_26 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 252

Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
BeitragVerfasst: So 27.01.08 00:12 
Hi!

Nee ... leider nich. Das is ja genau das Problem. Wenns so einfach wär, wärs schön :-)
Ich find da kein Ereignis was einem MouseOver irgendwie nahe kommt ...
bflegel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP, Win 7, BS2000
D5
BeitragVerfasst: So 27.01.08 00:48 
Hi,

hier mal eine "quick and dirty" Variante:

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:
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
   in_button : boolean;
implementation

{$R *.DFM}

////////////////////////
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if in_button = true then
  begin
    bitbtn1.Glyph.LoadFromFile('c:\bitmap1.bmp');
    in_button := false;
  end;
label1.caption := inttostr(x) + ' ; ' + inttostr(y);
end;
////////////////////////
procedure TForm1.FormCreate(Sender: TObject);
begin
in_button := false;
end;
////////////////////////
procedure TForm1.BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if in_button = false then
  begin
        bitbtn1.Glyph.LoadFromFile('c:\bitmap2.bmp');
        in_button := true;
  end;
label2.caption := inttostr(x) + ' ; ' + inttostr(y);
end;

end.


Viel Spaß :)

bye
bflegel

// Edit:

Zur Erklärung:

Ich verwende eine globale Variable "in_button", in dem ich speichere, ob ich mich im Button befinde oder nicht. Je nach dem, ob ich "drin" bin oder nicht setze ich sie auf true oder false (und lade das entsprechende Bild). Die Variable frage ich in den entsprechenden OnMouseMove's ab, damit nicht bei jeder kleinen Mausbewegung das Bild neu geladen wird.

Die Ausgaben in Label1 bzw. Label2 waren nur zu Testzwecke.

_________________
I know all the jokes about my name
OliverN_26 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 252

Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
BeitragVerfasst: So 27.01.08 14:02 
Klingt einleuchtend ... Hab gedacht dass es da irgendwie nen Ereignis gibt was ich übersehen hab, da MouseOver bei nem Button ja eigentlich drin sein sollte (dacht ich), aber ich werd mir deine Funktion mal unter die Lupe nehmen ...

Danke ...
OliverN_26 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 252

Win7 64-Bit, WinXP SP3
Delphi 7 Enterprise
BeitragVerfasst: Di 29.01.08 15:02 
OK ... funzt super ... Danke