Thread: How do I make a GUI interface?

  1. #1
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463

    How do I make a GUI interface?

    What applications, special compilers do I need to make a GUI interface in C coding?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No special compiler needed. You may need some extra tools such as a "resource editor" [that is what you use to design dialogs, icons, menus etc].

    Which architecture is this for?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Windows Vista.
    What are some good free 'resource editors' ?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Get Visual Studio express - it comes with a good resource editor, compiler and IDE. It's in my opinion the best IDE for Windows.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Thanks again Mats

  6. #6
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Will Visual C++ compile C as well?

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Yes, but you have to set it to compile the code as C code (otherwise it will happily compile C code that is valid C++, but may choke in cases where C and C++ differ, and produce object code with C++ name mangling). If I remember correctly (but I may be wrong), there is limited or no support for new features introduced in C99.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Actually, it chooses "intelligently" based on the filename. If you call a file "something.c" it compiles as "C", if you choose the name "something.cpp", it will compile as C++.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Nov 2007
    Posts
    10
    Also if I'm not mistaken (and I very well could be. :P) using the CL command from the visual studio command prompt compiles C code, at least it doesn't seem to compile any of my C++ code.

  10. #10
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Why would you want to write a Windows program in C instead of C++?

  11. #11
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Because? There's no reason not to use C, after all the Win32 framework is written in C.

  12. #12
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    If you write it in C++ and plan to have an OO program, you have to create classes that essentially wrap the precedural Windows API functions anyway. You also have to use char arrays (or similar) instead of std::string when using buffers with the Windows API functions that require them. My point is that even if you decide to make an OO framework, you still have to write a relatively decent amount (depending on the size of your framework/program I suppose) of C-style code anyway to glue your OO stuff to the procedural style of the Windows API.

    Essentially, depending on what you want to do, you can write Windows GUI code in either C or C++. It doesn't matter how you interface with the API or with your program, except with whatever is easier to write for and interface with from your own perspective.
    Last edited by MacGyver; 11-22-2007 at 07:39 PM.

  13. #13
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by MacGyver View Post
    If you write it in C++ and plan to have an OO program, you have to create classes that essentially wrap the precedural Windows API functions anyway. You also have to use char arrays (or similar) instead of std::string when using buffers with the Windows API functions that require them. My point is that even if you decide to make an OO framework, you still have to write a relatively decent amount (depending on the size of your framework/program I suppose) of C-style code anyway to glue your OO stuff to the procedural style of the Windows API.

    Essentially, depending on what you want to do, you can write Windows GUI code in either C or C++. It doesn't matter how you interface with the API or with your program, except with whatever is easier to write for and interface with from your own perspective.
    Sure, if you want to reinvent the wheel for every program you write... There's a lot of code out there that already does most of the work for you (some free, and some for sale).
    As for passing buffers to C functions, you can use std::vector for that.

  14. #14
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Quote Originally Posted by cpjust View Post
    Why would you want to write a Windows program in C instead of C++?
    That is a silly question. You may as well ask why people use C++ instead of VisualBasic or C#. I've been using straight C since 1998 and have never been limited on resources or code production times. Plus it creates smaller and faster executables.

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Preferance, I guess. I can't see how someone wants to write a C program seeing how it lacks OO and good functionality such as smart pointers, vectors, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. First time GUI program tips and help needed.
    By naja77 in forum C Programming
    Replies: 1
    Last Post: 08-01-2008, 08:28 AM
  2. How do you make a program to interface with another?
    By Finchie_88 in forum C++ Programming
    Replies: 6
    Last Post: 08-24-2007, 03:48 AM
  3. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  4. Trying to make a menu screen
    By circle in forum C Programming
    Replies: 0
    Last Post: 12-07-2004, 06:06 AM
  5. gui interface tutorials?
    By gamer in forum C++ Programming
    Replies: 2
    Last Post: 11-22-2004, 02:36 PM