Creating your first window
Creating a window is the first step in Windows programming. All our sprites and other objects will be drawn on top of this window. There is a standard way of drawing a window. So this part of the code will be repeated in all programs that use Windows programming to draw something.
Getting ready
You need to have a working copy of Visual Studio installed on your Windows machine.
How to do it…
In this recipe, we will find out how easy it is to create a window:
Open Visual Studio.
Create a new C++ project.
Select a Win32 Windows application.
Add a source file called
Source.cpp
.Add the following lines of code to it:
#define WIN32_LEAN_AND_MEAN #include <windows.h> // Include all the windows headers. #include <windowsx.h> // Include useful macros. #include "resource.h" #define WINDOW_CLASS_NAME L"WINCLASS1" void GameLoop() { //One frame of game logic occurs here... } LRESULT CALLBACK WindowProc(HWND _hwnd, UINT _msg, WPARAM _wparam, LPARAM _lparam...