To make it short: No, you cannot write a windows application with just regular standard C++. There isn't a GUI equivalent to "iostream" and all those other standard headers.
You cannot call a function
std::createdlg() like you can call
std::cout << "Hello".
Standard ISO C++ doesn't define any functions for windows and dialog boxes etc. since they are not platform-independent.
That's why you need to use the WinAPI or a wrapper library.
The reason why a WinAPI application in Visual C++ looks so complicated is because it already includes everything that you need to create a window.
After all, you could also simply just do this:
Code: Select all
#include <windows.h>
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
MessageBox(NULL, "Hello", "Message", MB_OK);
}
But this wouldn't help anybody.
So, the Visual C++ template creates everything for you that you need for a standard window: Creating the window, a message loop, an event function etc.
But this has nothing to do with "regular C++" vs. "Visual C++".
Apart from the fact that a Windows program has WinMain instead of main, this is all pretty much standard C++: It uses types and a bunch of functions. The types are not part of the language, but can be found in the header file, just like you yourself could define types in header files, like
typedef int MyCoolNumber;.
That template is like with NES programming in Assembly:
An IDE that creates an NES template for you would maybe fill the code files with a reset interrupt, an NMI interrupt, system initialization and a controller reading function.
And you might ask yourself: Why does regular Assembly work with LDA and STA while "NES Assembly" uses such complicated things like vectors and stuff?
Because "NES Assembly" isn't a language. You're simply looking at a bare-bones compilable Assembly program that properly initializes itself for use on the NES.
It's the same with that WinAPI program: This is simply a bare-bones program to create a window. The code is still standard C++, only that it uses a bunch of functions, structs and typedefs to actually get a window on the screen.
But those things are no more sophisticated than if you wrote an Assembly macro:
Code: Select all
.macro ADD_3 variable
INC variable
INC variable
INC variable
.endmacro
And someone who saw this macro used in your code (
ADD_3 Status) would ask: "What kind of sophisticated stuff is this? I thought all commands in Assembly consist only of three letters."
If you want to understand what your code template does, you can check this tutorial:
http://www.winprog.org/tutorial
If WinAPI is too complicated for you and you want to be able to create windows right away as you would do in C#, you can look for GUI libraries: MFC was Microsoft's own wrapper library. Borland C++ used its own as well. And then there are compiler-independent libraries like Qt etc.