www.pudn.com > mfcopentree.rar > Welcome.cpp


// Welcome.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "mfcopen.h" 
#include "Welcome.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CWelcome dialog 
 
 
CWelcome::CWelcome(CWnd* pParent /*=NULL*/) 
	: CDialog(CWelcome::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CWelcome) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CWelcome::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CWelcome) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CWelcome, CDialog) 
	//{{AFX_MSG_MAP(CWelcome) 
	ON_WM_PAINT() 
	ON_WM_TIMER() 
	ON_BN_CLICKED(ID_MOVEWND, OnMovewnd) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CWelcome message handlers 
 
void CWelcome::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	 
	// TODO: Add your message handler code here 
	tm tm_data; 
	_getsystime(&tm_data);	 
 
	GetDlgItem(IDC_ZHUHE)->GetWindowRect(&rect); 
	ScreenToClient(&rect); 
	CString str; 
	str.Format("%d年%d月%d日%d时%d分%d秒", 1900+tm_data.tm_year, tm_data.tm_mon+1, 
		tm_data.tm_mday, tm_data.tm_hour, tm_data.tm_min, tm_data.tm_sec); 
	dc.SetBkMode(TRANSPARENT); 
	dc.TextOut(rect.left+18, rect.top+135, str);	 
	rect.left = rect.left+18; 
	rect.top  = rect.top+135; 
	// Do not call CDialog::OnPaint() for painting messages 
} 
 
void CWelcome::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
	if(nIDEvent == 5) 
		InvalidateRect(&rect, TRUE); 
	if(nIDEvent == 6) 
		OnMovewnd(); 
	CDialog::OnTimer(nIDEvent); 
} 
 
BOOL CWelcome::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	SetTimer(5, 1000, NULL); 
 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
int m_gmove = 0; 
 
void CWelcome::OnMovewnd()  
{ 
	// TODO: Add your control notification handler code here 
	if(m_gmove == 0) 
	{ 
		::GetWindowRect(m_hWnd, &WndRect); 
//		KillTimer(5); 
		SetTimer(6, 20, NULL); 
		m_gmove++; 
	} 
	::MoveWindow(m_hWnd, WndRect.left, WndRect.top-5, WndRect.Width(), WndRect.Height(), TRUE); 
	WndRect.top = WndRect.top - 5; 
	WndRect.bottom = WndRect.bottom - 5; 
 
	if(WndRect.bottom <= 2) 
	{ 
		KillTimer(5); 
		KillTimer(6); 
		OnCancel(); 
	} 
}