1.调用Windows api InvalidateRect(...);
  可以指定更新的区域,这样即使抖动也只是小范围抖动;
2.截获WM_ERASEBKGOUND消息,阻止Form自动刷新背景;
3.或者可以这样,你在Form.Canvas上画画肯定是分成很多次画,这样当然容易引起抖动,
  解决办法:设置一个内部位图TBitmap,大小和Form一样,每次画的时候,都画到Bitmap.Canvas上,到最后才一次性的画到Form.Canvas上。
  
这样就可以了。

解决方案 »

  1.   

    你可以这样做就不会出现这样的情况了,我用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
      

  2.   

       感谢各位大仙的帮助,我已试过用这几种方法,我认为用调用Windows api InvalidateRect
    方法不错,国为我在画时不想先擦掉再画(即设置canvas.Pen.Mode :=pmNotXor;画完后再设置canvas.Pen.Mode :=pmNotCopy;),这样就必须让Form自动刷新背景.但是用InvalidateRect在VC中可以而在Delphi中就不行。各位大仙能交我用InvalidateRect具体咋用????
      

  3.   

    InvalidateRect      The InvalidateRect function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn. BOOL InvalidateRect(    HWND hWnd, // handle of window with changed update region  
        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 
      

  4.   

    设置 Form1.DoubleBuffered:= True; 
      

  5.   

    use Double-buffering techniquehDC=CreateCompatibleDC
    hBitmap=CreateCompatibleBitmap
    hDC.SelectObject(hBitmap)
    hDC......
    BitBlt