[Delphi] Jak zmienić kolor i brush w button-nie.

0

Mam Delphi 5.5.
Nie mogę zmienić koloru i patern button-a i bitbtn-a.
W Javie to się robi tak:
document.form1.button.style.background = "#80FFFF";

a w Delphi nie mogę dojść.
W pliku "Unit" commctrl.pas jest wzmianka:

type
// Custom Draw Structure
{$EXTERNALSYM _NMTBCUSTOMDRAW}
_NMTBCUSTOMDRAW = packed record
nmcd: TNMCustomDraw;
hbrMonoDither: HBRUSH;
hbrLines: HBRUSH; // For drawing lines on buttons
hpenLines: HPEN; // For drawing lines on buttons
clrText: COLORREF; // Color of text
clrMark: COLORREF; // Color of text bk when marked. (only if TBSTATE_MARKED)
clrTextHighlight: COLORREF; // Color of text when highlighted
clrBtnFace: COLORREF; // Background of the button
clrBtnHighlight: COLORREF; // 3D highlight
clrHighlightHotTrack: COLORREF; // In conjunction with fHighlightHotTrack
// will cause button to highlight like a

Ale jak to zrobić, żeby zadziałało-bo kompilator nie informuje o błędzie a Button nadal jest standartowy.

Może trzeba wpisać coś na twardo w *.dfm ?

0

ja nie mam takich linijek :)))))
ale patrz
clrBtnFace := ColorToRGB(FCanvas.Brush.Color);

btw poszukaj w stdctrls

i jeszcze jedno a moze wykozystac tylko rysowanie? Hasdle buttona (jako canvas) i narysowac =] )

przykladowy komponent, ktory w 100% nie dzila jak nalezy :P
(moj)

TNoxxButtonColor = class(TComponent)
private
fbutton : TButton;
fbutton_color : Tcolor;
fcolor_3d_left, fcolor_3d_top, ffont_color : TColor;
fleft, ftop : integer;
fcleft, fctop : integer;
procedure setbutton(abutton : TButton);
procedure setbuttoncolor(value : Tcolor);
procedure set3dleftcolor(value : Tcolor);
procedure set3dtopcolor(value : Tcolor);
procedure setfontcolor(value : Tcolor);

procedure setfleft(value : integer);
procedure setftop(value : integer);
procedure setfcleft(value : integer);
procedure setfctop(value : integer);
protected
public
constructor Create(AOwner: TComponent); override;
procedure change_unclicked;
procedure change_clicked;
published
property Button : TButton read fbutton write setbutton;
property Button_color : TColor read fbutton_color write setbuttoncolor default clbtnface;
property Left_color : TColor read fcolor_3d_left write set3dleftcolor default clwhite;
property Top_color : TColor read fcolor_3d_top write set3dtopcolor default clblack;
// property Font_color : TColor read ffont_color write setfontcolor default clblack;
property Text_left_unchck : integer read fleft write setfleft default 10;
property Text_top_unchck : integer read ftop write setftop default 10;
property Text_left_chck : integer read fcleft write setfcleft default 10;
property Text_top_chck : integer read fctop write setfctop default 10;
end;

[..]

procedure tnoxxbuttoncolor.change_unclicked;
var
c : Tcanvas;
capt : Tlabel;
begin
capt := TLabel.create(self);
capt.Parent := nil;
//to zmienia kolor buttona :]
c:=TCanvas.Create;
c.Handle:=GetDC(fbutton.Handle);
c.Brush.Style := bssolid;
c.Brush.Color := fbutton_color;
c.pen.Color := fbutton_color;
c.Rectangle(1,1,fbutton.width - 1,fbutton.height - 2);
c.MoveTo(0,0);
c.Pen.color := fcolor_3d_left;
c.lineto(fbutton.width,0);
c.MoveTo(0,0);
c.lineto(0,fbutton.height - 1);

c.pen.color := fcolor_3d_top;
c.moveto(0,fbutton.height+1);
c.lineto(fbutton.width-1,fbutton.height-1);
c.moveto(fbutton.width-1,fbutton.height-1); // <-- tak dla pewności
c.lineto(fbutton.width-1,1);

c.pen.color := clbtnshadow;
c.moveto(fbutton.width - 3,1);
c.lineto(fbutton.width - 3,fbutton.height - 3);
c.moveto(fbutton.width - 3,fbutton.height - 3); //-||-
c.lineto(2,fbutton.height - 3);
//ale gdzie jest caption? - to już za chwile :]
capt.font := fbutton.Font;
capt.Font.Color := ffont_color;
capt.Caption := fbutton.caption; {
c.brush.Color := ffont_color;
c.Brush.Style := bsclear; }
c.TextOut(fleft,ftop,fbutton.caption);
capt.free;
c.free;
end;

;]

1 użytkowników online, w tym zalogowanych: 0, gości: 1