dialogmsg.cpp

来自「《Visual C++编程技巧典型案例解析:基础与应用篇(下)(含1CD-ROM」· C++ 代码 · 共 83 行

CPP
83
字号
// DialogMsg.cpp : implementation file
//

#include "stdafx.h"
#include "SortID.h"
#include "DialogMsg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDialogMsg dialog


CDialogMsg::CDialogMsg(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogMsg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogMsg)
	m_strMessage = _T("");
	//}}AFX_DATA_INIT
	m_nTimerGap=500;
	m_bTimerSeted=FALSE;
}


void CDialogMsg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogMsg)
	DDX_Text(pDX, IDC_STATIC_MSG, m_strMessage);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialogMsg, CDialog)
	//{{AFX_MSG_MAP(CDialogMsg)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogMsg message handlers

BOOL CDialogMsg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

	m_bTimerSeted=SetTimer(1, m_nTimerGap, NULL);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDialogMsg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CDialog::OnTimer(nIDEvent);

	if(m_bTimerSeted)
	{	
		KillTimer(1);
		m_bTimerSeted=FALSE;
	}
	CDialog::OnOK();
}

void CDialogMsg::OnOK() 
{
	// TODO: Add extra validation here
	if(m_bTimerSeted)
	{	
		KillTimer(1);
		m_bTimerSeted=FALSE;
	}
	
	CDialog::OnOK();
}

⌨️ 快捷键说明

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