Thread: Borland help please (GUI)

  1. #1
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154

    Borland help please (GUI)

    Hi,

    I've been using Dev-C++ for quite a while now and I'm very happy with it, but since I need to make a graphical interface now, I've bought "Borland C++ Builder 6 Enterprise Suite" (well I didn't - my boss did for me ).

    I've been told it's quite easy to create a user interface with buttons for an existing program. My problem is... I haven't got a clue where/how to begin. I've created a new project and added the existing c code. Then I've created a new form and added some buttons... but what's next?!

    For example, the main of my program basically is a switch/case with 9 functions. Now I've made 9 buttons on my form... but how on earth do I link these to my switch/case functions?

    Hope someone can help me out here... maybe there's a good tutorial online? I've Googled and searched through the Borland support pages but found nothing useful.

    Thanks in advance for any help!

    René
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    You're using a C++ Builder for C programming... which means the code for all those buttons are likely written in C++. Which means, you're no longer doing C programming, you're doing C++ programming.

    Unless Borland has C versions of those buttons, then they're likely objects of a button class. Which means they most likely have a function that says whether they're pressed down or not. That's what should be controlling your conditional.
    Code:
    if (button1.pressed()) { // ...
    }
    if (button2.pressed()) { // ...
    }
    ...and that of course is looping until you get keypresses.
    Sent from my iPad®

  3. #3
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    Quote Originally Posted by SlyMaelstrom
    You're using a C++ Builder for C programming... which means the code for all those buttons are likely written in C++. Which means, you're no longer doing C programming, you're doing C++ programming.
    To be quite honest, I'm not really sure in what language I'm programming anymore (don't know the exact differences between C and C++). I do know that the extension of my program is .cpp and if I change it to .c and compile it, it works too (after including stdbool.h)... I'm only posting in this subforum, because when I have a look in the C++ subforum, I see a lot of weird characters that I haven't ever used (chout, >>, etc.) I'm starting to think my program is a weird kind of mix between C and C++. Nevertheless: the responses in this part of the forum have always been very helpful to me!

    Quote Originally Posted by SlyMaelstrom
    Unless Borland has C versions of those buttons, then they're likely objects of a button class. Which means they most likely have a function that says whether they're pressed down or not. That's what should be controlling your conditional.
    Code:
    if (button1.pressed()) { // ...
    }
    if (button2.pressed()) { // ...
    }
    ...and that of course is looping until you get keypresses.
    Hmm thanks, I'll try and see if I can get that to work.
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  4. #4
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    You were right SlyMaelstrom, there is a button click command:

    Code:
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
       printf("\a");
       printf("blah");
    }
    I've tried the above but it doesn't work... most likely because it doesn't have a DOS screen to printf() the text to..? How can I make a field on a form that displays text?
    Again, these are really general questions because I can't find any background information and/or online tutorials... can anyone help me out?

    Thanks.
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    All of that console I/O is going to have to go. It has no place in GUI. In the same manner as the buttons, all input fields are also objects, and as such contain a text field. You really have to look at the documentation, and they probably give some sample programs as well.
    Sent from my iPad®

  6. #6
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    Hmmm yeah... I didnt get documentation as I bought it on my student account... the package existed of two cd's, nothing more. The help function isn't very helpful either and I see no example programs...
    I must have been fooled when I was told this was supposed to be easy...?
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

  7. #7
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    I was really hoping for some feedback here, but the question is probably too general for a good answer.
    I think I'll need to find a book for this...
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Convert Windows GUI to Linux GUI
    By BobS0327 in forum Linux Programming
    Replies: 21
    Last Post: 11-27-2005, 04:39 AM
  2. .NET And GUI Programming :: C++
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 01-27-2002, 04:22 PM
  3. GUI Programming :: C++ Exclusive
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 01-25-2002, 03:22 PM
  4. C++: Reference Book, GUI, Networking & Beyond
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 11-10-2001, 08:03 PM
  5. GUI (Graphical User Interface) Help Needed
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-11-2001, 10:35 AM