Hi Ken,
Quote:> I am migrating to C++ Builder 3.0 from Visual Basic and I have found the
> on-line help to be adequate. However, I have not found any on-line help
> to address the following question:
> What is the recommend method of "displaying" text on a form? In
> particular, can one use 'printf' in order to display a string at
> coordinates (X,Y) on a form? Or must one always use labels and other
> controls?
Coming from Visual Basic, I'm sure you're already familiar with the idea of a
device context and the WM_PAINT message. Namely, any persistent text or
graphics that need to be displayed on your Form, must be rendered to the device
context of your Form (or one of its controls), and can be done in response to
the WM_PAINT message.
C++Builder provides the OnPaint event as an encapsualtion of the WM_PAINT
message handler. That is, you can provide a handler for your Form's OnPaint
event and render directly to the Form's device context (via the TForm::Canvas
property). Here's a simple example...
void __fastcall TForm1::FormPaint(TObject *Sender)
{
const int X = 10, Y = 20;
Canvas->TextOut(X, Y, "My Text!");
Quote:}
The TLabel component actually wraps the above code -- it uses the WM_PAINT
message of it's Parent to render its Caption to the Form's Canvas. Either
approach is fine, the latter is simpler.
Hope this helps.
--
Damon Chandler
http://bcbcaq.freeservers.com