1,105,386 Community Members

How do I make a GUI in C++

Member Avatar
Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 5 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
-1
 

Hello,
I am new to make programs. So far I can just do logical stuff like math in a dos window. I now want to move on to making actual windows programs. Does anyone know how to make a GUI in C++ for a windows application? Any reading online or in a book that I can look up? And I was also wondering once you have your code and your GUI how to make the code become the program?
Any help would be great,
Thanks

Member Avatar
BountyX
Posting Whiz in Training
230 posts since Mar 2004
Reputation Points: 7 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello,
I am new to make programs. So far I can just do logical stuff like math in a dos window. I now want to move on to making actual windows programs. Does anyone know how to make a GUI in C++ for a windows application? Any reading online or in a book that I can look up? And I was also wondering once you have your code and your GUI how to make the code become the program?
Any help would be great,
Thanks

http://www.winprog.org/tutorial/ -- That will teach you how to make a GUI for Windows only in window's native GUI implement (API)

To implement your code you need to respond to a user's action, i.e clicks a button then do i = 1+1;

Member Avatar
infamous
Junior Poster in Training
77 posts since Mar 2004
Reputation Points: 26 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

the definitive book to pick up would be charles petzolds "programming windows"

Member Avatar
FireNet
Posting Whiz in Training
256 posts since May 2004
Reputation Points: 64 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

