You are on page 1of 2

#include <Windows.h> #include <stdio.h> #include <string.

h> long _stdcall MyFunction(HWND,UINT,UINT,long); WNDCLASS obj; int flag=0,x1,y1,x2,y2; int _stdcall WinMain(HINSTANCE a,HINSTANCE b,char *c,int d) { HWND hnd; MSG msg; //obj.style=CS_DBLCLKS; obj.lpfnWndProc=MyFunction; obj.lpszClassName="MyClass"; obj.hInstance=a; obj.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); RegisterClass(&obj); hnd=CreateWindow("MyClass","Glens",WS_OVERLAPPEDWINDOW,10,10,300,300,0,0 ,a,0); ShowWindow(hnd,3); //UpdateWindow(hnd); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } long _stdcall MyFunction(HWND w,UINT x,UINT y,long z) { HDC dev; static int cx,cy; int i; static POINT my_poly[8]={15,75,50,75,50,15,80,15,80,50,30,50,30,80,15,55 }; POINT poly[8]; PAINTSTRUCT ps; switch(x) { case WM_SIZE:

cx=LOWORD(z); cy=HIWORD(z); return 0; case WM_PAINT: dev=BeginPaint(w,&ps); Rectangle(dev,cx/5,cy/5,3*cx/5,3*cy/5); MoveToEx(dev,0,0,NULL); SelectObject(dev,GetStockObject(GRAY_BRU SH)); Ellipse(dev,cx/5,cy/5,3*cx/5,3*cy/5); SetPolyFillMode(dev,ALTERNATE); for(i=0;i<=8;i++) { poly[i].x=cx*my_poly[i].x/200; poly[i].y=cy*my_poly[i].y/200; } SetPolyFillMode(dev,ALTERNATE); Polygon(dev,poly,8); EndPaint(w,&ps); return 0; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(w,x,y,z);

return 0L; }

You might also like