?? chooselistdialog.cpp
字號:
// ChooseListDialog.cpp : implementation file
//
/* This sample application and corresponding sample code is provided
* for example purposes only. It has not undergone rigorous testing
* and as such should not be shipped as part of a final application
* without extensive testing on the part of the organization releasing
* the end-user product.
*/
#include "stdafx.h"
#include "ChooseListDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChooseListDialog dialog
CChooseListDialog::CChooseListDialog(const CString& inPrompt, const CStringList & inChoices, int inDefaultChoice, CWnd* pParent /*=NULL*/)
: prompt(inPrompt), choices(inChoices), defaultChoice(inDefaultChoice), CDialog(CChooseListDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CChooseListDialog)
m_Choice = _T("");
//}}AFX_DATA_INIT
}
void CChooseListDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChooseListDialog)
DDX_LBString(pDX, IDC_CHOICE_LIST, m_Choice);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChooseListDialog, CDialog)
//{{AFX_MSG_MAP(CChooseListDialog)
ON_LBN_DBLCLK(IDC_CHOICE_LIST, OnDblclkChoiceList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChooseListDialog message handlers
const CString CChooseListDialog::GetChoice() /*throw (CString)*/ {
DoModal();
if(m_Choice == "")
throw CString("No selection made");
else
return m_Choice;
}
BOOL CChooseListDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CListBox* list = (CListBox*)GetDlgItem(IDC_CHOICE_LIST);
list->SetCurSel(defaultChoice);
int j;
POSITION i;
for(j = 0, i = choices.GetHeadPosition(); i != NULL;j++) {
list->InsertString(j, choices.GetNext(i));
}
CStatic* promptControl = (CStatic*)GetDlgItem(IDC_PROMPT);
promptControl->SetWindowText(prompt);
SetWindowText(prompt);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CChooseListDialog::OnCancel()
{
CDialog::OnCancel();
m_Choice = "";
}
void CChooseListDialog::OnDblclkChoiceList()
{
OnOK();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -