求delphi双缓冲画图demo,该如何解决
求delphi双缓冲画图demo
最近使用paintbox来画图,但是效果不佳,按照网上的提示,DoubleBuffered := true,还有发送消息等均是无效。求大神们来一个双缓冲demo看看,看是不是有帮助。顺便说一下,paintbox是用来画图的,使用timer来刷,还有就是paintbox在panel上,该panel是用来接收一个实时流图像的。
不知道有没有老鸟愿意教菜鸟的,可以请邮件至: libaocheng@cnmta.com。菜鸟
------解决方案--------------------
双缓冲画图,DELPHI的源码里就有例子...如下:
procedure TWinControl.WMPaint(var Message: TWMPaint);
var
DC, MemDC: HDC;
MemBitmap, OldBitmap: HBITMAP;
PS: TPaintStruct;
begin
if not FDoubleBuffered or (Message.DC <> 0) then
begin
if not (csCustomPaint in ControlState) and (ControlCount = 0) then
inherited
else
PaintHandler(Message);
end
else
begin
DC := GetDC(0);
MemBitmap := CreateCompatibleBitmap(DC, ClientRect.Right, ClientRect.Bottom);
ReleaseDC(0, DC);
MemDC := CreateCompatibleDC(0);
OldBitmap := SelectObject(MemDC, MemBitmap);
try
DC := BeginPaint(Handle, PS);
Perform(WM_ERASEBKGND, MemDC, MemDC);
Message.DC := MemDC;
WMPaint(Message);
Message.DC := 0;
BitBlt(DC, 0, 0, ClientRect.Right, ClientRect.Bottom, MemDC, 0, 0, SRCCOPY);
EndPaint(Handle, PS);
finally
SelectObject(MemDC, OldBitmap);
DeleteDC(MemDC);
DeleteObject(MemBitmap);
end;
end;
end;
------解决方案--------------------
不懂,帮顶!
最近使用paintbox来画图,但是效果不佳,按照网上的提示,DoubleBuffered := true,还有发送消息等均是无效。求大神们来一个双缓冲demo看看,看是不是有帮助。顺便说一下,paintbox是用来画图的,使用timer来刷,还有就是paintbox在panel上,该panel是用来接收一个实时流图像的。
不知道有没有老鸟愿意教菜鸟的,可以请邮件至: libaocheng@cnmta.com。菜鸟
------解决方案--------------------
双缓冲画图,DELPHI的源码里就有例子...如下:
procedure TWinControl.WMPaint(var Message: TWMPaint);
var
DC, MemDC: HDC;
MemBitmap, OldBitmap: HBITMAP;
PS: TPaintStruct;
begin
if not FDoubleBuffered or (Message.DC <> 0) then
begin
if not (csCustomPaint in ControlState) and (ControlCount = 0) then
inherited
else
PaintHandler(Message);
end
else
begin
DC := GetDC(0);
MemBitmap := CreateCompatibleBitmap(DC, ClientRect.Right, ClientRect.Bottom);
ReleaseDC(0, DC);
MemDC := CreateCompatibleDC(0);
OldBitmap := SelectObject(MemDC, MemBitmap);
try
DC := BeginPaint(Handle, PS);
Perform(WM_ERASEBKGND, MemDC, MemDC);
Message.DC := MemDC;
WMPaint(Message);
Message.DC := 0;
BitBlt(DC, 0, 0, ClientRect.Right, ClientRect.Bottom, MemDC, 0, 0, SRCCOPY);
EndPaint(Handle, PS);
finally
SelectObject(MemDC, OldBitmap);
DeleteDC(MemDC);
DeleteObject(MemBitmap);
end;
end;
end;
------解决方案--------------------
不懂,帮顶!