1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 5152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610 7108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 1481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871 88189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
Please save file with C language suffix (*.c) # include <windows.h> #include <math.h> #define NUM 1000#define Twopi (2 * 3.1415926 ) lresult CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain (hinstance hinstance, hinstance hPr Evinstance, PSTR szcmdline, int icmdshow) {static TCHAR szappname[] = TEXT ("Hellowin"); HWND hwnd; MSG msg; WNDCLASS wndclass; int CX, CY; CX = GetSystemMetrics (sm_cxscreen)/2-200;cy = GetSystemMetrics (sm_cyscreen)/2-200; 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 (/*gray*/white_brush); wndclass.lpszmenuname = NULL; Wndclass.lpszclassname = Szappname; if (! RegisterClass (&wndclass)) {MessageBox (NULL, TEXT ("ThIs program requires Windows nt! "), Szappname, mb_iconerror); return 0;} registerclass (&wndclass); hwnd = CreateWindow (szappname,//Window class Nametext ("the Hello program "),//Window Captionws_overlappedwindow,//Window STYLECX,//initial x positioncy, Initial y position400,//initial x size400,//initial y sizenull, Parent window handlenull,//Window menu handlehinstance,//program in Stance handlenull); Creation Parameters showwindow (hwnd, icmdshow); UpdateWindow (HWND); while (GetMessage (&msg, NULL, 0, 0)) {translatemessage (&msg);D ispatchmessage (& msg);} return Msg.wparam;} lresult CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM) {HDC hdc; paintstruct PS; static int cxclient, cyclient; Hbrush hbrush; int i; Point Apt[num],lefthand[] = {CXCLIENT/2-cyclient/2-20,CXCLIENT/2-CYCLIENT/2 + 10,CXCLIENT/2-+, CYCLIENT/2 + 30,CXC LIENT/2-CYCLIENT/2 + 10},righthand[] = {CXCLIENT/2 +, CYCLIENT/2-20,CXCLIENT/2 + +, CYCLIENT/2 + 10,CXCLIENT/2 +, CYCLIENT/2 + 30,CXCLIENT/2 +, CYCLIENT/2 + ten}; switch (message) {case Wm_size:cxclie NT = LoWord (lParam); cyclient = HiWord (lParam) + 120;return 0; case wm_paint:hdc = BeginPaint (hwnd, &PS); &nb Sp Ellipse (hdc, CXCLIENT/2-N, CYCLIENT/2 + CXCLIENT/2, CYCLIENT/2 + 85); Foot Ellipse (hdc, CXCLIENT/2, CYCLIENT/2 +, CXCLIENT/2 +, CYCLIENT/2 +); hbrush = CreateSolidBrush ( RGB (100, 150, 255)); SelectObject (hdc, hbrush); //Rectangle (hdc, CXCLIENT/2-A, CYCLIENT/2-CXCLIENT/2 +60, cyclient/ 2 + 70); Body RoundRect (hdc, CXCLIENT/2-Max, CYCLIENT/2-$, CXCLIENT/2 +, CYCLIENT/2 + +, +); deleteobject (Hbrush); hbrush = Getstockobject (White_brush); SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2 – CYCLIENT/2-, CXCLIENT/2 + 50 ) ; Belly part hbrush = CreateSolidBrush (RGB (100, 150, 255)); SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2-N, CYCLIENT/2-up, CXCLIENT/2 +100, CYCLIENT/2- 20); Head deleteobject (hbrush); hbrush = Getstockobject (White_brush); SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2-rated, CYCLIENT/2-, CXCLIENT/2 + 2, CYCLIENT/2 0); Face Ellipse (hdc, CXCLIENT/2-Max, CYCLIENT/2-CXCLIENT/2, CYCLIENT/2-140); Orbital left ellipse (hdc, CXCLIENT/2, CYCLIENT/2-CXCLIENT/2 + +, CYCLIENT/2-140); Orbital right hbrush = Getstockobject (Black_brush); SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2 – CYCLIENT/2-155, CXCLIENT/2 -10, CYCLIENT/2-15 0); Eyes left Ellipse (hdc, CXCLIENT/2 +, CYCLIENT/2-155, CXCLIENT/2 +, CYCLIENT/2-150); Eyes right deleteobject (hbrush), hbrush = CreateSolidBrush (RGB (255, 0, 0)); SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2-Ten, CYCLIENT/2-, CXCLIENT/2 +10, CYCLIENT/2-130 ) ; Nose movetoex (hdc, CXCLIENT/2, CYCLIENT/2 -130, NULL); LineTo (hdc, CXCLIENT/2, CYCLIENT/2); movetoex (hdc, CXCLIENT/2-MAX, CYCLIENT/2-All, NULL); Mouth for (i = 0; i < NUM/2; i++) {apt[i].x = CXCLIENT/2-+ i * 160/num; apt[i].y = CYCLIENT/2-+ + (int) (30 * Sin (Twopi * i/num))/2; LineTo (hdc, apt[i].x, APT[I].Y);} movetoex (HDC, CXCLIENT/2-A, CYCLIENT/2-$, NULL); Beard LineTo (hdc, CXCLIENT/2-CYCLIENT/2); movetoex (hdc, CXCLIENT/2-A, CYCLIENT/2-A, NULL) ; LineTo (hdc, CXCLIENT/2-CYCLIENT/2); movetoex (hdc, CXCLIENT/2-A, CYCLIENT/2-N, NULL); LineTo (hdc, CXCLIENT/2-CYCLIENT/2-&nbs);P Movetoex (hdc, CXCLIENT/2 +, CYCLIENT/2 -140, NULL); LineTo (hdc, CXCLIENT/2 +, CYCLIENT/2); movetoex (hdc, CXCLIENT/2 +, CYCLIENT/2-A, NULL); LineTo (hdc, CXCLIENT/2 +20, CYCLIENT/2-N); movetoex (hdc, CXCLIENT/2 +60, CYCLIENT/2-N, NULL); LineTo (hdc, CXCLIENT/2 +, CYCLIENT/2-100); hbrush = Getstockobject (White_brush); Pocket SelectObject (hdc, hbrush); chord (hdc, CXCLIENT/2-All, CYCLIENT/2-, CXCLIENT/2 + +4, CYCLIENT/2) 0,CXCLIENT/2-CYCLIENT/2 + ten, Cxclient/2 +40, CYCLIENT/2 +); hbrush = CreateSolidBrush (RGB (255, 0, 0)); Ring SelectObject on the neck (hdc, hbrush); roundrect (hdc, CXCLIENT/2-All, CYCLIENT/2-, CXCLIENT/2 + Cyclien T/2, deleteobject (hbrush), hbrush = CreateSolidBrush (RGB (100, 150, 255)); Arm SelectObject (hdc, hbrush); setpolyfillmode (hdc, WindING); Polygon (HDC, LeftHand, 4); setpolyfillmode (hdc, winding); Polygon (HDC, righthand, 4); deleteobject (hbrush); hbrush = Getstockobject (White_brush); Hand SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2-, CYCLIENT/2 + 5, CXCLIENT/2-rated, CYCLIENT/2 + 35); Ellipse (hdc, CXCLIENT/2 + +, CYCLIENT/2 + 5, CXCLIENT/2 +, CYCLIENT/2 + 35); hbrush = CreateSolidBrush (RGB (250, 255, 150)); Bell SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2-CYCLIENT/2 - deleteobject (hbrush); hbrush = Getstockobject (Black_brush); SelectObject (hdc, hbrush); ellipse (hdc, CXCLIENT/2-4, CYCLIENT/2-CXCLIENT/2 + 4, CYCLIENT/2-21) ; movetoex (hdc, CXCLIENT/2, CYCLIENT/2-All, NULL); LineTo (hdc, CXCLIENT/2, CYCLIENT/2); endpaint (hwnd, &PS); return 0; case wm_destroy:postquitmes Sage (0); return 0; }return DefWindowProc (hwnd, message, WParam, LParam);} |