Tuesday, October 30, 2007

Rectangle split in VC++

#include static int a=100,b=100,c=250,d=250; static int e=250,f=100,g=400,h=250; static int i=100,j=250,k=250,l=400; static int m=250,n=250,o=400,p=400;class myframe:public CFrameWnd{private:
public: myframe() { Create(0,"Rectangle"); } void OnPaint() { CPaintDC dc(this); CRect r1(a,b,c,d),r2(e,f,g,h),r3(i,j,k,l),r4(m,n,o,p); // GetClientRect(&r); CPen pen; pen.CreatePen(PS_SOLID,4,RGB(255,0,0)); dc.SelectObject(&pen); CBrush brush; brush.CreateSolidBrush(RGB(255,0,0)); dc.SelectObject(&brush); dc.Rectangle(&r1); dc.Rectangle(&r2); dc.Rectangle(&r3); dc.Rectangle(&r4);
} void OnLButtonDown(UINT n,CPoint asd) { SetTimer(1,500,NULL); } void OnTimer() { a-=10; b-=10; c-=10; d-=10;
e+=10; f-=10; g+=10; h-=10;
i-=10; j+=10; k-=10; l+=10;
m+=10; n+=10; o+=10; p+=10; Invalidate();
} void OnDestroy() { KillTimer(1); } DECLARE_MESSAGE_MAP()};
class myapp:public CWinApp{public: int InitInstance() { myframe *p; p=new myframe; p->ShowWindow(3); m_pMainWnd=p; return 1; }};BEGIN_MESSAGE_MAP(myframe,CFrameWnd)ON_WM_PAINT()ON_WM_LBUTTONDOWN()ON_WM_TIMER()ON_WM_DESTROY()END_MESSAGE_MAP()myapp ass;

No comments: