D7移植到Delphi2009,TStringGrid DrawCell使用DrawText时出现乱码,请教怎么回事?
dyfh 2012-05-05 08:15:36 代码在下面,在Delphi7里是完全没有问题的,但把代码移植到2009后,发现DrawText的中文会出现乱码,而如果没有中文只有英文和数字,则只显示第一个字符,请问这是怎么回事?如何解决??
procedure TfrmSick.stringgridInfoDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
r:TRect;
a:TGridRect;
begin
with TStringGrid(Sender).Canvas do
begin
if ((ARow=TStringGrid(Sender).Row)) then begin
Brush.Color := $00FAE2C0;
FillRect(rect);
SetRect(r,Rect.Left+2,Rect.Top+4,Rect.Right,Rect.Bottom);
Font.Color:=clBlack;
DrawText(Handle,PAnsiChar(TStringGrid(Sender).Cols[acol][arow]),-1,R,DT_LEFT or DT_WORD_ELLIPSIS);
end;
end;
end;