📄 playerhistorydlg.cpp
字号:
// PlayerHistoryDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Russian.h"
#include "PlayerHistoryDlg.h"
#include "russianview.h"
#include "wcedb.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPlayerHistoryDlg dialog
CPlayerHistoryDlg::CPlayerHistoryDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPlayerHistoryDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPlayerHistoryDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pParent=(CRussianView*)pParent;
m_name=_T("");
m_score=0;
}
void CPlayerHistoryDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPlayerHistoryDlg)
DDX_Control(pDX, IDC_LIST_PLAYER, m_ListHistory);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPlayerHistoryDlg, CDialog)
//{{AFX_MSG_MAP(CPlayerHistoryDlg)
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPlayerHistoryDlg message handlers
BOOL CPlayerHistoryDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ListHistory.InsertColumn(0,_T("姓名"),LVCFMT_LEFT,75);
m_ListHistory.InsertColumn(1,_T("得分"),LVCFMT_LEFT,88);
//填充列表控制:
TCHAR a[20];
if(!m_pParent->m_DBPlayer.SeekFirst())
return false;
m_pParent->m_DBPlayer.m_bAutoSeekNext=true;
while(!m_pParent->m_DBPlayer.m_bEOF)
{
for(int iItem=0;iItem<m_pParent->m_DBPlayer.GetNumRecords();iItem++)
{
ReadRecord();
m_ListHistory.InsertItem(iItem,(LPCTSTR)m_name);
wsprintf(a,_T("%d"),m_score);
m_ListHistory.SetItemText(iItem,1,a);
}
}
m_pParent->m_DBPlayer.m_bAutoSeekNext=false;
m_pParent->m_DBPlayer.SeekFirst();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPlayerHistoryDlg::ReadRecord()
{
CString str;
CCeDBRecord m_DBRecord;
CCeDBProp* m_pValProperty[2];
if(!m_pParent->m_DBPlayer.ReadCurrRecord(&m_DBRecord))
{
AfxMessageBox(_T("Cann't read current record!"));
return;
}
m_pValProperty[0]=m_DBRecord.GetPropFromIdent(100);
m_pValProperty[1]=m_DBRecord.GetPropFromIdent(101);
m_name = m_pValProperty[0]->GetString();
m_score= m_pValProperty[1]->GetULong();
}
void CPlayerHistoryDlg::OnButtonDelete()
{
m_pParent->m_DBPlayer.Delete();
SendMessage(WM_CLOSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -