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

📄 pdb readerdlg.cpp

📁 PALM PDB文件阅读器源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// PDB ReaderDlg.cpp : implementation file
//

#include "stdafx.h"
#include "PDB Reader.h"
#include "PDB ReaderDlg.h"
#include "RecDefDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

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

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

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

/////////////////////////////////////////////////////////////////////////////
// CPDBReaderDlg dialog

CPDBReaderDlg::CPDBReaderDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPDBReaderDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPDBReaderDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	thisApp=(CPDBReaderApp *) AfxGetApp();
}

void CPDBReaderDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPDBReaderDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPDBReaderDlg, CDialog)
	//{{AFX_MSG_MAP(CPDBReaderDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
	ON_WM_SIZE()
	ON_WM_SHOWWINDOW()
	ON_COMMAND(IDM_FILE_OPEN, OnFileOpen)
	ON_COMMAND(IDM_FILE_SAVE, OnFileSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPDBReaderDlg message handlers

BOOL CPDBReaderDlg::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
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CPDBReaderDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CPDBReaderDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CPDBReaderDlg::OnFileOpen() 
{
	CRecDefDlg dlg;
	_TCHAR		chrFileName[_MAX_PATH]=_T("");

	OPENFILENAME	ofnSave;

	strFileName = "";

	ofnSave.lStructSize = sizeof(OPENFILENAME);
	ofnSave.hwndOwner = GetSafeHwnd();
	ofnSave.lpstrFilter = "Pilot Databases\000*.PDB\000\000";
	ofnSave.lpstrCustomFilter = NULL;
	ofnSave.nFilterIndex = 1;
	ofnSave.lpstrFile = chrFileName;
	ofnSave.nMaxFile = _MAX_PATH;
	ofnSave.lpstrFileTitle = NULL;
	ofnSave.lpstrInitialDir = NULL;
	ofnSave.lpstrTitle = _T("Read PDB File");
	ofnSave.Flags = OFN_LONGNAMES | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_SHAREAWARE;
	ofnSave.lpstrDefExt = _T("PDB");
	ofnSave.lpfnHook = NULL;
	ofnSave.lpTemplateName = NULL;

	if (GetOpenFileName(&ofnSave)) {
		thisApp->dlgRec = &dlg;			// Change so the application knows where to direct accellerators

		if (dlg.DoModal() == IDOK) {
			strFileName = chrFileName;
			LoadPDBFile();
		}

		thisApp->dlgRec = NULL;			// Turn off the accellerator redirect
	}
}

void CPDBReaderDlg::OnFileSave() 
{
	ofstream	filTemp;
	_TCHAR		strFileName[_MAX_PATH]=_T("");

	OPENFILENAME	ofnSave;

	ofnSave.lStructSize = sizeof(OPENFILENAME);
	ofnSave.hwndOwner = GetSafeHwnd();
	ofnSave.lpstrFilter = "Text File\000*.TXT\000\000";
	ofnSave.lpstrCustomFilter = NULL;
	ofnSave.nFilterIndex = 1;
	ofnSave.lpstrFile = strFileName;
	ofnSave.nMaxFile = _MAX_PATH;
	ofnSave.lpstrFileTitle = NULL;
	ofnSave.lpstrInitialDir = NULL;
	ofnSave.lpstrTitle = _T("Save Report");
	ofnSave.Flags = OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_SHAREAWARE;
	ofnSave.lpstrDefExt = _T("TXT");
	ofnSave.lpfnHook = NULL;
	ofnSave.lpTemplateName = NULL;
	

	if (GetSaveFileName(&ofnSave)) {
		filTemp.open(strFileName);
		if (filTemp.is_open()) {
			long		i;
			CListBox*	lstTemp;
			CString		strTemp;

			lstTemp = (CListBox *) GetDlgItem(IDC_RESULT_LIST);
			
			for (i=0; i < lstTemp->GetCount(); i++) {
				lstTemp->GetText(i, strTemp);
				filTemp << strTemp << endl;
			}

			filTemp.close();
		}
	}
}

void CPDBReaderDlg::OnFileSaveAs() 
{
	ofstream	filTemp;
	_TCHAR		strFileName[_MAX_PATH]=_T("");

	OPENFILENAME	ofnSave;

	ofnSave.lStructSize = sizeof(OPENFILENAME);
	ofnSave.hwndOwner = GetSafeHwnd();
	ofnSave.lpstrFilter = "Comma Separated Value File\000*.CSV\000\000";
	ofnSave.lpstrCustomFilter = NULL;
	ofnSave.nFilterIndex = 1;
	ofnSave.lpstrFile = strFileName;
	ofnSave.nMaxFile = _MAX_PATH;
	ofnSave.lpstrFileTitle = NULL;
	ofnSave.lpstrInitialDir = NULL;
	ofnSave.lpstrTitle = _T("Save Report");
	ofnSave.Flags = OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_SHAREAWARE;
	ofnSave.lpstrDefExt = _T("CSV");
	ofnSave.lpfnHook = NULL;
	ofnSave.lpTemplateName = NULL;
	

	if (GetSaveFileName(&ofnSave)) {
		filTemp.open(strFileName);
		if (filTemp.is_open()) {
			DumpPDBFile(filTemp);
			filTemp.close();
		}
	}
}

void CPDBReaderDlg::LoadPDBFile()
{
	CListBox*	lstTemp;

	CFile		filInput;

	CString		strTemp;
	_TCHAR		strConv[20];

	char			bytTemp;
	unsigned char	ubytTemp;

	long		i;
	long		j;

	arrRecInfo.RemoveAll();

	lstTemp = (CListBox *) GetDlgItem(IDC_RESULT_LIST);
	lstTemp->ResetContent();

	lstTemp->AddString(CString(_T("Dump of PDB file: <")) + strFileName + _T(">"));
	lstTemp->AddString(_T(""));

	filInput.Open(strFileName, CFile::modeRead);

	GetHeader(filInput, &uctHeader);

	lstTemp->AddString(CString(_T("Name: ")) + uctHeader.strName);

	strTemp = _T("\tAttr = ");
	strTemp += itoa(uctHeader.intAttr, strConv, 10);
	strTemp += _T("\t");

    if (uctHeader.intAttr & dmHdrAttrResDB)
        strTemp += _T("(P");
    else
        strTemp += _T("(-");
    
    if (uctHeader.intAttr & dmHdrAttrReadOnly)
        strTemp += _T("R");
    else
        strTemp += _T("-");
    
    if (uctHeader.intAttr & dmHdrAttrAppInfoDirty) 
        strTemp += _T("I");

⌨️ 快捷键说明

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