#include #include #define febr 800 #define feho 600 //---------------------VARIABLEN------------------------------------- double zeit, posi, gesc, kraf, damp; //------------------------------------------------------------------- static int cxClient, cyClient ; HDC hdc ; LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT ("DASSISSESS") ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("Program requires Windows NT!"), szAppName, MB_ICONERROR) ; return 0 ; } hwnd = CreateWindow (szAppName, TEXT ("DASSISSESS"), WS_OVERLAPPEDWINDOW, 0, 0, febr, feho, NULL, NULL, hInstance, NULL) ; ShowWindow (hwnd, SW_SHOWMAXIMIZED) ; UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; } //------------------------------------UNTERPROGRAMME----------------- //------------------------------------------------------------------- LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps ; switch (message) { case WM_SIZE: cxClient = LOWORD (lParam) ; cyClient = HIWORD (lParam) ; return 0 ; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; //----------------------------------------HAUPTPROGRAMM-------------- // double zeit, posi, gesc, kraf, damp; posi = 280 ; // Position gesc = 0 ; // Geschwindigkeit kraf = 0.000001; // Rueckstellkraft damp = 0.99992 ; // Daempfungsrest // Das (kleiner als)-Zeichen stoert die html-Darstellung for(zeit = 0; zeit < 800; zeit = zeit + 0.01) // Zeitablauf { gesc = gesc - kraf * posi; // Beschleunigung gesc = gesc * damp; // Bremsung posi = posi + gesc; // Bewegung SetPixel(hdc, (int)zeit, 290-(int)posi, RGB(0,0,0)); // Punkt zeichnen } // nächster Zeitpunkt //------------------------------------------------------------------- EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }