本人根据pngextra的TPNGButton修改了一个通过GDI来绘画的按钮
但是最近发现闪烁过于厉害,以前以为是cpu太渣,现在换成了i5后依然如此所以想来请教下各位
procedure TaLoPNGButton.Paint;
const
  Slide: Array[false..true] of Integer = (0, 2);
var
  Area:TRect;
  GPRect:TGPRect;
  Image: TGPImage;
  Pushed: Boolean;
  TextSize: TSize;
  TextPos: TPoint;
  OldStyle:TBrushStyle;
  DC, MemDC: HDC;
  MemBitmap,OldBitmap: HBITMAP;
  PS: TPaintStruct;
begin
  inherited;  {Determines if the button is pushed}
  Pushed := (ButtonState = pbsDown) and IsMouseOver;  {Determines the image to use}
  if (Pushed) then
    Image := fImageDown
  else if IsMouseOver and Enabled then
    Image := fImageOver
  else if (ButtonState = pbsDisabled) then
    Image := fImageDisabled
  else
    Image := fImageNormal;
  Area:=GetClientRect;
  if Stretch then//平铺
    begin
      GPRect.X:=0;
      GPRect.Y:=0;
      GPRect.Width:=Width;
      GPRect.Height:=Height;
    end
  else//原始大小
    begin
      GPRect.X:=0;
      GPRect.Y:=0;
      GPRect.Height:=Image.GetHeight;
      GPRect.Width:=Image.GetWidth;
    end;  Canvas.Lock;
  try
    MemDC:=CreateCompatibleDC(Canvas.Handle);
    MemBitmap:=CreateCompatibleBitmap(Canvas.Handle,GPRect.Width,GPRect.Height);
    OldBitmap:=SelectObject(MemDC,MemBitmap);
    try
      PerformEraseBackground(Self,MemDC);
      FGraphics.LoadFromDC(MemDC);
      //FGraphics.LoadFromDC(Canvas.Handle);
      FGraphics.DrawImage(Image,GPRect);
      BitBlt(Canvas.Handle,GPRect.X,GPRect.Y,GPRect.Width,GPRect.Height
        ,MemDC,0,0,SRCCOPY );
    finally
      SelectObject(MemDC,OldBitmap);
      DeleteDC(MemDC);
      DeleteObject(MemBitmap);
    end;
  finally
    Canvas.Unlock;
  end;
  if Caption <> '' then
    begin
      TextSize := Canvas.TextExtent(Caption);
      TextPos.X := (Width - TextSize.cx) div 2 + Slide[Pushed];
      TextPos.Y := (Height - TextSize.cy) div 2;
      TextPos.Y := TextPos.Y + Slide[Pushed];
      OldStyle:=Canvas.Brush.Style;
      Canvas.Brush.Style:=bsClear;
      Canvas.TextOut(TextPos.X,TextPos.Y,Caption);
      Canvas.Brush.Style:=OldStyle;
    end;end;
使用如上代码,闪烁依旧,求各位大神给与帮助~gdipngdelphi7pngbutton按钮