下記のようにして、グリッドの背景に画像を描画しようとしました。
画像は表示されたのですが、テキストが表示されません。
セルをクリックすると表示されますが、再描画が掛かると消えます。
どなたかわかる方、おられませんでしょうか?
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
saText: AnsiString;
begin
saText := TStringGrid(Sender).Cells[ACol, ARow];
with TStringGrid(Sender).Canvas do begin
Bitblt(TStringGrid(Sender).Canvas.Handle, 0, 0, Image1.Width, Image1.Height, Image1.Canvas.Handle, 0, 0, SRCCOPY);
TextRect(Rect, Rect.Left+12, Rect.Top+4, saText);
//DrawText(StringGrid1.Canvas.Handle, PChar(saText), Length(saText), Rect, DT_SINGLELINE or DT_VCENTER or DT_LEFT);
//TextOut(Rect.Left+12, Rect.Top+4, saText);
end;
end;
with TStringGrid(Sender).Canvas do begin
Brush.Style := bsClear;
CopyRect(Rect,Image1.Canvas,Rect);
TextRect(Rect,Rect.Left+12,Rect.Top+4,saText);
end;
なんてーのは、ダメだろうなぁ。。。
tooさん、ありがとうございました。
Bitblt と CopyRect で何がどー違うのかよく分からないのですが、
できました。^^;まだまだ奥深ですね・・・。
ツイート | ![]() |