home *** CD-ROM | disk | FTP | other *** search
- /*** Windows Application 1 ***/
- /*** ***/
- /*** WINAPP-1 includes ***/
- /*** (1) WINAPP-1.C ***/
- /*** (2) WINAPP-1.DEF ***/
-
- #include <windows.h>
-
- // Declaration
-
- long FAR PASCAL AppWndProc (HWND, WORD, WORD, LONG) ;
-
-
- // Definition
-
- int PASCAL WinMain(HANDLE hInstance,
- HANDLE hPrevInstance,
- LPSTR lpszCmdLine,
- int nCmdShow)
- { char szAppName[]="WinApp" ;
- WNDCLASS wndclass ;
- MSG msg ;
- HWND hwnd ;
-
- if ( !hPrevInstance )
- { wndclass.style = CS_HREDRAW | CS_VREDRAW ;
- wndclass.lpfnWndProc = AppWndProc ;
- wndclass.cbClsExtra = 0 ;
- wndclass.cbWndExtra = 0 ;
- wndclass.hInstance = hInstance ;
- wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION) ;
- wndclass.hCursor = LoadCursor(NULL,IDC_ARROW) ;
- wndclass.hbrBackground = GetStockObject(WHITE_BRUSH) ;
- wndclass.lpszMenuName = NULL ;
- wndclass.lpszClassName = szAppName ;
-
- RegisterClass(&wndclass) ;
- }
-
- hwnd = CreateWindow(szAppName, // window class name
- "Windows Application", // window caption
- WS_OVERLAPPEDWINDOW, // window style
- CW_USEDEFAULT, // initial x position
- 0, // initial y position
- CW_USEDEFAULT, // initial x length
- 0, // initial y length
- NULL, // parent window handle
- NULL, // window menu handle
- hInstance, // program instance handle
- NULL) ; // parameters
-
- ShowWindow(hwnd,nCmdShow) ;
- UpdateWindow(hwnd) ;
-
- while ( GetMessage(&msg, NULL, 0, 0) )
- { TranslateMessage(&msg) ;
- DispatchMessage(&msg) ;
- }
- return msg.wParam ;
- }
-
-
- long FAR PASCAL AppWndProc (HWND hwnd,
- WORD message,
- WORD wParam,
- LONG lParam)
- { switch (message)
- { case WM_DESTROY:
- PostQuitMessage(0) ;
- break ;
-
- default:
- return DefWindowProc(hwnd, message, wParam, lParam) ;
- }
- return 0 ;
- }
-