InvalidateRect、ValidateRect、RedrawWindow
其他的与画图相关的也可以!
万分感激!

解决方案 »

  1.   

    把位图变成一个图标实现Acdsee式的预览---InvalidateRect
    ========================================================
    procedure TForm1.Button1Click(Sender: TObject);varIconSizeX : integer;IconSizeY : integer;AndMask : TBitmap;XOrMask : TBitmap;IconInfo : TIconInfo;Icon : TIcon;begin{Get the icon size}IconSizeX := GetSystemMetrics(SM_CXICON);IconSizeY := GetSystemMetrics(SM_CYICON);{Create the "And" mask}AndMask := TBitmap.Create;AndMask.Monochrome := true;AndMask.Width := IconSizeX;AndMask.Height := IconSizeY;{Draw on the "And" mask}AndMask.Canvas.Brush.Color := clWhite;AndMask.Canvas.FillRect(Rect(0, 0, IconSizeX, IconSizeY));AndMask.Canvas.Brush.Color := clBlack;AndMask.Canvas.Ellipse(4, 4, IconSizeX - 4, IconSizeY - 4);{Draw as a test}Form1.Canvas.Draw(IconSizeX * 2, IconSizeY, AndMask);{Create the "XOr" mask}XOrMask := TBitmap.Create;XOrMask.Width := IconSizeX;XOrMask.Height := IconSizeY;{Draw on the "XOr" mask}XOrMask.Canvas.Brush.Color := ClBlack;XOrMask.Canvas.FillRect(Rect(0, 0, IconSizeX, IconSizeY));XOrMask.Canvas.Pen.Color := clRed;XOrMask.Canvas.Brush.Color := clRed;XOrMask.Canvas.Ellipse(4, 4, IconSizeX - 4, IconSizeY - 4);{Draw as a test}Form1.Canvas.Draw(IconSizeX * 4, IconSizeY, XOrMask);{Create a icon}Icon := TIcon.Create;IconInfo.fIcon := true;IconInfo.xHotspot := 0;IconInfo.yHotspot := 0;IconInfo.hbmMask := AndMask.Handle;IconInfo.hbmColor := XOrMask.Handle;Icon.Handle := CreateIconIndirect(IconInfo);{Destroy the temporary bitmaps}AndMask.Free;XOrMask.Free;{Draw as a test}Form1.Canvas.Draw(IconSizeX * 6, IconSizeY, Icon);{Assign the application icon}Application.Icon := Icon;{Force a repaint}InvalidateRect(Application.Handle, nil, true);//这里{Free the icon}Icon.Free;end; 
     
      

  2.   

    淡入和淡出    
    下面的代码可以在窗体上面淡入淡出一个图形: --redrawwindow
    ===============================================
    typePRGBTripleArray = ^TRGBTripleArray;TRGBTripleArray = array[0..32767] of TRGBTriple;/////////////////////////////////////////////////// Fade In ///////////////////////////////////////////////////procedure FadeIn(ImageFileName: TFileName);varBitmap, BaseBitmap: TBitmap;Row, BaseRow : PRGBTripleArray;x, y, step : integer;begin// Bitmaps vorbereiten / Preparing the Bitmap //Bitmap := TBitmap.Create;tryBitmap.PixelFormat := pf32bit; // oder pf24bit / or pf24bit //Bitmap.LoadFromFile(ImageFileName);BaseBitmap := TBitmap.Create;tryBaseBitmap.PixelFormat := pf32bit;BaseBitmap.Assign(Bitmap);// Fading //for step := 0 to 32 dobeginfor y := 0 to (Bitmap.Height - 1) dobeginBaseRow := BaseBitmap.Scanline[y];// Farben vom Endbild holen / Getting colors from final image //Row := Bitmap.Scanline[y];// Farben vom aktuellen Bild / Colors from the image as it is now //for x := 0 to (Bitmap.Width - 1) dobeginRow[x].rgbtRed := (step * BaseRow[x].rgbtRed) shr 5;Row[x].rgbtGreen := (step * BaseRow[x].rgbtGreen) shr 5; // Fading //Row[x].rgbtBlue := (step * BaseRow[x].rgbtBlue) shr 5;end;end;Form1.Canvas.Draw(0, 0, Bitmap); // neues Bild ausgeben / Output new image //InvalidateRect(Form1.Handle, nil, False);// Fenster neu zeichnen / Redraw window //RedrawWindow(Form1.Handle, nil, 0, RDW_UPDATENOW);end;finallyBaseBitmap.Free;end;finallyBitmap.Free;end;end;/////////////////////////////////////////////////// Fade Out /////////////////////////////////////////////////// procedure FadeOut(ImageFileName: TFileName);varBitmap, BaseBitmap: TBitmap;Row, BaseRow: PRGBTripleArray;x, y, step: integer;begin// Bitmaps vorbereiten / Preparing the Bitmap //Bitmap := TBitmap.Create;tryBitmap.PixelFormat := pf32bit; // oder pf24bit / or pf24bit //Bitmap.LoadFromFile(ImageFileName);BaseBitmap := TBitmap.Create;tryBaseBitmap.PixelFormat := pf32bit;BaseBitmap.Assign(Bitmap);// Fading //for step := 32 downto 0 dobeginfor y := 0 to (Bitmap.Height - 1) dobeginBaseRow := BaseBitmap.Scanline[y];// Farben vom Endbild holen / Getting colors from final image //Row := Bitmap.Scanline[y];// Farben vom aktuellen Bild / Colors from the image as it is now //for x := 0 to (Bitmap.Width - 1) dobeginRow[x].rgbtRed := (step * BaseRow[x].rgbtRed) shr 5;Row[x].rgbtGreen := (step * BaseRow[x].rgbtGreen) shr 5; // Fading //Row[x].rgbtBlue := (step * BaseRow[x].rgbtBlue) shr 5;end;end;Form1.Canvas.Draw(0, 0, Bitmap); // neues Bild ausgeben / Output new image //InvalidateRect(Form1.Handle, nil, False);// Fenster neu zeichnen / Redraw window //RedrawWindow(Form1.Handle, nil, 0, RDW_UPDATENOW);sleep(20);end;finallyBaseBitmap.Free;end;finallyBitmap.Free;end;end; procedure TForm1.Button1Click(Sender: TObject);beginFadeIn('F:.BMP')end;{*****************************}{by Yucel Karapinar, [email protected] }{ Only for 24 ve 32 bits bitmaps }procedure FadeOut(const Bmp: TImage; Pause: Integer);varBytesPorScan, counter, w, h: Integer;p : pByteArray;beginif not (Bmp.Picture.Bitmap.PixelFormat in [pf24Bit, pf32Bit]) thenraise Exception.Create('Error, bitmap format is not supporting.');tryBytesPorScan := Abs(Integer(Bmp.Picture.Bitmap.ScanLine[1]) -Integer(Bmp.Picture.Bitmap.ScanLine[0]));exceptraise Exception.Create('Error!!');end;for counter := 1 to 256 dobeginfor h := 0 to Bmp.Picture.Bitmap.Height - 1 dobeginP := Bmp.Picture.Bitmap.ScanLine[h];for w := 0 to BytesPorScan - 1 doif P^[w] > 0 then P^[w] := P^[w] - 1;end;Sleep(Pause);Bmp.Refresh;end;end;procedure TForm1.Button2Click(Sender: TObject);beginFadeOut(Image1, 1);end; 
     
       
      

  3.   

    Windows程序设计 一书中 有详细说明和例子!
      

  4.   

    http://www.ccw.com.cn/htm/produ/special/VC/neimu/01_9_17_12.asp
    -----
    你可以参考Windows API函数手册