It's easy once you get to know the windows message handling
[I will assume you checked out http://www.winprog.org/tutorial/ it's good]

Hey read everything and if you need more come back here..

You cant compile GUI like dos, you will have to change some options in your compiler or you will get an error on make like:

WinMain() not referneced ..... bla...bla or someting like that

Member Avatar
Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 5 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Yeah I read most of the tutorial and havent got a cahnce to finish it yet. I heard that using a library would be an easier way of making a GUI so I found one called fox-toolkit. The only problem is that I dont know how to get it to work or install.
Right now I am using Bloodshed Dev-C++

Member Avatar
FireNet
Posting Whiz in Training
256 posts since May 2004
Reputation Points: 64 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Dump the fox-whatever.There are alot of such stuff which have no future. Get rid of Bloodshed also.I have used it and some standards are not supported.Borland Command line complier (they give that for free) is much
better.

Window's native GUI implement (API) is also good to know it's not so tough.

Member Avatar
Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 5 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

That wasn't very helpful. And the new version of Dev-C++ is pretty good.
I still need to know how to install a new library if any one could help. I know that the library is intergrated into the API to make it easier.

Member Avatar
alc6379
Cookie... That's it
2,752 posts since Dec 2003
Reputation Points: 105 [?]
Q&As Helped to Solve: 154 [?]
Skill Endorsements: 4 [?]
Team Colleague
 
0
 

If the library is integrated into the API, then you shouldn't have to install it.

...What GUI library are you trying to install, anyways? There are bunches of them: Gtk, Qt, and Motif are examples of GUI libraries-- what's the name of the one you're trying to install?

Member Avatar
liliafan
Junior Poster
117 posts since Apr 2004
Reputation Points: 53 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Dump the fox-whatever.There are alot of such stuff which have no future. Get rid of Bloodshed also.I have used it and some standards are not supported.Borland Command line complier (they give that for free) is much
better.

What don't you like about bloodshed? I have used it a bit and quite like it, I prefer it over Visual C++ 6, and so far as standards are concerned it is basically GNU GCC 2.95 (last time I checked) ported to windows which is very standards compliant.

Member Avatar
Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 5 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Its called fox-toolkit. I got it from their website at www.fox-toolkit.org. I tried to get Gtk but it wouldn't let me download it from the site. If you know where i can get it that would be great. Thanks.

Member Avatar
alc6379
Cookie... That's it
2,752 posts since Dec 2003
Reputation Points: 105 [?]
Q&As Helped to Solve: 154 [?]
Skill Endorsements: 4 [?]
Team Colleague
 
0
 
Member Avatar
Dark_Omen
Posting Pro
573 posts since Apr 2004
Reputation Points: 5 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

I have tried to install the gimp tool-kit before and it did not work, I think i was installing it wrong. How do you do it?

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
0
 

Download the BCX system from:

http://www.rjpcomputing.com/programming/bcx/devsuite.html

It's free, creates C or C++ code you can look at and learn from. Super help file and lots of GUI samples. Look at BCX as a preprocessor. I use it all the time, a great learning tool.

Member Avatar
hax_hp
Newbie Poster
4 posts since Nov 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Dude my advice would be to go to C# instead..C++ is for rough programming..It would help you more if you were aming to program in other platforms like Linux for example..But if you want to program in Windows the best way to fo is C# and the good news is that C# is also supported in platforms like Linux..I believe there is a library that lets you do this. The name is Mono and there is a very easy to learn library to create your gui called gtk-sharp..You can even use XML to create a gui..But anyways if you want to give C# a try do the following..

Go to C:/WINDOWS/Microsoft.NET/Framework/[Find Version 2]
Then find a program named csc.exe (That is a CSharp compiler shipped with .NET Framework)
Create a batch file in your Desktop named CS.bat
Add the following commands to it change the Version number between the brackets

path C:/WINDOWS/;C:/WINDOWS/System32;C:WINDOWS/Microsoft.NET/Framework/[Version 2]
cls

The create a source file to test this out here is the code make the name Test.cs

using System;
using System.Windows.Forms;

class Test {
                  
                 static Form frm1;

                 public static void Main(String[]Args)
                 {
                                   frm1 = new Form();
                                   frm1.Text = "Test Window";
                                   frm1.Show();
                                   MessageBox.Show("This is my first C# Program and Window");
                                   Application.Run();
                 }
}

Yeah then you have to compile it so Open a Command Prompt window and do this

cd Desktop
CS
csc /t:winexe /r:System.Windows.Forms.dll Test.cs
Test

Wallah there you go man you see how easy you should try it..

Member Avatar
wamuti
Newbie Poster
23 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello,
I am new to make programs. So far I can just do logical stuff like math in a dos window. I now want to move on to making actual windows programs. Does anyone know how to make a GUI in C++ for a windows application? Any reading online or in a book that I can look up? And I was also wondering once you have your code and your GUI how to make the code become the program?
Any help would be great,
Thanks

Also try MFC(Microsoft Foundation Classes). It is an encapsulation of Windows API. To make them work just compile, build and execute the ordinary way!. As easy as that(You can even skip compile:) ).

Member Avatar
Ancient Dragon
Achieved Level 70
27,632 posts since Aug 2005
Reputation Points: 5,232 [?]
Q&As Helped to Solve: 3,037 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

Also try MFC(Microsoft Foundation Classes). It is an encapsulation of Windows API. To make them work just compile, build and execute the ordinary way!. As easy as that(You can even skip compile:) ).

I agree MFC is pretty easy to use, but it isn't free. Neither VC++ 5.0 Express nor VC++ 8.0 Express supports it. If you want to use MFC then you have to buy the Stanrard or better versions for $$$$.

VC++ 6.0 should be scrapped for the newest Express version because of compatability problems.

Member Avatar
Maulth
Junior Poster in Training
65 posts since Mar 2008
Reputation Points: 4 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Wonderful tutorial, I thank you very much. I've been doing C++ for 2 years now (school) and I've only done logic programming.

Member Avatar
codeaa
Junior Poster in Training
98 posts since Feb 2008
Reputation Points: 3 [?]
Q&As Helped to Solve: 12 [?]
Skill Endorsements: 0 [?]
 
0
 

The guy asked for advice on _C++_ GUI programming. You say "C++ is for rough programming"? What does that mean? C++ is very well suited for GUI programming.

