Board index » cppbuilder » Unexpected color change

Unexpected color change


2006-06-13 04:30:26 AM
cppbuilder51
What is the default Brush color for a TPaintBox's canvas? When a script
runs from the OnCreate event, PaintBox->Canvas->Brush->Color returns
clWhite, but when the same script runs from a button's OnClick event,
the property returns clBtnFace. I have tripple-checked, and confirmed,
my code is not causing this. This only happens between the following
statements in the WinMain() function:
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
 
 

Re:Unexpected color change

How can the settings be invalid?
Is the same true for a TImage?
 

Re:Unexpected color change

What control should I use that would allow the user to make changed to a
canvas and have the changed automatically painted?
 

{smallsort}

Re:Unexpected color change

"JVines" < XXXX@XXXXX.COM >wrote in message
Quote
How can the settings be invalid?
Because an HDC is assigned to the Canvas only when the component is actually
in a state of being drawn by the OS, such as in response to the WM_PAINT
message.
Quote
Is the same true for a TImage?
TImage is different than TPaintBox. TImage stores an in-memory graphic.
Accessing the TImage's Canvas accesses the Canvas of the graphic. You can
make changes to the graphic outside of the OnPaint event. When the TImage
is being drawn, it merely copies the current graphic to whichever HDC it is
supposed to be drawing to.
Gambit
 

Re:Unexpected color change

"JVines" < XXXX@XXXXX.COM >wrote in message
Quote
What control should I use that would allow the user to make
changed to a canvas and have the changed automatically painted?
You can continue using a TPaintBox for that. Just keep track of the changes
in between OnPaint event, such as to a TBitmap, and then copy the changes to
the TPaintBox Canvas whenever the OnPaint event is triggered.
Gambit