// TimeOutDlg.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "TimeOutDlg.h" ///////////////////////////////////////////////////////////////////////////// // TimeOutDlg dialog TimeOutDlg::TimeOutDlg(CWnd* pParent /*=NULL*/) : CDialog(TimeOutDlg::IDD, pParent) { //{{AFX_DATA_INIT(TimeOutDlg) m_psw2 = _T(""); //}}AFX_DATA_INIT } void TimeOutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(TimeOutDlg) DDX_Text(pDX, IDC_EDIT1, m_psw2); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(TimeOutDlg, CDialog) //{{AFX_MSG_MAP(TimeOutDlg) ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // TimeOutDlg message handlers void TimeOutDlg::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CBrush brush(RGB(235,235,235)); CRect rc; GetClientRect(rc); dc.FillRect (rc, &brush); rc.DeflateRect (2,2); brush.DeleteObject (); brush.CreateSolidBrush (RGB(229,54,189)); dc.FillRect (rc, &brush); rc.left +=10; rc.top +=20; Graphics graph(dc.GetSafeHdc()); RectF layoutRect(rc.left , rc.top, rc.Width (), rc.Height ()); StringFormat format; format.SetAlignment(StringAlignmentNear ); SolidBrush *Brush=new SolidBrush(Color(255,255,255,255)); CString str; str="温馨提示:"; int leng=GetLengthEx(str); BSTR bstr= str.AllocSysString(); Gdiplus::Font *g_TimerFont=new Gdiplus::Font(L"黑体", 13); graph.SetTextRenderingHint(TextRenderingHintAntiAlias); graph.DrawString( bstr, leng, g_TimerFont, layoutRect, &format, Brush); SysFreeString(bstr); rc.top +=30; rc.left +=40; RectF layoutRect2(rc.left , rc.top, rc.Width (), rc.Height ()); int hour,minute; int second=::GetTickCount ()-m_ticks; second/=1000; hour=second/3600; second-=3600*hour; minute=second/60; str.Format("尊贵的客人, 您选片已超过 %d 小时, %d 分钟!", hour, minute); leng=GetLengthEx(str); bstr= str.AllocSysString(); graph.SetTextRenderingHint(TextRenderingHintAntiAlias); graph.DrawString( bstr, leng, g_TimerFont, layoutRect2, &format, Brush); SysFreeString(bstr); GetDlgItem(IDC_EDIT1)->GetWindowRect(rc); ScreenToClient(rc); rc.right=rc.left; rc.left =0; RectF layoutRect3(rc.left , rc.top, rc.Width (), rc.Height ()); str="密码:"; leng=GetLengthEx(str); StringFormat format2; format2.SetAlignment(StringAlignmentFar ); bstr= str.AllocSysString(); graph.SetTextRenderingHint(TextRenderingHintAntiAlias); graph.DrawString( bstr, leng, g_TimerFont, layoutRect3, &format2, Brush); delete Brush; delete g_TimerFont; SysFreeString(bstr); // Do not call CDialog::OnPaint() for painting messages } void TimeOutDlg::OnOK() { // TODO: Add extra validation here UpdateData(); CString psw1=g_cominfoarray.ElementAt(0).ElementAt(98); psw1.TrimLeft(); psw1.TrimRight(); m_psw2.TrimLeft(); m_psw2.TrimRight(); if(psw1!=m_psw2) { AfxMessageBox("密码错误!"); return; } CDialog::OnOK(); } void TimeOutDlg::OnCancel() { // TODO: Add extra cleanup here } BOOL TimeOutDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here return 0; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }