Hi,

I have a C++ program (built in Visual Studio 2010) and want to add a user interface to package it up. I've been reading around about windows forms and the win32 API, and found loads of tutorials showing how to create interfaces but I can't find any advice on linking everything together.

Basically, what I want to know is what is the best way (it may not be windows forms or win32) for me to create a GUI if I already have a working program in VS? and can anyone recommend a tutorial/reference that explains how to use a GUI to call and run a C++ program.

Please excuse my ignorance. I'll happily admit I'm a complete novice.

Thanks in advance,

Victoria

:o What a question.. You can use Windows Forms (.Net).. Try it. start a new project, give it a name.. choose WindowsForm Application.. it will set up a default looking form where you can drag and drop controls..

Copy your code to whatever you want it to do.. basically you double click the control and put the code that that control is supposed to do. Remember though your program is probably a console program so your going to need to revise some of the code..

Then there is Windows 32 API programming.. which I see as a bit harder when it comes to making GUI's due to me having a hard time figuring out where to place the buttons on the main form and you'd need to know the co-ordinates of where you want the button position to be, etc.. But if you do learn this, it will be very easy for you and does not require the .Net framework at all.. which is a Plus for most users (people wont have to download .Net framework to run your program)

using .NET means making your native C++ project a Mixed Mode assembly that contains both native machine instructions and MSIL. If you have compilation trouble using a mixed mode then you may want to look into using the #pragma managed and #pragma unmanaged.

As far as using it to make a GUI for your C++ project, click on your project name in the solution explorer & select add-> new item : Windows Form.

You can also use QT (which is not free) wxWidgets (I think it's free), MFC, or just native Win32 API calls.

For MFC you may have a little difficulty unless you take a lot of time trying to understand Microsoft's framework and then how to use it for your applications.

If you don't mind distributing your application with a couple of DLLs you can use QT (afaik). You don't have to distribute your source under the LGPL (as far as I know, and I'm NOT a lawyer so don't quote me on this).

QT is very nice IMO.

I would tak triumphost's approach. Start a new CLR/C++ Windows Forms project so that you can graphically design the form(s) the way you want them. That is a hell of a lot easier and faster than using pure win32 api functions. Then add in the code you wrote for that console program. How hard or easy that will be depends on the console program -- some may have to be rewritten to be integrated in with the CLR/C++ program.

commented: I'm still learning CLR/C++ I think it's a good technology,I'm with you. +7

There are 2 options to you.

1. Develop everything with C++/C (using QT/Windows Forums 2.0(like AD said)/wxWidget/win32 API).
2. Write a simple HTA (HTML application ) as your nice interface and link it with
your C++/C console mode program.


The second method is not bad as many ppl say, I have a popular dictionary application
which is written in that way, and yes it's used in the industry.
For a example if you put the "call of duty" DVD to your DVD rom you'll get a
welcome screen with menus that prompt you to run "install" ,"install directx" ,"
check for your computer combatibility" ,etc.

If you need some help on how to link your HTA application with your C++/C console
application just ask here.

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.