vebanco

Màu nền
Font chữ
Font size
Chiều cao dòng

/* Ve ban co */

#include<afxwin.h>

int luot=0;

class CMyApp:public CWinApp

{

public:

    BOOL InitInstance();

};

class CMyWin:public CFrameWnd

{

private:

    CBrush b;

public:

    CMyWin();

    afx_msg void OnRButtonDown(UINT nFlags, CPoint pt);

    afx_msg void OnLButtonDown(UINT nFlags, CPoint pt);

    DECLARE_MESSAGE_MAP()

};

CMyApp theApp;

BEGIN_MESSAGE_MAP(CMyWin,CFrameWnd)

    ON_WM_RBUTTONDOWN()

    ON_WM_LBUTTONDOWN()

END_MESSAGE_MAP()

BOOL CMyApp::InitInstance()

{

    m_pMainWnd=new CMyWin;

    m_pMainWnd->ShowWindow(m_nCmdShow);

    m_pMainWnd->UpdateWindow();

    return true;

}

CMyWin::CMyWin()

{

    Create(NULL,"Ve Ban Co");

}

afx_msg void CMyWin::OnRButtonDown(UINT nFlags, CPoint pt)

{

    int i=0;

    CDC *dc=GetDC();

    RECT r;

    GetClientRect(&r);

   

    int x=0,y=0;

    for(i=0; i<=100; i++)

    {

        x=x+20;

        dc->MoveTo(x,y);

        dc->LineTo(x,r.bottom);

    }

    x=0;

    y=0;

    for(i=0; i<=100; i++)

    {

        y=y+20;

        dc->MoveTo(x,y);

        dc->LineTo(r.right,y);

    }

    /*int g,gx,gy;

    gx=(r.right-r.left);

    gy=(r.bottom-r.top);

    g=(gx-gy)/2;

    int x=0,y=0;

    for(int i=1;i<=8;i++)

    {

        for(int j=1;j<=8;j++)

        {

            if((i+j)%2==0)

            {

                b.CreateSolidBrush(RGB(0,0,0));

                dc->SelectObject(&b);

                dc->Rectangle(g+x,y,gy/8+g+x,gy/8+y);

                x+=gy/8;

                b.DeleteObject();

            }

            else

            {

                b.CreateSolidBrush(RGB(255,255,255));

                dc->SelectObject(&b);

                dc->Rectangle(g+x,y,gy/8+g+x,gy/8+y);

                x+=gy/8;

                b.DeleteObject();

            }   

        }

        x=0;

        y+=gy/8;

    }

    */

}

afx_msg void CMyWin::OnLButtonDown(UINT nFlags, CPoint pt)

{

    int i=0, k=0;

    CDC *dc=GetDC();

    if(luot==0 && k==0)

    {

        dc->TextOut((( int(pt.x/20))*20)+7, ((  int(pt.y/20))*20)+7 , "x");

        luot=1;

        k=1;

    }

    if(luot==1 && k==0)

    {

        dc->TextOut((( int(pt.x/20))*20)+7, ((int(pt.y/20))*20)+7, "o");

        luot=0;

    }

}

Bạn đang đọc truyện trên: Truyen2U.Pro