Anyone else interested in C++ GUI programming, look into gtk, Qt, or wxWidgets and there are others.

I know C# and I'm not trying to be critical of it but my advice in evaluating your options when starting a project is to look at portable options and work from there with consideration for the requirements of your project and if you end up choosing C#, that's fine. There is Mono to make C# a bit more portable but there are still issues there. Personally, C# would not be a starting point for me in choosing my options for most of my projects.

You suggest gtk-sharp as an option. You then have gtk in C++ or C# (among others). At this point you should be considering your language by it's suitability to your project.

Dude my advice would be to go to C# instead..C++ is for rough programming..It would help you more if you were aming to program in other platforms like Linux for example..But if you want to program in Windows the best way to fo is C# and the good news is that C# is also supported in platforms like Linux..I believe there is a library that lets you do this. The name is Mono and there is a very easy to learn library to create your gui called gtk-sharp..You can even use XML to create a gui..But anyways if you want to give C# a try do the following..

Go to C:/WINDOWS/Microsoft.NET/Framework/[Find Version 2]
Then find a program named csc.exe (That is a CSharp compiler shipped with .NET Framework)
Create a batch file in your Desktop named CS.bat
Add the following commands to it change the Version number between the brackets

path C:/WINDOWS/;C:/WINDOWS/System32;C:WINDOWS/Microsoft.NET/Framework/[Version 2]
cls

The create a source file to test this out here is the code make the name Test.cs

using System;
using System.Windows.Forms;

class Test {
                  
                 static Form frm1;

                 public static void Main(String[]Args)
                 {
                                   frm1 = new Form();
                                   frm1.Text = "Test Window";
                                   frm1.Show();
                                   MessageBox.Show("This is my first C# Program and Window");
                                   Application.Run();
                 }
}

Yeah then you have to compile it so Open a Command Prompt window and do this

cd Desktop
CS
csc /t:winexe /r:System.Windows.Forms.dll Test.cs
Test

Wallah there you go man you see how easy you should try it..

Member Avatar
T3chn0logic
Newbie Poster
1 post since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-2
 

@ those who aren't already using any version of Microsoft Visual Studio:

You n00bs... Why do you continue to you use third party compilers? If your even remotely into development, you all need to get Microsoft Visual Studio. If on *nix machines, get WINE, and then get MSVS. MSVS is by far the best development workstation for any developer. And for the love of god, don't f***ing complain about it costing too much money. <snipped URL>
And if your one of those 'ethical' people who are religously banned from downloading illegal torrents, get a job, and use your second paycheck to buy MSVS.

~T3chn0logic

Member Avatar
tc2617
Newbie Poster
1 post since Jul 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

First of all reading the thread has been very nice. I've been trying to avoid working with gui's for quite a while now, but they're tending to catch up to me. Thank you for the link to the tutorial, because it just makes it that much easier to figure this stuff out.

@ those who aren't already using any version of Microsoft Visual Studio:

You n00bs... Why do you continue to you use third party compilers? If your even remotely into development, you all need to get Microsoft Visual Studio. If on *nix machines, get WINE, and then get MSVS. MSVS is by far the best development workstation for any developer. And for the love of god, don't f***ing complain about it costing too much money. <snipped URL>
And if your one of those 'ethical' people who are religously banned from downloading illegal torrents, get a job, and use your second paycheck to buy MSVS.

~T3chn0logic

and T3chn0logic, dude, chill out. Your post and my post here really have no bearing on this thread. But if you will consider this, the only thing that really matters when developing software is how you or your client wants it to run. Microsoft products are not the end all solutions for development. If you really consider what you are using for programming, then using something like MSVS, Eclipse, Scite, Dev-C++, Vi, Emacs, or Jed are just tools. None of these programs are final solutions for development platforms for all people. They are simply different programs that different people find effective to use. Sure MSVS has a proprietary compiler, but it depends on the program's intention and the programmer as to which compiler is a good choice.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article