Book Image

C++ Windows Programming

By : Stefan Björnander
Book Image

C++ Windows Programming

By: Stefan Björnander

Overview of this book

It is critical that modern developers have the right tools to build practical, user-friendly, and efficient applications in order to compete in today’s market. Through hands-on guidance, this book illustrates and demonstrates C++ best practices and the Small Windows object-oriented class library to ease your development of interactive Windows applications. Begin with a focus on high level application development using Small Windows. Learn how to build four real-world applications which focus on the general problems faced when developing graphical applications. Get essential troubleshooting guidance on drawing, spreadsheet, and word processing applications. Finally finish up with a deep dive into the workings of the Small Windows class library, which will give you all the insights you need to build your own object-oriented class library in C++.
Table of Contents (22 chapters)
C++ Windows Programming
Credits
About the Author
About the Reviewer
www.PacktPub.com
Dedication
Preface
Free Chapter
1
Introduction

The WinMain function


In the Win32 API, WinMain is the function equivalent to main. Each application must include the definition of the WinMain function. In order for Small Windows to work, WinMain is implemented as a part of Small Windows, while MainWindow has to be implemented by the user of Small Windows for each project. To sum it up, here are the three kinds of main functions:

Regular C/C++

Win32 API

Small Windows

main

WinMain

MainWindow

The WinMain function is called by the Windows system and takes the following parameters:

  • instanceHandle: This holds the handle of the application

  • prevInstanceHandle: This is present due to backward compatibility but is always null

  • commandLine: This is a null-terminated character (char, not TCHAR) array holding the arguments for the application, separated by spaces

  • commandShow: This holds the preferred appearance of the main window

WinMain.cpp

#include "SmallWindows.h" 
 
int WINAPI WinMain(HINSTANCE instanceHandle, 
            ...