home *** CD-ROM | disk | FTP | other *** search
- //
- // File name: HWorld.CPP
- //
- // Description: The main file for the Hello World example.
- //
- // Author: John De Goes
- //
- // Project: Cutting Edge 3D Game Programming
- //
-
- // ------------------------------------------------------------
- // | Global include files: |
- // ------------------------------------------------------------
-
- #include <Math.H>
- #include <Conio.H>
- #include <Time.H>
- #include <Stdio.H>
- #include <Windows.H>
- #include <Iostream.H>
-
- // ------------------------------------------------------------
- // | Local include files: |
- // ------------------------------------------------------------
- #include "HWORLD.RH"
-
- // ------------------------------------------------------------
- // | Global variables/constants: |
- // ------------------------------------------------------------
-
- LRESULT CALLBACK WndProc ( HWND hWnd, unsigned int iMessage,
- unsigned int wParam, LONG lParam );
-
- HANDLE ThisInstance;
-
- // ------------------------------------------------------------
- // | Program entry: |
- // ------------------------------------------------------------
-
- int WINAPI WinMain ( HANDLE hInstance, HANDLE hPrevInstance,
- LPSTR lpszCmdParam, int nCmdShow )
-
- {
- hPrevInstance; lpszCmdParam;
- ThisInstance = hInstance;
- HWND hWnd;
- MSG Message;
- WNDCLASS WndClass;
-
- WndClass.cbClsExtra = 0;
- WndClass.cbWndExtra = 0;
- WndClass.hbrBackground = GetStockObject ( GRAY_BRUSH );
- WndClass.hCursor = LoadCursor ( NULL, IDC_ARROW );
- WndClass.hIcon = LoadIcon ( hInstance, NULL );
- WndClass.hInstance = hInstance;
- WndClass.lpfnWndProc = WndProc;
- WndClass.lpszClassName = "HWORLD";
- WndClass.lpszMenuName = ( const char * ) MENU_1;
- WndClass.style = CS_HREDRAW | CS_VREDRAW;
-
- if ( !RegisterClass ( &WndClass ) )
- return 0;
-
- hWnd = CreateWindow ( "HWORLD", // class name
- "Hello World!", // Caption
- WS_OVERLAPPEDWINDOW,// Style
- CW_USEDEFAULT, // x position
- CW_USEDEFAULT, // y position
- CW_USEDEFAULT, // cx - size
- CW_USEDEFAULT, // cy - size
- NULL, // Parent window
- NULL, // Menu
- hInstance, // Program Instance
- NULL ); // Parameters
-
- ShowWindow ( hWnd, nCmdShow );
-
- while ( GetMessage ( &Message, hWnd, 0, 0 ) )
- {
- TranslateMessage ( &Message );
- DispatchMessage ( &Message );
- }
-
- return Message.wParam;
- }
-
- LRESULT CALLBACK WndProc ( HWND hWnd, unsigned int iMessage,
- unsigned int wParam, LONG lParam )
- {
- switch ( iMessage )
- {
- case ( WM_CREATE ):
- {
- break;
- }
- case ( WM_COMMAND ):
- {
- switch ( LOWORD ( wParam ) )
- {
- case ( CM_FILE_EXIT ):
- {
- PostQuitMessage ( 0 );
- break;
- }
- case ( CM_HELP_ABOUT ):
- {
- MessageBox ( hWnd, "Hello World Example", "About", MB_OK );
- break;
- }
- }
- break;
- }
- case ( WM_DESTROY ):
- {
- PostQuitMessage ( 0 );
- break;
- }
- default:
- return DefWindowProc ( hWnd, iMessage, wParam,
- lParam );
- }
- return 0;
- }