Board index » cppbuilder » Why Doesn't This PaintBox Code Work?

Why Doesn't This PaintBox Code Work?

I am using BCB5.0 professional. This problem seems to simple to be
believable. I have a simple test application with two forms. On Form2 there
are three PaintBoxes. PaintBox 2 and 3 are set to be invisible by manually
setting the visible property to false. Form2 is opened using the button
event handler below. When the Form2 opens all three PaintBoxes are visible.
I want to use PaintBox 2 and 3 as invisible buffers but this is not possible
because they are always visible. Is this a bug?  How can I make PaintBox 2
and 3 invisible?

Thanks
Larry Johnson.

void __fastcall TForm1::Button1Click(TObject *Sender)
{

  Form2->Show();

  Form2->PaintBox1->Canvas->Brush->Style = bsClear;
  Form2->PaintBox1->Canvas->Brush->Color = clWhite;
  Form2->PaintBox1->Canvas->FillRect(Rect(0, 0, Form2->PaintBox1->Width,
Form2->PaintBox1->Height));
  Form2->PaintBox1->Canvas->Brush->Style = bsClear;

  Form2->PaintBox2->Canvas->Brush->Style = bsClear;
  Form2->PaintBox2->Canvas->Brush->Color = clRed;
  Form2->PaintBox2->Canvas->FillRect(Rect(0, 0, Form2->PaintBox2->Width,
Form2->PaintBox2->Height));
  Form2->PaintBox2->Canvas->Brush->Style = bsClear;

  Form2->PaintBox3->Canvas->Brush->Style = bsClear;
  Form2->PaintBox3->Canvas->Brush->Color = clBlue;
  Form2->PaintBox3->Canvas->FillRect(Rect(0, 0, Form2->PaintBox3->Width,
Form2->PaintBox3->Height));
  Form2->PaintBox3->Canvas->Brush->Style = bsClear;

Quote
}

//--------------------------------------------------------------------------
-
 

Re:Why Doesn't This PaintBox Code Work?


Quote
"Larry Johnson" <johnso...@ev1.net> wrote in message

news:3ed982d9$1@newsgroups.borland.com...

Quote
> I want to use PaintBox 2 and 3 as invisible buffers

You should not be using PaintBoxes like that.  Use an in-memory bitmap
instead, such as a TBitmap.  It has its own Canvas you can draw it while
remaining only in memory, not visual.

Gambit

Re:Why Doesn't This PaintBox Code Work?


In BCB5.0 the TBitmap canvas has a bug which makes the TBitmap canvas go
blank when the bitmap gets to large. I have good code for buffers using the
TBitmap canvas but it will not work for any large size image. I am trying to
find a replacement for the TBitmap because of its size bug. My problem is
that I can not find any BCB buffer method which will allow a large buffer
canvas.

regards
larry johnson.

"Remy Lebeau (TeamB)" <gambi...@yahoo.com> wrote in message
news:3ed98b25$1@newsgroups.borland.com...

Quote

> "Larry Johnson" <johnso...@ev1.net> wrote in message
> news:3ed982d9$1@newsgroups.borland.com...
> > I want to use PaintBox 2 and 3 as invisible buffers

> You should not be using PaintBoxes like that.  Use an in-memory bitmap
> instead, such as a TBitmap.  It has its own Canvas you can draw it while
> remaining only in memory, not visual.

> Gambit

Re:Why Doesn't This PaintBox Code Work?


Quote
"Larry Johnson" <johnso...@ev1.net> wrote in message

news:3eda0e8a@newsgroups.borland.com...

Quote
> In BCB5.0 the TBitmap canvas has a bug which makes
> the TBitmap canvas go blank when the bitmap gets to large.

TBitmap is just a suggestion.  You could always use the Win32 API directly
to work with an HBITMAP manually instead.  The point is, use an in-memory
bitmap, whether it be VCL or API.  Don't use TPaintBox non-visually.

Gambit

Other Threads