1.调用Windows api InvalidateRect(...);
可以指定更新的区域,这样即使抖动也只是小范围抖动;
2.截获WM_ERASEBKGOUND消息,阻止Form自动刷新背景;
3.或者可以这样,你在Form.Canvas上画画肯定是分成很多次画,这样当然容易引起抖动,
解决办法:设置一个内部位图TBitmap,大小和Form一样,每次画的时候,都画到Bitmap.Canvas上,到最后才一次性的画到Form.Canvas上。
这样就可以了。
可以指定更新的区域,这样即使抖动也只是小范围抖动;
2.截获WM_ERASEBKGOUND消息,阻止Form自动刷新背景;
3.或者可以这样,你在Form.Canvas上画画肯定是分成很多次画,这样当然容易引起抖动,
解决办法:设置一个内部位图TBitmap,大小和Form一样,每次画的时候,都画到Bitmap.Canvas上,到最后才一次性的画到Form.Canvas上。
这样就可以了。
public
{ Public declarations }
//禁止重绘窗体
procedure WMERASEBKGND(var Msg: TWMERASEBKGND); message WM_ERASEBKGND;implementation{$R *.dfm}procedure TfrmExit.WMERASEBKGND(var Msg: TWMERASEBKGND);
begin
Msg.Result:= 0;
end;
=======加上上面的代码后就不会出现这种情况了。
欢迎您访问http://www.vbersoft.com
方法不错,国为我在画时不想先擦掉再画(即设置canvas.Pen.Mode :=pmNotXor;画完后再设置canvas.Pen.Mode :=pmNotCopy;),这样就必须让Form自动刷新背景.但是用InvalidateRect在VC中可以而在Delphi中就不行。各位大仙能交我用InvalidateRect具体咋用????
CONST RECT *lpRect, // address of rectangle coordinates
BOOL bErase // erase-background flag
);
ParametershWndIdentifies the window whose update region has changed. If this parameter is NULL, Windows invalidates and redraws all windows, and sends the WM_ERASEBKGND and WM_NCPAINT messages to the window procedure before the function returns. lpRectPoints to a RECT structure that contains the client coordinates of the rectangle to be added to the update region. If this parameter is NULL, the entire client area is added to the update region. bEraseSpecifies whether the background within the update region is to be erased when the update region is processed. If this parameter is TRUE, the background is erased when the BeginPaint function is called. If this parameter is FALSE, the background remains unchanged. Return ValuesIf the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. ResThe invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs or until the region is validated by using the ValidateRect or ValidateRgn function.
Windows sends a WM_PAINT message to a window whenever its update region is not empty and there are no other messages in the application queue for that window.
If the bErase parameter is TRUE for any part of the update region, the background is erased in the entire region, not just in the given part. See AlsoBeginPaint, InvalidateRgn, RECT, ValidateRect, ValidateRgn, WM_ERASEBKGND, WM_NCPAINT, WM_PAINT
hBitmap=CreateCompatibleBitmap
hDC.SelectObject(hBitmap)
hDC......
BitBlt