unit Main;

interface
{$I AnyLib.Inc}
uses
  Windows, Messages, SysUtils, {$IFDEF Delphi6} Variants,{$ELSE}FileCtrl,{$ENDIF}
  Classes, Graphics, Controls, Forms,
  Dialogs, BaseForm, AnyPrint, AnyGrids, ComCtrls, Buttons, ExtCtrls,
  StdCtrls, ImgList;

type
  TfrmMain = class(TfrmBase)
    Button1: TButton;
    ImageList1: TImageList;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure AnyGridDrawCell(Sender: TObject; Row, Col: Integer;
      Canvas: TCanvas; R: TRect; var Handled: Boolean);
    procedure AnyGridBeforeColumnWidthChange(Sender: TObject;
      Index: Integer; var CanChange: Boolean);
  private
    SCurrency:WideString;
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}
uses ShellApi;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
  inherited;
  ShowMessage('I am a delphi button');
end;

procedure TfrmMain.FormCreate(Sender: TObject);
var
  R:TRect;
  s:array[0..9] of char;
begin
  inherited;
  LayoutSection:='Main';
  R:=AnyGrid.CellByName('Control').Rect;
  AnyGrid.SetUserControlPos(Button1,R.Left+3,R.Top+3);
  AnyGrid.FixUserControl(Button1,True);
  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SCURRENCY,s,10);
  SCurrency:=s;
end;

procedure TfrmMain.AnyGridDrawCell(Sender: TObject; Row, Col: Integer;
  Canvas: TCanvas; R: TRect; var Handled: Boolean);
var
  W,L1,L2:integer;
begin
  inherited;
  if (Row=12) and (Col=4) then
  begin
    W:=R.Right-R.Left;
    ImageList1.Draw(Canvas,R.Left+(W-ImageList1.Width) div 2,R.Top+4,1);
    Canvas.Brush.Style:=bsClear;
    Canvas.Font.Assign(Font);
    Canvas.Font.Color:=clBlack;
    Canvas.Font.Style:=[fsBold];
    L2:=Canvas.TextWidth('Draw');
    Canvas.Font.Style:=[];
    L1:=Canvas.TextWidth('Owner');
    Canvas.TextOut(R.Left+(W-L1-L2) div 2,R.Top+4+ImageList1.Height+4,'Owner');
    Canvas.Font.Style:=[fsBold];
    Canvas.TextOut(R.Left+(W-L1-L2) div 2+L1, R.Top+4+ImageList1.Height+4,'Draw');
    Handled:=True;
  end;
end;

procedure TfrmMain.AnyGridBeforeColumnWidthChange(Sender: TObject;
  Index: Integer; var CanChange: Boolean);
begin
  inherited;
  CanChange:=not (Index in [5..13]);
end;

end.
