type
TForm6 = class(TForm)
Image1: TImage;
SpinEdit1: TSpinEdit;
procedure FormCreate(Sender: TObject);
procedure SpinEdit1Change(Sender: TObject);
procedure UpdateString;
private
FontSize: Integer;
public
end;
var
Form6: TForm6;
implementation
procedure TForm6.FormCreate(Sender: TObject);
begin
FontSize := 12;
SpinEdit1.Value := FontSize;
UpdateString;
end;
procedure TForm6.SpinEdit1Change(Sender: TObject);
begin
FontSize := SpinEdit1.Value;
UpdateString;
end;
procedure TForm6.UpdateString;
var
ARect: TRect;
TextStr: string;
TextHeight: Integer;
begin
TextStr := 'Июнь 2012';
Image1.Invalidate;
Image1.Canvas.Brush.Color := clWhite;
Image1.Canvas.FillRect(Rect(0,0,Image1.Height, Image1.Width));
Image1.Canvas.Font := self.Font;
Image1.Canvas.Font.Size := FontSize;
TextHeight := Image1.Canvas.TextHeight(TextStr);
ARect := Rect(0, 0, 200, TextHeight*2);
Image1.Canvas.Brush.Color := clYellow;
Image1.Canvas.FillRect(ARect);
Image1.Canvas.Brush.Color := clLime;
DrawText(Image1.Canvas.Handle, PWideChar(TextStr), Length(TextStr), ARect, DT_VCENTER);
end;
Как-то не похоже что работает :(