Thema: Delphi buttonstyle ändern

Einzelnen Beitrag anzeigen

Benutzerbild von FastJack2
FastJack2

Registriert seit: 22. Mär 2004
Ort: Lübeck
54 Beiträge
 
Delphi 7 Enterprise
 
#6

Re: buttonstyle ändern

  Alt 25. Aug 2004, 14:01
jupp ...
aber auf einem canvas kannste halt malen oder bitmaps reinkopieren ... ganz wie du lustig bist ...

diese proceduren

Code:
    procedure PMNorm(var message: TMessage); message WM_PAINT;
    procedure PMUpDown(var message: TMessage); message $f3;
    procedure PMEnter(var message: TMessage); message WM_SETFOCUS;
    procedure PMLeave(var message: TMessage); message WM_KILLFOCUS;
    procedure PMMouseEnter(var message: TMessage); message CM_MOUSEENTER;
    procedure PMMouseLeave(var message: TMessage); message CM_MOUSELEAVE;
schalten nur die button-states um und rufen die Prozedur paintme auf, die dann den button-canvas bemalt ...

wenn du jetzt die paintme prozedur wie folgt abänderst ändert sich die farbe und die caption des buttons

Code:
procedure TOwnButton.paintme;
var
  c: TControlCanvas;
  tmpcaption: string;
begin
  try
    c := TControlCanvas.create;
    c.Control := self;
    if isdown then
    begin
      c.Brush.Color := clmaroon;
      c.FillRect((rect(0,0,self.Width,self.Height)));
      c.font.Color := clred;
      tmpcaption := 'down';
      c.TextOut((width div 2)-(c.TextWidth(tmpcaption) div 2),
                (height div 2)-(c.Textheight(tmpcaption) div 2),
                tmpcaption);
    end
    else if ismousein then
    begin
      c.Brush.Color := cllime;
      c.FillRect((rect(0,0,self.Width,self.Height)));
      c.font.Color := clblack;
      tmpcaption := 'hover';
      c.TextOut((width div 2)-(c.TextWidth(tmpcaption) div 2),
                (height div 2)-(c.Textheight(tmpcaption) div 2),
                tmpcaption);
    end
    else if isin then
    begin
      c.Brush.Color := clnavy;
      c.FillRect((rect(0,0,self.Width,self.Height)));
      c.font.Color := clwhite;
      tmpcaption := 'focused';
      c.TextOut((width div 2)-(c.TextWidth(tmpcaption) div 2),
                (height div 2)-(c.Textheight(tmpcaption) div 2),
                tmpcaption);
    end
    else
    begin
      c.Brush.Color := clgreen;
      c.FillRect((rect(0,0,self.Width,self.Height)));
      c.font.Color := cllime;
      tmpcaption := 'normal';
      c.TextOut((width div 2)-(c.TextWidth(tmpcaption) div 2),
                (height div 2)-(c.Textheight(tmpcaption) div 2),
                tmpcaption);
    end;
  finally
    FreeAndNil(c);
  end;
end;
greetz
-FastJack2

[edit]probleme mit zeilemumbruch behoben ;)[/edit]
wo unrecht zu recht wird, wird widerstand zur pflicht ! (c) '98 - WoF board
  Mit Zitat antworten Zitat