home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------
- - WINDEMO.C - Ein kleines Übungsprogramm in MS C 6.0 -
- - (c) 1991 toolbox -
- ----------------------------------------------------------*/
-
- #include <windows.h>
- #include "windemo.h"
-
- /*---------------------------------------------------
- Prototyp der Fensterfunktion
- --------------------------------------------------*/
-
- long FAR PASCAL Fenster (HWND, WORD, WORD, LONG);
-
- static char szAppName[] = "Windows Demo";
- HANDLE hInst;
-
- /*---------------------------------------------------
- Hier ist der Eintrittspunkt des Programms
- --------------------------------------------------*/
-
- int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
- LPSTR lpszCmdParam, int nCmdShow)
- {
- HWND hwnd;
- MSG msg;
- WNDCLASS wndclass;
-
- if (!hPrevInstance)
- {
-
- /*---------------------------------------------------
- Hier wird die Fensterklasse definiert
- --------------------------------------------------*/
- wndclass.style = CS_HREDRAW | CS_VREDRAW ;
- wndclass.lpfnWndProc = Fenster;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInstance;
- wndclass.hIcon = LoadIcon(hInstance, szAppName );
- wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndclass.hbrBackground = GetStockObject(LTGRAY_BRUSH);
- wndclass.lpszMenuName = "TestMenu";
- wndclass.lpszClassName = szAppName ;
-
- /*------------------------------------------------
- Hier wird die Fensterklasse registriert
- --------------------------------------------------*/
-
- RegisterClass (&wndclass);
- }
- hInst = hInstance;
- hwnd = CreateWindow (szAppName,
- "toolbox Windows-Training",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- NULL,
- NULL,
- hInstance,
- NULL);
-
- /*---------------------------------------------------
- Darstellen des Fensters und des Client-Bereichs
- --------------------------------------------------*/
-
- ShowWindow(hwnd, nCmdShow) ;
- UpdateWindow (hwnd);
-
- /*---------------------------------------------------
- Warten auf eine Nachricht
- --------------------------------------------------*/
-
- while (GetMessage (&msg, NULL, 0, 0))
- {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- return msg.wParam;
- }
-
- /*---------------------------------------------------
- Definition der Fensterfunktion
- --------------------------------------------------*/
-
- long FAR PASCAL Fenster (HWND hwnd, WORD message,
- WORD wParam, LONG lParam)
- {
- static HICON hIcon;
- HDC hdc;
- PAINTSTRUCT ps;
- RECT rect;
- FARPROC lpProcAbout;
-
- /*---------------------------------------------------
- Hier werden eintreffende Nachrichten verarbeitet
- --------------------------------------------------*/
-
- switch(message)
- {
- case WM_CREATE :
- return 0;
-
- /*-----------------------------------------------------
- Hier wird geprüft, ob die Menüleiste ausgewählt wurde
- ----------------------------------------------------*/
- case WM_COMMAND :
- if (wParam == IDM_ABOUT)
- {
- lpProcAbout = MakeProcInstance(Hilfe, hInst);
- DialogBox(hInst,
- "InfoBox",
- hwnd,
- lpProcAbout);
- FreeProcInstance(lpProcAbout);
- break;
- }
- else
- return DefWindowProc (hwnd, message, wParam, lParam);
-
-
- case WM_PAINT :
- hIcon = LoadIcon (hInst, szAppName);
- hdc = BeginPaint (hwnd, &ps);
- GetClientRect (hwnd, &rect) ;
- DrawText (hdc,"Das erste Windows-Programm!",-1,
- &rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER);
- EndPaint (hwnd, &ps);
- return 0;
-
- case WM_DESTROY :
- PostQuitMessage (0);
- return 0;
- }
- return DefWindowProc (hwnd, message, wParam, lParam);
- }
-
- /*---------------------------------------------------
- Hier wird die About-Funktion definiert
- --------------------------------------------------*/
-
- BOOL FAR PASCAL Hilfe(HANDLE hDlg, WORD message,
- WORD wParam, LONG lParam)
- {
- switch(message){
- case WM_INITDIALOG:
- return TRUE;
-
- case WM_COMMAND :
- if ((wParam == IDOK) || (wParam == IDCANCEL))
- {
- EndDialog(hDlg, TRUE);
- return (TRUE);
- }
- break;
- }
- return FALSE;
- }
- /*----------------------------------------------------------
- - Ende von WINDEMO.C */