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

📄 pcdmview.cpp

📁 《Windows CE 权威指南》(作者:(美)CHRIS MUENCH
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// PCDMView.cpp : implementation of the CPCDMView class
//

#include "stdafx.h"
#include "PCDM.h"

#include "PCDMDoc.h"
#include "PCDMView.h"

//<BOOK_ADDON STEP7 Chapter 9.6.4> *********************************
#include "waitdlg.h"
//</BOOK_ADDON STEP7 Chapter 9.6.4> *********************************

//<BOOK_ADDON STEP5 Chapter 7.4.4> *********************************
#include "details.h"
#include "finddlg.h"
//</BOOK_ADDON STEP5 Chapter 7.4.4> *********************************
// <BOOK_ADDON Step6 Chapter 8.3.5> *********************************
using namespace PCDMdll_space;
// </BOOK_ADDON Step6 Chapter 8.3.5> *********************************

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


// <BOOK_ADDON STEP8 Chapter 10.2.3> ***************************
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CPCDMPicture	m_Picture;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();		// Added for WCE apps
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Control(pDX, IDC_PCDMPICTURE1, m_Picture);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CPCDMApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CPCDMApp commands
// Added for WCE apps
BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

// <BOOK_ADDON STEP8 Chapter 10.2.3> ***************************
#define IDB_ABOUTBMP                    211	// From PCDMUI Resource.h
	m_Picture.Load(TEXT(""),IDB_ABOUTBMP);	
	sndPlaySound(TEXT("\\windows\\exclam.wav"),SND_ASYNC);
// </BOOK_ADDON STEP8 Chapter 10.2.3> ***************************
	CenterWindow();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
// </BOOK_ADDON STEP8 Chapter 10.2.3> ***************************

/////////////////////////////////////////////////////////////////////////////
// CPCDMView

IMPLEMENT_DYNCREATE(CPCDMView, CFormView)

BEGIN_MESSAGE_MAP(CPCDMView, CFormView)
	//{{AFX_MSG_MAP(CPCDMView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPCDMView construction/destruction

CPCDMView::CPCDMView()
	: CFormView(CPCDMView::IDD)  // <BOOK_ADDON Step2 Chapter 7.1.4/> **********
{
//<BOOK_ADDON STEP5 Chapter 7.4.4> *********************************
	m_LastRow=-1;
	m_SearchString[0]=0;
//</BOOK_ADDON STEP5 Chapter 7.4.4> *********************************
}

CPCDMView::~CPCDMView()
{
}

BOOL CPCDMView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CPCDMView drawing

void CPCDMView::OnDraw(CDC* pDC)
{
	CPCDMDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CPCDMView diagnostics

#ifdef _DEBUG
void CPCDMView::AssertValid() const
{
	CFormView::AssertValid();
}

void CPCDMView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CPCDMDoc* CPCDMView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPCDMDoc)));
	return (CPCDMDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CPCDMView message handlers

// <BOOK_ADDON Step2 Chapter 7.1.4> **********************************************
void CPCDMView::DoDataExchange(CDataExchange* pDX) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPCDMView)
	DDX_Control(pDX, IDC_COMMANDER, m_cmdBar);
	DDX_Control(pDX, IDC_PCDMLIST, m_LVC);
	//}}AFX_DATA_MAP
}

BEGIN_EVENTSINK_MAP(CPCDMView, CFormView)
    //{{AFX_EVENTSINK_MAP(CPCDMView)
	ON_EVENT(CPCDMView, IDC_COMMANDER, 1 /* CmdBarAction */, OnCmdBarActionCommander, VTS_I4 VTS_BSTR)
	ON_EVENT(CPCDMView, IDC_PCDMLIST, 1 /* RowSelected */, OnRowSelected, VTS_I4 VTS_I4 VTS_I4)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CPCDMView::OnCmdBarActionCommander(long ID, LPCTSTR text) 
{
// <BOOK_ADDON STEP7 Chapter 9.6.4> ***************************
#define RETRIES	5
CWaitDlg	*tDlg;
BSTR		tBstr;
IPCDMAccessDBPtr  comDB;
IPCDMUtilsPtr	  comUtils;
long		DBHandle,FieldCnt;
HRESULT		hr;
TCHAR		tStr[255];
VARIANT		value,tvalue;
// </BOOK_ADDON STEP7 Chapter 9.6.4> ***************************

//<BOOK_ADDON STEP5 Chapter 7.4.4> *********************************
	switch (ID)
	{
		case 31:
			if (m_LastRow!=-1)
			{
				CDetails *dlg;
				int plat;

		 		plat=LOWORD(((CPCDMApp *)AfxGetApp())->m_CePlatform);
				if (plat>=CEP_PALMPC && plat<CEP_PALMPCEND)
					dlg=new CDetails(IDD_CDDETAILSPALM,m_LastRow);
				else
					dlg=new CDetails(IDD_CDDETAILS,m_LastRow);					
				dlg->DoModal();
				delete dlg;
			}
		  break;
		case 32:
			{
			LONG Result=0,tRes=0;
			LV_FINDINFO FindIt;

				if (m_SearchString[0]==0)
				{
					CFindDlg *dlg;
					dlg=new CFindDlg();
					dlg->DoModal();
					wsprintf(m_SearchString,dlg->m_FindString);
					if (m_SearchString[0]==0)
						break;
				}
				memset(&FindIt,0,sizeof(FindIt));
				FindIt.flags=LVFI_PARTIAL;
				FindIt.psz=m_SearchString;
				Result=m_LVC.SendCommand(LVM_FINDITEM,0,(long)&FindIt);
				if (Result>=0)
				{
					tRes=m_LVC.SendCommand(LVM_ENSUREVISIBLE,Result,FALSE);
					LV_ITEM lvi;
					memset(&lvi,0,sizeof(lvi));
					lvi.stateMask=0x000F;
					lvi.state=LVIS_FOCUSED | LVIS_SELECTED;
					tRes=m_LVC.SendCommand(LVM_SETITEMSTATE ,Result,(long)&lvi);
					tRes=m_LVC.SendCommand(LVM_UPDATE ,Result,0);
					Result=tRes;
				}
			}
		  break;
		case 1007:
			wsprintf(m_SearchString,text);
		  break;
// <BOOK_ADDON STEP9 Chapter 11.2.2> ***************************
		case 34:
			{
				CreateProcess(TEXT("peghelp.exe"),
						TEXT("file:PCDM.htm#Main_Contents"), 
						NULL, NULL, FALSE, 0, NULL,
						NULL, NULL, NULL);
			}
		  break;
// </BOOK_ADDON STEP9 Chapter 11.2.2> ***************************
// <BOOK_ADDON STEP8 Chapter 10.2.3> ***************************
		case 35:
			{
				CAboutDlg aboutDlg;
				aboutDlg.DoModal();
			}

⌨️ 快捷键说明

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