www.pudn.com > vcsvr.rar > TimerSet.cpp


// TimerSet.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "vcsvr.h" 
#include "TimerSet.h" 
#include "MainFrm.h" 
#include "TagDef.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CTimerSet dialog 
 
 
CTimerSet::CTimerSet(CWnd* pParent /*=NULL*/) 
	: CDialog(CTimerSet::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CTimerSet) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CTimerSet::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CTimerSet) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CTimerSet, CDialog) 
	//{{AFX_MSG_MAP(CTimerSet) 
	ON_WM_SHOWWINDOW() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CTimerSet message handlers 
//设置设备标签刷新周期 
void CTimerSet::OnOK()  
{ 
	// TODO: Add extra validation here 
	long newInterval; 
	CString str; 
	CWnd *pWnd = GetParent(); 
	CEdit *pWndEdit= (CEdit *)GetDlgItem(IDC_EDIT1); 
	pWndEdit->GetWindowText(str); 
	newInterval = atoi(str.GetBuffer(str.GetLength())); 
	if(newInterval!=TimerInterval) 
	{ 
		TimerInterval=newInterval; 
		KillTimer(ID_TIMER); 
		pWnd->SetTimer(ID_TIMER,TimerInterval,NULL); 
	} 
	CDialog::OnOK(); 
} 
//显示当前刷新周期 
void CTimerSet::OnShowWindow(BOOL bShow, UINT nStatus)  
{ 
	CDialog::OnShowWindow(bShow, nStatus); 
	char Interval[6]; 
	itoa(TimerInterval,Interval,10); 
	CEdit *pWndEdit= (CEdit *)GetDlgItem(IDC_EDIT1); 
	pWndEdit->SetWindowText(Interval); 
} 
 
void CTimerSet::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	 
	CDialog::OnCancel(); 
}