📄 mfcobjectstoredlg.cpp
字号:
// MFCObjectStoreDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MFCObjectStore.h"
#include "MFCObjectStoreDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMFCObjectStoreDlg dialog
CMFCObjectStoreDlg::CMFCObjectStoreDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMFCObjectStoreDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMFCObjectStoreDlg)
// 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);
}
void CMFCObjectStoreDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMFCObjectStoreDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMFCObjectStoreDlg, CDialog)
//{{AFX_MSG_MAP(CMFCObjectStoreDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMFCObjectStoreDlg message handlers
BOOL CMFCObjectStoreDlg::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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// <BOOK_ADDON Chapter 8.3.2> ******************************
void CMFCObjectStoreDlg::OnButton1()
{
CCeDBDatabase myDB;
// Step1 - Open/Create a database
// *********************************************
if (!CCeDBDatabase::Exists(TEXT("Book831")))
myDB.Create(TEXT("Book831"));
myDB.Open(TEXT("Book831"));
wprintf(TEXT("Step1 Complete: Database Opened\n\r"));
// Step2 - Writing a record
// *********************************************
CCeDBRecord rec;
CCeDBProp props[4];
SYSTEMTIME SystemTime;
FILETIME FileTime;
CEBLOB tBlob;
props[0] = CCeDBProp((long)0xffffffff, 0);
GetSystemTime(&SystemTime);
SystemTimeToFileTime(&SystemTime,&FileTime);
props[1] = CCeDBProp(FileTime,1);
props[2] = CCeDBProp(TEXT("This is a string property"),2);
tBlob.lpb=(LPBYTE)TEXT("This is a Blob property");
tBlob.dwCount=lstrlen((TCHAR *)tBlob.lpb)*sizeof(TCHAR);
props[3] = CCeDBProp(tBlob, 3);
rec.AddProps(props,4);
if(!myDB.AddRecord(&rec))
{ return; } // Handle Write Failure
// Step3 - Reading a record
// *********************************************
CCeDBProp *pProp;
if(!myDB.SeekFirst() || !myDB.ReadCurrRecord(&rec))
{ return; } // Handle Seek and Read Failure
for (int i=0;i<rec.GetNumProps();i++)
{
pProp = rec.GetPropFromIdent(i);
wprintf(TEXT(" : Prop/Field %d of Type %d\n\r"),
i+1,pProp->GetType());
}
// Step4 - Closing the Database
// *********************************************
myDB.Close();
}
// </BOOK_ADDON Chapter 8.3.2> ******************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -