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

📄 operatorlistdlg.cpp

📁 Retrieving list of known operators using Radio Interface Layer (RIL) Windows Mobile
💻 CPP
字号:
// OperatorListDlg.cpp : implementation file
//

#include "stdafx.h"
#include "OperatorList.h"
#include "OperatorListDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define __ALL_OPERATORS__

void CALLBACK ResultCallback(DWORD dwCode,HRESULT hrCmdID,const void *lpData,DWORD cbData,DWORD dwParam)
{
	COperatorListDlg*	pDialog	= (COperatorListDlg*)dwParam;

	if(pDialog->GetOperatorListResult() == hrCmdID)
	{
#if defined(__ALL_OPERATORS__)
		RILOPERATORNAMES*	pList	= (RILOPERATORNAMES*)lpData;
		int					nCount	= cbData/sizeof(RILOPERATORNAMES);
#else
		RILOPERATORINFO*	pInfo	= (RILOPERATORINFO*)lpData;
		int					nCount	= cbData/sizeof(RILOPERATORINFO);
#endif
		
		CString				strName;

		for(int nList=0; nList<nCount; ++nList)
		{
#if defined(__ALL_OPERATORS__)
			pDialog->AddToList(nList,&pList[nList]);
#else
			pDialog->AddToList(nList,&pInfo[nList].ronNames);
#endif
		}
	}
}

void CALLBACK NotifyCallback(DWORD dwCode,const void *lpData,DWORD cbData, DWORD dwParam)
{
	COperatorListDlg*	pDialog	= (COperatorListDlg*)dwParam;
}

// COperatorListDlg dialog
COperatorListDlg::COperatorListDlg(CWnd* pParent /*=NULL*/)
	: CDialog(COperatorListDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_hRIL	= NULL;
}

void COperatorListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_OPLIST, m_wndOpList);
}

BEGIN_MESSAGE_MAP(COperatorListDlg, CDialog)
	ON_WM_SIZE()
	ON_WM_DESTROY()

	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


// COperatorListDlg message handlers

BOOL COperatorListDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	m_wndOpList.ModifyStyle(0,LVS_REPORT);
	m_wndOpList.SetExtendedStyle(LVS_EX_FULLROWSELECT);

	m_wndOpList.InsertColumn(0,TEXT("Name"),LVCFMT_LEFT,100);
	m_wndOpList.InsertColumn(1,TEXT("Number"),LVCFMT_LEFT,50);
	m_wndOpList.InsertColumn(2,TEXT("Country"),LVCFMT_LEFT,75);

	HRESULT	hr = RIL_Initialize(1,ResultCallback,NotifyCallback,
								RIL_NCLASS_ALL,(DWORD)this,&m_hRIL);

	if(FAILED(hr))
	{
		m_hRIL	= NULL;

		AfxMessageBox(TEXT("Failed to initialize RIL"));
	}
	else
	{
#if defined(__ALL_OPERATORS__)
		m_hResultOpList	= RIL_GetAllOperatorsList(m_hRIL);
#else
		m_hResultOpList	= RIL_GetOperatorList(m_hRIL);
#endif

		if(FAILED(m_hResultOpList))
		{
			AfxMessageBox(TEXT("Error getting operator list"));
		}
	}
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void COperatorListDlg::OnDestroy()
{
	if(m_hRIL)
		RIL_Deinitialize(m_hRIL);

	CDialog::OnDestroy();
}

void COperatorListDlg::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType,cx,cy);

	if(m_wndOpList.GetSafeHwnd())
	{
		m_wndOpList.SetWindowPos(NULL,DRA::SCALEX(X_OFFSET),DRA::SCALEY(Y_OFFSET),
			DRA::SCALEX(cx - X_OFFSET * 2),DRA::SCALEY(cy - Y_OFFSET * 2),SWP_NOZORDER);
	}
}

void COperatorListDlg::AddToList(int nItem,RILOPERATORNAMES* pOpName)
{
	CString		strName(pOpName->szLongName);
	CString		strNum(pOpName->szNumName);
	CString		strCountry(pOpName->szCountryCode);

	int			nItemNo		= m_wndOpList.InsertItem(nItem,strName);

	m_wndOpList.SetItemText(nItemNo,1,strNum);
	m_wndOpList.SetItemText(nItemNo,2,strCountry);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -