⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chooselistdialog.cpp

📁 MapX+VC++的SerialSample,地图示例
💻 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 + -