Hi,

I wish to create a very simple GUI for my C++ code

I have written a simple C++ program using Microsoft Visual C++ Express. The details of the program functionality are not really important. Currently the user enters a number (1-5) on the command line and presses enter. A few lines of C++ code are executed depending on which number is entered.

It is a fairly simple program. I would really like to make a simple GUI for this program. It would just need to be 5 buttons. If the user clicked on a button, the corresponding code would be executed.

This would be much more user friendly than a command line interface.

Ideally, I would also like to be able to create an executable file (.exe) that I could move to another computer and run.

Can anyone give me a starting point on how I should do this? I imagine this must be the simplest kind of GUI, and relatively simple to accomplish.

Thanks,

aallan

There are two options, neither of which will be a quick learn unfortunately (certainly that depends on the amount of time you are willing to put into it). The express edition offers you two options for doing GUI. The first is Win32 API which is quite powerful but can also be unwieldy as well. A good starting tutorial for that is http://www.winprog.org/tutorial/. The other option is to use the Winforms (.NET) via CLR (using C++/CLI). If you are familiar at all with .NET programming from C# or VB this may be easier, but you'll have to rewrite at least some of your code for this particular dialect of C++ (strings are quite different). There are other options available. Were you to have the full version of Visual Studio you could use MFC which is more tightly bound to C++. Options outside of the Microsoft world which are free in one form or another are Qt and wxWidgets.

Not the answer you wanted to hear I know. Post back if you have any questions of course.

Hi, Thanks so much for your reply.

I have tried to use Win32 API using that tutorial. I will perhaps have another go based on your recommendation.

The Win32 API does seem very powerful but I just thought there must be a simpler way to do it, considering I only require 5 little buttons.

Have you got any thoughts about how I could create an executable file to run on any computer?

Thanks again

I suggest wxWidgets ;)
It is simple, well supported and Heavily documented and very liberal licence.
Its executables are also small

Its executables are also small

What do you mean by small? A year ago I downloaded a wxWidgets demo that had a few GUI elements on it (buttons, listboxes, etc.) and it was around 800K or something like that. A Win32 Sdk style program like that would have been around 20k.

Sure, It should be larger than bare win32 but I meant small in comparison with space available. Those who comes from wxPython will know that its size is bigger (sometims 10s of MB).

But it has advantage over win32 if you want to go cross platform

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.