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

        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...


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

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

    MESSAGE_HANDLER(WM_PAINT, TMessage, OrderedRePaint)

//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");


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


Other Threads