Board index » cppbuilder » custom component inside custom component flickering

custom component inside custom component flickering

Hi all,

I made a custom listView derived from TCustomControl, when I'm adding an
other component ( a tree ) inside the listView, when scrolling the tree
is flickering.  I tried to add csOpaque in the listView and in the tree
without any result.
I also tried to set doublebuffered to true to both.
I also tried to catch the wm_erasebkgnd...

What's the appropriate way to achieve this task?
I would appreciate any leads as to the cause of this problem. Thanks.

Please reply (also) to : anto...@slantproductions.com

Antoine

 

Re:custom component inside custom component flickering


On Thu, 10 Apr 2003 16:15:41 -0400, - Antoine Buscarlet -

Quote
<anto...@slantproductions.com> wrote:
>I would appreciate any leads as to the cause of this problem. Thanks.

What does the TCustomControl descendant Paint look like?
If you get flicker look for some kind of circular action,, like
the Paint handler calling Inherited or doing something else
that triggers circular repaint operations.

Maybe if you post the Paint code someone can see what's
up with it.

--

"I don't want to belong to any club that would have me as a member."

    -- Groucho Marx

Re:custom component inside custom component flickering


Hi,

Thanks for the help.
In my OnScroll event I call Invalide() which redraw my trees..
and I set : tree->Parent = listView;
Here is my paint method for my tree:

void __fastcall AB_RTree::Paint()
{

   TRect cRect, tRect, gRect;
   TColor TopColor, BottomColor;
   int pos=ROWHEIGHT;
   int dh=0;

   int currpos = Tag;
   int topRowIndex, numVisibleRow, numPainted=0;

   TopColor = clBlack;
   BottomColor = 0x444444;

   Canvas->Brush->Color = clBtnFace;
   Canvas->FillRect(ClientRect);
   cRect = ClientRect;
   Graphics::TBitmap *bit = new Graphics::TBitmap;
   bit->Width = ClientWidth;
   bit->Canvas->Brush->Color = 0xe5e5e5;
   bit->Canvas->FillRect(cRect);

   dh = (VTRow.size())*ROWHEIGHT;
   if ( dh > Height ) {
         sb->Visible =true;
         bit->Height = dh;
     }
     else {
         sb->Pos=0;
         sb->Visible=false;
         bit->Height = Height;
         dh=Height;
     }
   sb->Max=dh;
   sb->Min=0;
   sb->PageSize=Height;

   topRowIndex=toppos/ROWHEIGHT;
   numVisibleRow= Height/ ROWHEIGHT;

   for ( int i = topRowIndex ; i <= topRowIndex+numVisibleRow; i++) {
      if ( i < VTRow.size() ){

          paintRow(bit->Canvas,VTRow[i],toppos+(ROWHEIGHT*numPainted));
          numPainted++;
      }
      else break;

   }

  BitBlt(Canvas->Handle, 0,-toppos, ClientWidth, dh,
bit->Canvas->Handle, 0, 0,SRCCOPY);

   delete bit;

   if ( FShowBorder){
          Canvas->Brush->Color = clBlack;
          Canvas->FrameRect(cRect);
   }

Quote
}

And now my PaintRow method :

int AB_RTree::paintRow(TCanvas * canvas, TRow* row, int top){

   TRect cRect;
   TColor TopColor, BottomColor;
   TopColor=clBlack;
   BottomColor=0x444444;
   AnsiString S, SS;
   int left = 0;

   S.sprintf("%s",row->node->getCaption().GetData());

   left = (row->level)*INDENTATION;

   cRect = Rect(0,top,left+100,top+ROWHEIGHT);
   if (row->node->nbChild()>0 ){

            if ( row->node!= root) canvas->Draw(left+5,top+6,DefPlus);
            else canvas->Draw(left+5,top+6,DefPlus);

   }
   if (row->expanded) {
           if (row->node!= root) canvas->Draw(left+5,top+6,DefMinus);
           else canvas->Draw(left+5,top+6,DefMinus);
          // canvas->Draw(left+18,top+5,DefFolder);
   }

  if ( row->selected ) {
       canvas->Font->Color= 0x00A8F0;
       canvas->Font->Name="Tahoma";
       if ( row->FState == TRsOver ){

         canvas->Font->Color= 0xAD8156;
       }
       canvas->TextOut(left+20,top+6,S);
  }
  else if ( row->FState == TRsOver ) {
       canvas->Font->Color= 0xDFBC98;
       canvas->Font->Name="Tahoma";
       canvas->TextOut(left+20,top+6,S);

  }
  else {
       canvas->Font->Color=clBlack;
       canvas->Font->Name="Default";
       canvas->TextOut(left+20,top+6,S);
  }

Quote
}

hope it helps.

Antoine

Quote
Michael Kelly wrote:
> On Thu, 10 Apr 2003 16:15:41 -0400, - Antoine Buscarlet -
> <anto...@slantproductions.com> wrote:

>>I would appreciate any leads as to the cause of this problem. Thanks.

> What does the TCustomControl descendant Paint look like?
> If you get flicker look for some kind of circular action,, like
> the Paint handler calling Inherited or doing something else
> that triggers circular repaint operations.

> Maybe if you post the Paint code someone can see what's
> up with it.

Re:custom component inside custom component flickering


On Fri, 11 Apr 2003 15:04:06 -0400, - Antoine Buscarlet -

Quote
<anto...@slantproductions.com> wrote:
>hanks for the help.
>In my OnScroll event I call Invalide() which redraw my trees..
>and I set : tree->Parent = listView;
>Here is my paint method for my tree:

I'm just wondering if there was a need to inherit
from TCustomControl instead of TCustomListView?
Usually when you get flicker it's because some event
is triggered multiple times that should only happen
once.

Other than that nothing leaps out at me.

--

"I don't want to belong to any club that would have me as a member."

    -- Groucho Marx

Other Threads