Game Development Reference
In-Depth Information
Hello World Windows Application
Below is the code to a fully functional yet simple Windows program.
Follow the code as best you can. The next section explains the code a
bit at a time. It is recommended that you create a project with your
development tool, type the code in by hand, compile it, and execute it
as an exercise. Note that you must create a Win32 Application Project,
not a Win32 Console Application Project.
/////////////////////////////////////////////////////////////////////
//
// File: hello.cpp
//
// Author: Frank D. Luna (C) All Rights Reserved
//
// System: AMD Athlon 1800+ XP, 512 DDR, Geforce 3, Windows XP,
//
MSVC++ 7.0
//
// Desc: Demonstrates creating a Windows application.
//
/////////////////////////////////////////////////////////////////////
// Include the windows header file, this has all the
// Win32 API structures, types, and function declarations
// we need to program Windows.
#include <windows.h>
// The main window handle. This is used to identify
// the main window we are going to create.
HWND MainWindowHandle = 0;
// Wraps the code necessary to initialize a Windows
// application. Function returns true if initialization
// was successful, else it returns false.
bool InitWindowsApp(HINSTANCE instanceHandle, int show);
// Wraps the message loop code.
int Run();
// The window procedure, handles events our window
// receives.
LRESULT CALLBACK WndProc(HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam);
// Windows equivalant to main()
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR
pCmdLine,
int
nShowCmd)
{
// First we create and initialize our Windows
// application. Notice we pass the application
// hInstance and the nShowCmd from WinMain as
Search WWH ::




Custom Search