home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include "MyGenric.h"
-
- HWND hAppWnd; // global Window handle for use as needed
- HANDLE hInst; // global instance handle for use as needed
- char szAppName[] = APP_NAME; // ID string
-
- long FAR PASCAL WndProc( HWND hWnd,
- WORD msg,
- WORD wParam,
- long lParam )
- { long retval = 0L; // local for return value
- switch( msg ) // dispatch the messages
- {
- case WM_COMMAND: // only these are usually needed
- switch( wParam )
- {
- case 101: // do it -- insert code
- // for testing after this line
- break;
- case 999: // quit just fakes the
- // System Menu's CLOSE
- SendMessage( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0L );
- }
- break;
- default: // handles all other messages
- retval = DefWindowProc( hWnd, msg, wParam, lParam );
- }
- return retval;
- }
-
- BOOL FAR PASCAL RegApp( void )
- { WNDCLASS wc;
-
- wc.style = 0; // plain vanilla style bits
- wc.lpfnWndProc = &WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInst;
- wc.hIcon = NULL;
- wc.hCursor = NULL; // use system defaults
- wc.hbrBackground = COLOR_APPWORKSPACE+1;
- wc.lpszMenuName = "MyGenric";
- wc.lpszClassName = szAppName; // initialized via macro
-
- return RegisterClass( &wc );
- }
-
- BOOL FAR PASCAL InitInst(LPSTR lpCmdLine, WORD nCmdShow)
- { hAppWnd = CreateWindow (szAppName, // class name
- szAppName, // window name
- WS_OVERLAPPEDWINDOW
- | WS_CLIPCHILDREN
- | WS_VSCROLL
- | WS_HSCROLL
- , // style bits
- 0, // X
- 0, // Y
- CW_USEDEFAULT, // width
- 0, // height
- NULL, // parent
- NULL, // menu
- hInst, // instance handle
- NULL); // param block LP
- if (!hAppWnd) // CreateWindow failed
- return FALSE;
- ShowWindow (hAppWnd, nCmdShow); // Success
- UpdateWindow (hAppWnd);
- return TRUE;
- }
-
- int PASCAL WinMain( HANDLE hInstance, // current instance
- HANDLE hPrevInstance, // previous instance
- LPSTR lpszCmdLine, // command line
- int nCmdShow ) // min, max, or
- // normal
- { MSG msg;
- hInst = hInstance; // set global instance handle
- if( !hPrevInstance ) // If this is first instance,
- // register window class
- { if( !RegApp() )
- return 0; // If registration failed, get out
- }
- if( !InitInst( lpszCmdLine, nCmdShow ))
- { return 0; // If initialization failed,get out
- }
- while( GetMessage( &msg, NULL, 0, 0 )) // run the loop
- { TranslateMessage( &msg );
- DispatchMessage( &msg );
- }
- return 0;
- }