-
November 30th, 2013, 04:44 PM
#1
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.
-
November 30th, 2013, 05:16 PM
#2
Re: Console to GUI
Basic Windows programming resolves around the WIN32 set of APIs that can be used from c/c++ programs. The best book to start with is programming Windows by Charles Petzold
http://www.amazon.co.uk/Programming-...etzold+charles
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 Prosise
http://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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 30th, 2013, 05:44 PM
#3
Re: Console to GUI
Originally Posted by omolajat
but it's clear that nobody uses console programming anymore.
Not true.
Many, if not most of the programs you run now are console programs with a GUI wrapper around them. The Visual C++ compiler you're using now is a console program (cl.exe), so is the linker (link.exe).
Regards,
Paul McKenzie
-
November 30th, 2013, 06:04 PM
#4
Re: Console to GUI
NB to my post #2. Note that if you are using the free Visual Studio Express (as opposed to the paid versions), it doesn't come with MFC.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 30th, 2013, 06:24 PM
#5
Re: Console to GUI
Originally Posted by Paul McKenzie
Not true.
Many, if not most of the programs you run now are console programs with a GUI wrapper around them. The Visual C++ compiler you're using now is a console program (cl.exe), so is the linker (link.exe).
Regards,
Paul McKenzie
Um, compilers are more the exception as most GUI programs are definitely not UI shells around console apps.
-
November 30th, 2013, 06:46 PM
#6
Re: Console to GUI
Originally Posted by Arjay
Um, compilers are more the exception as most GUI programs are definitely not UI shells around console apps.
I'm really responding to the OP's claim that "nobody uses console programming anymore." That simply isn't true.
Regards,
Paul McKenzie
-
November 30th, 2013, 11:59 PM
#7
Re: Console to GUI
Originally Posted by Paul McKenzie
I'm really responding to the OP's claim that "nobody uses console programming anymore." That simply isn't true.
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.
As for the OP's question, I can't imagine you haven't tried something like this.
-
December 1st, 2013, 05:52 AM
#8
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
-
December 1st, 2013, 07:29 AM
#9
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
December 4th, 2013, 10:50 AM
#10
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).
What type of application results in a MSVC build, is set by /SUBSYSTEM linker option.
Last edited by ovidiucucu; December 4th, 2013 at 11:09 AM.
-
December 5th, 2013, 07:56 AM
#11
Re: Console to GUI
Originally Posted by dc_2000
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.
Last edited by OReubens; December 5th, 2013 at 07:58 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|