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
| unit Class1;
interface
uses
System.ComponentModel, System.Drawing , System.Windows.Forms ;
type
TClass1 = class(DateTimePicker)
private
m_backBrush : SolidBrush;
protected
procedure WndProc(var m : Message);
public
constructor Create;
procedure setBackColor(c : Color);
end;
implementation
constructor TClass1.Create;
begin
inherited Create;
m_backBrush := SolidBrush.Create(Color.get_Brown);
end;
procedure TClass1.setBackColor(c : Color);
begin
BackColor := c;
m_backBrush := SolidBrush.Create(c);
Self.Invalidate;
end;
procedure TClass1.WndProc(var m : Message);
var g : Graphics;
begin
g := Graphics.FromHdc(m.WParam);
g.FillRectangle(m_backBrush, Self.ClientRectangle);
end;
end. |
Partager