我制作了一个组件,上有一个TImage控件,当程序运行时,可以拖动TImage控件。可是在实际应用中,我发现当TImage控件移动时,系统重绘该组件(继承自TPanel),会产生明显的闪烁。请问各位高手怎样解决这个问题。

解决方案 »

  1.   

    不行啊,我的组件上Image有很多,都是无缝连接的,是不是每次移动时(还要处理特效)要处理的时间较长,连双缓冲都应付不了?
      

  2.   

    weibz0525(小虫) :对不起,是我的问题。你的方案对于TWinControl是对的。
    可是,我的组件是继承自TGraphicControl,怎么处理?
      

  3.   

    呵呵,我只能说I don't know,问问其他高手吧
      

  4.   

    其容器控件的DoubleBuffered=True然后Image.Proportional:=False;
    Image.Stretch:=True;
    Image.Transparent:=False;至于原因,查看VCLprocedure TImage.PictureChanged(Sender: TObject);
    var
      G: TGraphic;
    begin
      if AutoSize and (Picture.Width > 0) and (Picture.Height > 0) then
    SetBounds(Left, Top, Picture.Width, Picture.Height);
      G := Picture.Graphic;
      if G <> nil then
      begin
    if not ((G is TMetaFile) or (G is TIcon)) then
      G.Transparent := FTransparent;
    if (not G.Transparent) and Stretch and not Proportional then
      ControlStyle := ControlStyle + [csOpaque]
    else  // picture might not cover entire clientrect
      ControlStyle := ControlStyle - [csOpaque];
    if DoPaletteChange and FDrawing then Update;
      end
      else ControlStyle := ControlStyle - [csOpaque];
      if not FDrawing then Invalidate;
    end;就是改变ControlStyle!