Creating an Include File

It is often useful to create an include file in which to define constants and function prototypes for your application. Most applications consist of at least two source files that share common constants: the C-language source file and the resource script file. Since the Resource Compiler carries out the same preprocessing as the C Compiler, it is useful and convenient to place constant definitions in a single include file and then include that file in both the C-language source file and the resource script file.

For example, for the Generic application, you can place the function prototypes for the WinMain, MainWndProc, About, InitApplication, and InitInstance functions, and the definition of the menu ID for the About command, in the GENERIC.H include file. The file should look like this:

#define IDM_ABOUT 100

int PASCAL WinMain (HANDLE, HANDLE, LPSTR, int);

BOOL InitApplication (HANDLE);

BOOL InitInstance (HANDLE, int);

long FAR PASCAL MainWndProc (HWND, unsigned, WORD, LONG);

BOOL FAR PASCAL About (HWND, unsigned, WORD, LONG);

Since GENERIC.H refers to Windows data types, you must include it after WINDOWS.H, which defines those data types. That is, the beginning of your source files should look like this:

#include “WINDOWS.H” /* required for all Windows applications */

#include “GENERIC.H” /* specific to this program */