I am using Dev C++. I am new to this program as well as C++. I have written a samll piece of test code. This has been compiled and added to a project. The linker has been invoked and allegedly completed successfully. I have a .cpp file, makefile, main (for windows I presume) and an application file which I named. When I double click on this file nothing happens. Does the Windows main file contain all the necessary code to produce the program in a window. Is there anything else that I need to do. The file (I saved as ASCII) works in a DOS screen. All it does is display the list of ASCII characters with their associated numeric value. I would like to have this displayed in a windows window. Any help appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What Wayne said of course. But from the very start you have to realise that a Console app and a GUI app are very different things. You cannot just take your console code and select build as a GUI and have it magically work.
In fact when you tell Dev-C++ to create a GUI app, all it actually does is specify the -mwindows option, which does nothing more that suppress the console window. Hence you see nothing. If you want to create a graphical window (a "Windows window" as you put it), you have to do it programatically. Moreover, the graphical window is not the standard output console, so standard I/O functions such as printf() will do nothing (or at least nothing you can see).
To see how a basic Win32 GUI application looks, try the Windows GUI template in File->New->New project. You will see that there is a lot of code needed just to produce an empty window.
Next you might take a look at some of the example projects in c:\dev-cpp\examples. First copy the examples folder to somewhat outside of the c:\dev-cpp folder hierarchy to avoid problems with builds and so that you always have the untouched original code.
The style of code you see in these examples is basic Win32 API programming, often called "Petzold style" after the author of the most popular book on the subject.
There are far easier ways of GUI programming. One way is to use a framework and class library such as wxWidgets. This is made even easier with wxDev-C++, a version of Dev-C++ with wxWidgets included and visual GUI interface design tools. This is similar in functionality to using Visual C++ 6.0 with MFC or perhaps closer to Borland C++ Builder with VCL.
As far as Microsoft are concerned the preferred interface to Windows programming is no longer Win32, or MFC, but rather .NET. Unfortunately Dev-C++ does not support .NET, however this is hardly a problem since Microsoft's VC++ 2008 Express Edition is both free and far superior to Dev-C++. Using C++ with .NET requires some extensions to the language which Microsoft call C++/CLI. It is essentially a different language, but is a superset of C++. Personally I figured that if you have to learn a new language, you might as well learn an entirely new one, rather than confusing extensions, and one better matched to the task. So I suggest that if you want to use the .NET framework and class library, and Windows Forms then you might want to consider C# - a language uncompromisingly designed for .NET. There is free a Visual C# 2008 Express Edition too.
Some people suggest that Win32 programming is good for the soul, and allows you to understand how a Windows program works under the hood. To be honest it is likely to merely confuse and frustrate so that you never want to program again. People who learned the hard way (when there was no other way) often want others to do it that way too so that they have the same deep understanding of the arcane details. Frankly you often don't need to know, and don't really want to spend years flogging away at it while others are getting interesting stuff done in no time.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Descriptions are useful for providing context, but we really need details to help you better.
In the thread titled "Please Read Before Posting a Question" is a section on the "Basic 3", the
data we need to help you better. There is also a lot of other useful information there, please
check it out.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using Dev C++. I am new to this program as well as C++. I have written a samll piece of test code. This has been compiled and added to a project. The linker has been invoked and allegedly completed successfully. I have a .cpp file, makefile, main (for windows I presume) and an application file which I named. When I double click on this file nothing happens. Does the Windows main file contain all the necessary code to produce the program in a window. Is there anything else that I need to do. The file (I saved as ASCII) works in a DOS screen. All it does is display the list of ASCII characters with their associated numeric value. I would like to have this displayed in a windows window. Any help appreciated.
What Wayne said of course. But from the very start you have to realise that a Console app and a GUI app are very different things. You cannot just take your console code and select build as a GUI and have it magically work.
In fact when you tell Dev-C++ to create a GUI app, all it actually does is specify the -mwindows option, which does nothing more that suppress the console window. Hence you see nothing. If you want to create a graphical window (a "Windows window" as you put it), you have to do it programatically. Moreover, the graphical window is not the standard output console, so standard I/O functions such as printf() will do nothing (or at least nothing you can see).
To see how a basic Win32 GUI application looks, try the Windows GUI template in File->New->New project. You will see that there is a lot of code needed just to produce an empty window.
Next you might take a look at some of the example projects in c:\dev-cpp\examples. First copy the examples folder to somewhat outside of the c:\dev-cpp folder hierarchy to avoid problems with builds and so that you always have the untouched original code.
The style of code you see in these examples is basic Win32 API programming, often called "Petzold style" after the author of the most popular book on the subject.
There are far easier ways of GUI programming. One way is to use a framework and class library such as wxWidgets. This is made even easier with wxDev-C++, a version of Dev-C++ with wxWidgets included and visual GUI interface design tools. This is similar in functionality to using Visual C++ 6.0 with MFC or perhaps closer to Borland C++ Builder with VCL.
As far as Microsoft are concerned the preferred interface to Windows programming is no longer Win32, or MFC, but rather .NET. Unfortunately Dev-C++ does not support .NET, however this is hardly a problem since Microsoft's VC++ 2008 Express Edition is both free and far superior to Dev-C++. Using C++ with .NET requires some extensions to the language which Microsoft call C++/CLI. It is essentially a different language, but is a superset of C++. Personally I figured that if you have to learn a new language, you might as well learn an entirely new one, rather than confusing extensions, and one better matched to the task. So I suggest that if you want to use the .NET framework and class library, and Windows Forms then you might want to consider C# - a language uncompromisingly designed for .NET. There is free a Visual C# 2008 Express Edition too.
Some people suggest that Win32 programming is good for the soul, and allows you to understand how a Windows program works under the hood. To be honest it is likely to merely confuse and frustrate so that you never want to program again. People who learned the hard way (when there was no other way) often want others to do it that way too so that they have the same deep understanding of the arcane details. Frankly you often don't need to know, and don't really want to spend years flogging away at it while others are getting interesting stuff done in no time.
Clifford
Descriptions are useful for providing context, but we really need details to help you better.
In the thread titled "Please Read Before Posting a Question" is a section on the "Basic 3", the
data we need to help you better. There is also a lot of other useful information there, please
check it out.
Wayne