FillRect不会在Delphi XE2中绘制完整的TStringGrid单元格 [英] FillRect doesn't paint the complete TStringGrid cell in Delphi XE2

查看:296
本文介绍了FillRect不会在Delphi XE2中绘制完整的TStringGrid单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FillRect 不会在Delphi XE2中绘制完整的 TStringGrid 单元格。默认颜色左侧有3个像素间距( BiDiMode 设置为 bdLeftToRight )。这个问题在我以前使用的Delphi 6中不存在。

FillRect doesn't paint the complete TStringGrid cell in Delphi XE2. There is a gap of 3 pixels on the left side in the default color (with BiDiMode set to bdLeftToRight). This problem doesn't exist in Delphi 6 which I used before.

procedure TShapeline.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  Stringgrid1.Canvas.Brush.Color:=$00FF80FF;
  StringGrid1.Canvas.FillRect(Rect);
end;

我尝试更改所有属性(包括 DrawingStyle )和不同的画笔样式,绘制的矩形不会填满整个单元格。

I tried to change all properties (including the DrawingStyle) and different brush styles, the painted rectangle doesn't fill the complete cell.

推荐答案

这是XE2中的预期行为当 DefaultDrawing = true 并启用主题(我不会在这里讨论好或坏 - 正如您可能已经注意到的,RigthToLeft的行为是不同的模式...

This is expected behaviour in XE2 when DefaultDrawing = true and themes are enabled (I'm not going to argue about good or bad here - as you might have noticed, the behaviour is different for RigthToLeft mode...).

解决方法是检查此条件并减少 Rect.Left 4像素调用 FillRect

A workaround is to check for this condition and decrement Rect.Left by 4 pixel before calling FillRect.

这篇关于FillRect不会在Delphi XE2中绘制完整的TStringGrid单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