📄 enddlg.cpp
字号:
// EndDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Alert.h"
#include "EndDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "AlertDlg.h"
#include <vfw.h>
/////////////////////////////////////////////////////////////////////////////
// CEndDlg dialog
CEndDlg::CEndDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEndDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEndDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CEndDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEndDlg)
DDX_Control(pDX, IDC_PROGRESS, m_Progress);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEndDlg, CDialog)
//{{AFX_MSG_MAP(CEndDlg)
ON_WM_TIMER()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEndDlg message handlers
BOOL CEndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
GetDesktopWindow()->GetWindowRect(&rect);
MoveWindow(rect);
GetDlgItem(IDCANCEL)->MoveWindow(rect.left+20,rect.bottom-60,80,25);
GetDlgItem(IDOK)->MoveWindow(rect.right-100,rect.bottom-60,80,25);
GetDlgItem(IDC_PROGRESS)->MoveWindow(rect.left+180,rect.bottom-60,rect.Width()-360,20);
m_Progress.SetRange(0,150);
if(m_bShut)
{
SetTimer(IDD_END_DIALOG,100,NULL);
GetDlgItem(IDC_PROGRESS)->ShowWindow(SW_SHOW);
}
else
GetDlgItem(IDC_PROGRESS)->ShowWindow(SW_HIDE);
CAlertApp * pa = (CAlertApp *)AfxGetApp();
if(pa->GetProfileInt("Settings","PlayMusic",0))
{
FILE *p;
CString MusicPath=pa->GetProfileString("Settings","MusicPath","");
if(pa->GetProfileInt("Settings","OwnMusic",0))
{
if(p=fopen(MusicPath,"rb"))
{
PlaySound(MusicPath,NULL,SND_LOOP|SND_ASYNC);//==FALSE)
fclose(p);
}
else if(p=fopen("C:\\Windows\\Media\\Tada.wav","rb"))
{
PlaySound("C:\\Windows\\Media\\Tada.wav",NULL,SND_LOOP|SND_ASYNC);//==FALSE)
fclose(p);
}
}
else
if(p=fopen("C:\\Windows\\Media\\Tada.wav","rb"))
{
PlaySound("C:\\Windows\\Media\\Tada.wav",NULL,SND_LOOP|SND_ASYNC);//==FALSE)
fclose(p);
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEndDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
int sit=m_Progress.GetPos();
if(sit>=150)
OnOK();
else
m_Progress.SetPos(++sit);
CDialog::OnTimer(nIDEvent);
}
void CEndDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CAlertDlg * pf=(CAlertDlg *)AfxGetApp()->m_pMainWnd;
CFont fnt;
char buf[32];strcpy(buf,"楷体_GB2312");
CString m_Alert=pf->m_Alert;
if(m_Alert.GetLength())
{
fnt.CreateFont(1200/m_Alert.GetLength(),1500/(2*m_Alert.GetLength()+1),0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,buf);
dc.SetTextColor(RGB(255,0,0));
dc.SetBkColor(RGB(191,191,191));
dc.SelectObject(fnt);
dc.TextOut(12,110,m_Alert);
}
if(m_bShut)
{
CString str="请注意,15秒钟后自动关机!";
fnt.CreateFont(1200/str.GetLength(),1500/(2*str.GetLength()+1),0,0,FW_HEAVY,0,0,0,ANSI_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,buf);
dc.SetTextColor(RGB(255,0,0));
dc.SetBkColor(RGB(191,191,191));
dc.SelectObject(fnt);
dc.TextOut(12,300,str);
}
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CEndDlg::DestroyWindow()
{
PlaySound(NULL,NULL,SND_LOOP|SND_ASYNC);
return CDialog::DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -