Thread: Forms in Borland C++ Builder

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    20

    Forms in Borland C++ Builder

    Hi,

    I have written a small piece of code that output some text in the command window using 'cout<<whatever'. I'd like it to print out in the Form(e.g a Label or something) instead. What do I need to do?
    Thanks
    sKar

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    20

    Problem sorted but....

    I used Edit1->Text = "whatever"; inside the:
    void __fastcall TForm1::ButtonZClick(TObject *Sender)
    {
    }

    however, it only reacts when I click on the button.
    I want to have an if loop outside the onclick action, for checking states in the program, but I can't use the Edit1->Text = "whatever"; in the main program as an error msg of undefined symbol 'Edit1' comes up.

    how do I change the caption as soon as the program is running, rather than having to click something first?

    Thanks
    sKar

  3. #3
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343

    Question

    Hmmm, I´m dont understand the question??? Should it change caption on the form when the program starts running or??? Give me some more info and I think I can help you.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    20
    There are 2 state in my program, top and bottom
    by enum state{top, bottom} currentstate=top;

    the inital state is top and I want the Label->Caption to display "a to E"
    then when I click on a button, the currentcurrent state change to bottom and the label->caption becomes "A"

    I can make the caption change when I click the button, but not when the currentstate is initialised to top.

    my idea was something like:
    int main()
    {
    if(currentstate==top)
    Label1->Caption="A toE";

    then the code for the button click
    }

    but the Label1 in the main program is undefined!

  5. #5
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Oki, I think I get the point. First you should initiate currentstate to top in the OnCreate (or FormCreate) event for the form. Then in the onlick-event


    void __fastcall TForm1::ButtonZClick(TObject *Sender)
    {
    //Change currentstate each time you click on button
    if(currentstate==top)
    {
    Label1->Caption="A toE";
    currentstate = bottom;
    }
    else
    {
    Label1->Caption="A";
    currentstate = top;
    }
    }

    Hopefully this should work. Did it???

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    20
    Done, Thanks!

    more questions in other threads

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Good introduction to Windows Forms?
    By jcafaro10 in forum C# Programming
    Replies: 1
    Last Post: 05-19-2009, 06:11 PM
  2. Replies: 2
    Last Post: 04-02-2009, 04:40 AM
  3. C# Game using Forms
    By ejohns85 in forum C# Programming
    Replies: 1
    Last Post: 12-16-2006, 05:35 PM
  4. THE END - Borland C++ Builder, Delphi, J Builder?
    By Davros in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-28-2006, 11:23 PM
  5. C++ Builder Forms
    By learning110 in forum Windows Programming
    Replies: 0
    Last Post: 05-26-2003, 04:45 PM