If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Console to GUI

Can someone please refer to my a book or website where I can make a transition from console programming to GUI programming. I'm totally confused about this. I know how to program in console and can make a whole program based on console. I also know the OPP programming, but it's clear that nobody uses console programming anymore. Your help will really help.

However, hardly anyone programs windows now using the basic WIn32 APIs. Most use some sort of graphical framework. There are various available - some of which are cross platform. However, the most common one for Windows produced by Microsoft is the MFC framework. The best intro book for this is
Programming Windows with MFC by Jeff Prosisehttp://www.amazon.co.uk/Programming-...rogramming+mfc

MFC provide a c++ 'gui' wrapper around the Win32 APIs. Note that you need to be quite knowledge about c++ classes to use MFC - particularly inheritence and virtual functions.

To program windows is not trivial and there is an awful lot to learn at the beginning to get your gui program to display a window showing 'Hello Windows' - so start with something simple and work up. You have to know how it all fits together and how it is expected to work.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: Console to GUI

Agreed. Another example is programming service applications (or daemons as they're called in the Linux world.) They are technically console programs as well that are highly used everywhere. They probably don't receive all the glamour of the GUI programming though.

Re: Console to GUI

Originally Posted by omolajat

Can someone please refer to my a book or website where I can make a transition from console programming to GUI programming. I'm totally confused about this. I know how to program in console and can make a whole program based on console. I also know the OPP programming, but it's clear that nobody uses console programming anymore. Your help will really help.

I would advise learning Qt if you want to learn GUI programming in C++. It provides a nice abstraction that let's you program GUIs productively without getting bogged down too much in gritty details. It's not great for everything, but it makes a lot of things really simple. One problem with Qt is that it takes some effort to create really native looking and feeling programs (on Windows, at least). The default options in Qt do not give you a native look and feel. So, if you want this, you'll have to pay attention.

I would not recommend learning how to program using win32 (i.e. without any supporting framework). It can be useful if you really want to learn how windows works at a low level, but it is not an effective way to write GUI programs.

It's useful to know how to program in MFC, but I'm not sure I would recommend learning it. I believe there are plenty of Windows programs developed with MFC and you can use it to program modern Windows desktop applications effectively, but it also shows that it is an old framework (which is both a good and a bad thing). If you decide to learn MFC, you should side-step the doc-view framework and find other supporting tools for such things as rescaling dialog contents and translating GUIs. The biggest problem with MFC is that you tie yourself to MS Visual Studio (not the free Express edition).

There are also other GUI frameworks for C++, but I'm not familiar with them. You could also consider learning C# for GUI programming and learning C++/CLI for interop between GUI and core processing that is best implemented in C++.

Cheers, D Drmmr

Please put [code][/code] tags around your code to preserve indentation and make it more readable.

As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Re: Console to GUI

I would not recommend learning how to program using win32 (i.e. without any supporting framework). It can be useful if you really want to learn how windows works at a low level, but it is not an effective way to write GUI programs.

I agree, as per my previous post #2, but I still think that a basic understanding of WIN32 programming is very helpful for gui programming using frameworks such as MFC.

All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Re: Console to GUI

A few words to clarify a little bit:
A console application is a character-mode application which usually gets input and gives output in a console (although not obviously).
A GUI application is an application that deals with system Graphical User Interface.
Although isn't a brilliant idea, a console application may deal with GUI, as well.
An application that shows nothing isn't obviously a console one (may be a service, a device driver or even a Win32 application using or not MFC or other framework).

Re: Console to GUI

Agreed. Another example is programming service applications (or daemons as they're called in the Linux world.) They are technically console programs as well that are highly used everywhere.

This isn't correct either, while there are quite a few "lazy" services that are written as console exe's and rely on svrany.exe to actually behave like a service, a service is really something else entirely. A console exe being loaded by a service stub, doesn't make that console exe "a service". You could just as well create a gui exe and load it as a service with svrany.

Deep down, the difference is a flag in the exe header that says "I'm a console exe" or "I'm a gui exe", and how the CRuntime works together with that. (gui exe's have winmain() while console exe's have main(), but that's really just a runtime layer around a WinMain that ties the runtime handles to the input/output console window).

From a windows POV, a console exe means that the OS will create a console window and tie the input output streams to the console. A "Gui" exe doesn't get a console from the OS, and input/output streams are tied to the null device.

Once this is done...
A GUI exe can create a console window (AllocConsole) if it wants and tie input/output to it if it so desires it can also create any number of other "gui" windows. Or it can decide to not create any window at all.

A console exe, can equally create additional console windows as well as create any number of other "gui" windows.

Note that if you use a framework like MFC, QT, they typically take care of WinMain/main/DllMain/... so you don't have to worry about that part.

Other than "how the OS starts the exe" (create a console window or not) there isn't really any difference to Windows.