CHKBOOK

The CHKBOOK sample demonstrates how to simulate multiple views in Windows CE by hiding/showing windows. (Windows CE does not support Multi-Document Interface (MDI).)

There is only one view of the document, implemented in class CCheckBookView. To enter or view data for a single check, select the menu item View Check, and a dialog is displayed. To show a summary of each check in the checkbook, select the menu item View Book, and an edit window is displayed. The two views cannot be seen at the same time, but you can toggle between them.

You can change the current selection in the checkbook view by using the menu items Previous and Next, or by tapping a check item with the stylus. The check view always shows the current selection in the checkbook view.

The check amount field in the check form view validates and converts a textual representation such as "19.98" to an internal DWORD representation. CHKBOOK does not do arithmetic, but it easily could be extended to add up all the check amounts and display the total on a bottom line.

Record-Based Documents

A CHKBOOK file is a record-based document. The system updates the persistent data (on disk or hard drive) of a record-based document each time the user adds, deletes, or modifies some portion of its data. For file-based documents, by contrast, the system reads a file entirely into memory when you open a file and writes it entirely back to the disk only when you close the document.

CHKBOOK Simplifications

The CHKBOOK sample has several simplifications to keep the code focused on MFC features and techniques the sample is designed to illustrate. For example:

Creating a new CHKBOOK File

CHKBOOK does not have a “new” file option. To create a new file, you need to open the blank check file (BlankCheck.chb), modify it as desired, and then save it under a different file name.

To use the Blankcheck.chb sample, you need to copy it to the My Documents directory on the device. If you want to save it as a template, copy it to the My Documents\Template directory. You can use pfile to copy the file to the device by typing the following command:

pfile copy BlankCheck.chb "wce:\My Documents\Templates\BlankCheck.chb"

When you commit a check, CHKBOOK writes the check to the CURRENT file When you select Save As, CHKBOOK will save the last uncommitted check in the specified file. It will not save the committed checks to the specified file, because the committed files have already been written into the open CURRENT file.

    To save a committed check in a file

  1. In the current file, write and commit the check..
  2. Select Save As, enter a new file name and select OK. Nothing is saved at this point since all your checks are written to your original file.
  3. Open the new file as the current file. Any check committed from now on will be saved to this new file.

This sample demonstrates the following keywords:

CArchive::IsStoring CString::Format
CCmdUI::Enable CString::LoadString
CCmdUI::SetCheck CString::GetLength
CDC::GetTextMetrics CString::Left
CDataExchange::Fail CWinApp::AddDocTemplate
CDataExchange::PrepareEditCtrl CWinApp::OnFileNew
CDialog::DoModal CWnd::Create
CDocument::GetFirstViewPosition CWnd::DoDataExchange
CDocument::GetNextView CWnd::GetClientRect
CEdit::CharFromPos CWnd::MessageBox
CEdit::LineIndex CWnd::OnShowWindow
CEdit::SetSel CWnd::SendMessage
CEdit::SetTabStops CWnd::SetFocus
CFile::Close CWnd::SetWindowText
CFile::Open CWnd::ShowWindow
CFile::Read CWnd::UpdateData
CFile::Seek CWnd::UpdateWindow
CFile::Write AfxMessageBox
CFrameWnd::AddAdornments GetWindowText
CFrameWnd::GetActiveDocument SetWindowText
CFrameWnd::InsertButtons _tcslen
CObject::AssertValid _ttoi
CObject::Dump _ttol
CObject::IsKindOf  

You can find the CHKBOOK project files in the Wce\Samples\Mfc\CHKBOOK directory.

For information on the Windows CE platforms that support this sample, see MFC for Windows CE Samples.