?? statdlg.cpp
字號(hào):
// StatDlg.cpp : implementation file
//
#include "stdafx.h"
#include "five.h"
#include "StatDlg.h"
#include "Table.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStatDlg dialog
CStatDlg::CStatDlg(CWnd* pParent /*=NULL*/)
: CDialog(CStatDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CStatDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CStatDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStatDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStatDlg, CDialog)
//{{AFX_MSG_MAP(CStatDlg)
ON_BN_CLICKED(IDC_BTN_RESET, OnBtnReset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStatDlg message handlers
BOOL CStatDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// 讀取姓名
CTable *pTable = (CTable *)GetParent()->GetDlgItem( IDC_TABLE );
SetDlgItemText( IDC_ST_NAME, pTable->m_strMe );
ShowStat();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CStatDlg::OnOK()
{
// TODO: Add extra validation here
CFiveApp *pApp = (CFiveApp *)AfxGetApp();
// 寫入戰(zhàn)績(jī)統(tǒng)計(jì)
TCHAR str[10];
wsprintf( str, _T("%d"), pApp->m_nWin );
::WritePrivateProfileString( _T("Stats"), _T("Win"), str, pApp->m_szIni );
wsprintf( str, _T("%d"), pApp->m_nDraw );
::WritePrivateProfileString( _T("Stats"), _T("Draw"), str, pApp->m_szIni );
wsprintf( str, _T("%d"), pApp->m_nLost );
::WritePrivateProfileString( _T("Stats"), _T("Lost"), str, pApp->m_szIni );
CDialog::OnOK();
}
void CStatDlg::OnBtnReset()
{
// TODO: Add your control notification handler code here
CFiveApp *pApp = (CFiveApp *)AfxGetApp();
pApp->m_nWin = 0;
pApp->m_nDraw = 0;
pApp->m_nLost = 0;
ShowStat();
}
void CStatDlg::ShowStat()
{
CFiveApp *pApp = (CFiveApp *)AfxGetApp();
CString str;
str.Format( _T("%d"), pApp->m_nWin );
SetDlgItemText( IDC_ST_WIN, str );
str.Format( _T("%d"), pApp->m_nDraw );
SetDlgItemText( IDC_ST_DRAW, str );
str.Format( _T("%d"), pApp->m_nLost );
SetDlgItemText( IDC_ST_LOST, str );
// 計(jì)算勝率
if ( 0 == pApp->m_nWin )
{
str = _T("勝率:0%");
}
else
{
str.Format( _T("勝率:%d%%"), pApp->m_nWin * 100 / ( pApp->m_nWin + pApp->m_nDraw + pApp->m_nLost ) );
}
SetDlgItemText( IDC_ST_PERCENT, str );
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -