📄 choice.cpp
字号:
// Choice.cpp : implementation file
//
#include "stdafx.h"
#include "choice.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChoice dialog
CChoice::CChoice(CWnd* pParent /*=NULL*/, int nCurrSel)
: CDialog(CChoice::IDD, pParent)
{
//{{AFX_DATA_INIT(CChoice)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pParent=(CCardtestDlg *)pParent;
m_CurrSel=nCurrSel;
}
void CChoice::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChoice)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChoice, CDialog)
//{{AFX_MSG_MAP(CChoice)
ON_LBN_SELCHANGE(IDC_CARDLIST, OnSelchangeCardlist)
ON_LBN_DBLCLK(IDC_CARDLIST, OnDblclkCardlist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChoice message handlers
int FindPciDevices(CPciList* pList, ULONG uTarget);
void CChoice::OnOK()
{
// TODO: Add extra validation here
EndDialog(1);
CListBox *pList=(CListBox *)GetDlgItem(IDC_CARDLIST);
m_pParent->SelCard(pList->GetCurSel());
CDialog::OnOK();
}
void CChoice::OnCancel()
{
// TODO: Add extra cleanup here
EndDialog(0);
CDialog::OnCancel();
}
BOOL CChoice::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CCard card;
int nBus, nSlot;
g_bWin98=FALSE;
if(card.OpenCard(1)){
card.GetBusSlot(&nBus, &nSlot);
if(nBus==0 && nSlot==0)
g_bWin98=TRUE;
card.CloseCard();
}
if(g_bWin98)
g_nTotal=FindPciDevices(g_PciList, 0x71461131);
CListBox *pList=(CListBox *)GetDlgItem(IDC_CARDLIST);
for(int i=0; i<64; i++){
if(card.OpenCard(i+1)){
m_pParent->AddCard(i+1);
card.GetBusSlot(&nBus, &nSlot);
card.CloseCard();
CString str;
str.Format("卡%d, 总线号=%d, 设备号=%d", i+1, nBus, nSlot);
pList->AddString(str);
}
}
if(m_CurrSel>=0)
pList->SetCurSel(m_CurrSel);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CChoice::OnSelchangeCardlist()
{
// TODO: Add your control notification handler code here
CListBox *pList=(CListBox *)GetDlgItem(IDC_CARDLIST);
int nSel=pList->GetCurSel();
if(nSel<0)
GetDlgItem(IDOK)->EnableWindow(FALSE);
else
GetDlgItem(IDOK)->EnableWindow(TRUE);
}
void CChoice::OnDblclkCardlist()
{
// TODO: Add your control notification handler code here
OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -