wtlclock2view.cpp

来自「WTL框架下的对话框程序」· C++ 代码 · 共 48 行

CPP
48
字号
// WTLClock2View.cpp : implementation of the CWTLClock2View class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"

#include "WTLClock2View.h"

BOOL CWTLClock2View::PreTranslateMessage(MSG* pMsg)
{
    pMsg;
    return FALSE;
}

LRESULT CWTLClock2View::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CPaintDC dc(m_hWnd);
CRect    rc;
CString  sTime;

    // Get our window's client area.
    GetClientRect ( rc );

    // Build the string to show in the window.
    if ( m_bClockRunning )
        {
        sTime.Format ( _T("The time is %d:%02d:%02d"), 
                       m_stLastTime.wHour, m_stLastTime.wMinute, m_stLastTime.wSecond );
        }
    else
        {
        sTime.Format ( _T("Clock stopped on %d:%02d:%02d"), 
                       m_stLastTime.wHour, m_stLastTime.wMinute, m_stLastTime.wSecond );
        }

    // Set up the DC and draw the text.
    dc.SaveDC();
    
    dc.SetBkColor ( m_crBkgnd );
    dc.SetTextColor ( m_crText );
    dc.ExtTextOut ( 0, 0, ETO_OPAQUE, rc, sTime, sTime.GetLength(), NULL );

    // Restore the DC.
    dc.RestoreDC(-1);
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?