首页 新闻 会员 周边

无闪烁双缓冲的实现。

0
[待解决问题]

procedure TCSPaintBox.Paint; var   Bmp: TBitmap;   Rct: TRect; begin   GetClipBox(Canvas.Handle, Rct);

  if (Rct.Left=0) and (Rct.Top=0) and (Rct.Bottom=0) and (Rct.Right=0) then     Exit;

  Bmp := TBitmap.Create;   try     Bmp.Canvas.Brush.Color := Color;     Bmp.Width := Width;     Bmp.Height := Height;     Bmp.Canvas.Font := Font;

    if Assigned(FOnCsPaint) then     begin       FOnCSPaint(Self, Bmp.Canvas);       Canvas.Draw(0, 0, Bmp);     end;   finally     Bmp.Free;   end; end;

procedure TCSPaintBox.WMEraseBkgnd(var Message: TWMEraseBkgnd); begin   Message.Result := 1; end;

procedure TCSPaintBox.WMPaint(var Message: TWMPaint); begin   inherited;

  Paint; end;

--------------------------------------------------------------

 

万一老师以上代码是一个实现无闪烁双缓冲绘图的基类。

用的FONCSPaint回调函数 ,在子类绘制好图片后再在此基类Paint消息响应函数中一次绘制出来。

请问:

procedure TCSPaintBox.WMEraseBkgnd(var Message: TWMEraseBkgnd); begin   Message.Result := 1; end;

这个代码是不是实现了 屏蔽背景的重绘。 如果是,重绘中不会出现和原来的图片重叠吗。(实际测试正常显示)

RainWork的主页 RainWork | 菜鸟二级 | 园豆:204
提问于:2015-09-13 13:35
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册