Board index » cppbuilder » displaying variable output in a GUI

displaying variable output in a GUI

I need to display a variable on a form.  I can do this, but only inside
of a buttonclick function.  I was wondering if there was a way to use
textout on a form to display a variable.  I have gotten textout to run
when it is not inside of a buttonclick function, but I can't find the
output.  Please Help!!!

Thanks,  Steve

 

Re:displaying variable output in a GUI


Stephen,
        TextOut won't work in those events that trigger a Form repaint.  To get
this to work, you can TextOut to an TImage's Canvas such as...

Image1->Canvas->TextOut(...);

or alternatively, trap the WM_PAINT message and manage the repaint...

//in header file...
public:
       void virtual __fastcall OrderedRePaint(TMessage &Msg);

BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER(WM_PAINT, TMessage, OrderedRePaint)
END_MESSAGE_MAP(TForm)

//in source file...
void __fastcall TForm1::OrderedRePaint(TMessage &Msg)
{
    TForm::Dispatch(&Msg); // Let everything else draw first

    // Finally draw your stuff
    Canvas->TextOut(3, 3, "My Text");

Quote
}

You could also consider using a TLabel component, and setting the
Caption property.
Good luck.

//Damon

Other Threads