hiendongho

/* Hien dong ho ra giua cua so */

#include<afxwin.h>

class CMyApp:public CWinApp

{

public:

    BOOL InitInstance();

};

class CMyWin:public CFrameWnd

{

public:

    CMyWin();

    afx_msg void OnTimer(UINT nIDEvent);

    DECLARE_MESSAGE_MAP()

};

CMyApp theApp;

BOOL CMyApp::InitInstance()

{

    m_pMainWnd=new CMyWin;

    if(m_pMainWnd->SetTimer(117,1000,NULL)!=117)

    {

        MessageBox(NULL,"khong dat duoc chu ky thoi gian","Loi chuong trinh",MB_OK);

        return FALSE;

    }

    m_pMainWnd->ShowWindow(m_nCmdShow);

    m_pMainWnd->UpdateWindow();

    return true;

}

BEGIN_MESSAGE_MAP(CMyWin,CFrameWnd)

    ON_WM_TIMER()

END_MESSAGE_MAP()

CMyWin::CMyWin()

{

    Create(NULL,"ONG THE THANH");

}

afx_msg void CMyWin::OnTimer(UINT nIDEvent)

{

    CDC *dc=GetDC();

    char s[200];

    CTime t=CTime::GetCurrentTime();

    sprintf(s,"[%2d:%2d:%2d]",t.GetHour(),t.GetMinute(),t.GetSecond());

    RECT r;

    GetClientRect(&r);

    int h,w;

    h=r.bottom-r.top;

    h=h/2-8;

    w=r.right-r.left;

    w=w/2-30;

    dc->TextOut(w,h,s);

}

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: