如何判断paintbox的更新区域?(100分)

  • 主题发起人 主题发起人 xwings
  • 开始时间 开始时间
X

xwings

Unregistered / Unconfirmed
GUEST, unregistred user!
我用painbox画图. 创建了一个bitmap作为后台缓冲区. 图事先已经画好到bitmap上了.
然后在painbox的 OnPaint事件中draw到了painbox的canvas上去.
现在的问题是我的paintbox比较大. 即使painbox上面被一点点的窗体遮盖一下都会触发Onpain事件,
从而引起整个的Draw Bitmap过程.导致每次刷新Onpaint 都比较慢.
于是,我想获得每次需要Paint的区域或区域列表(Rect or Region).这样我只需要draw需要更新的部分就可以了.
但是如何获得需要更新的区域(Rect or Region )呢?我还没有找到相关的API或者方法. 请各位指教一下.先谢谢了.
 
可以通过InvalidateRect函数获得需要更新的区域,然后执行你想做的工作
 
不对吧. invalidaterect是加入一个需要更新的区域.不是获得.
 
GetUpdateRect
 
GetUpdateRect 我试过了. 没有试出来. 返回的rect都是 0 . 楼上的能不能给个Demo啊.
 
GetUpdateRect 要在 WM_PAINT 事件里,放到 inherited 前用的,不能在 ONPAINT 里用,因为这里已经处理过该了
 
要在TGraphicControl 里面用么? 我看了一下他的WMPaint 处理过程. 好像没有用GetUpdateRect 嘛.
我还是不清楚. 请.cqbaobao再说详细一点呀.
 
我在 PaintBox 的父窗口的 WM_PAINT 处理过程里试过,可以取得


procedure MyPaint(var msg: TWMPAINT); message WM_PAINT;

.............

procedure TForm1.MyPaint(var msg: TWMPAINT);
var
r: TRect;
begin
GetUpdateRect(Handle, r, true);
Caption := '(' + inttostr(r.Left) + ', ' + inttostr(r.Top) + ') - (' +
inttostr(r.Right) + ', ' + inttostr(r.Bottom) + ')';
inherited;
end;
 
接受答案了.
 
PaintBox.Canvas.ClipRect
 

Similar threads

后退
顶部