NotesDem.exe Reads and Writes the Contacts NOTES Field (190972)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q190972

SUMMARY

NotesDem.exe is an MFC sample for Windows CE that demonstrates how to read and write the NOTES field of the Contacts Database using the RichInk control. The NOTES field in the Contacts application is not the same field as HHPR_NOTES used in the address card structure. Actually, it is not even part of the addresscard structure so you must use the Windows CE Database APIs to get access to it.

MORE INFORMATION

The following files are available for download from the Microsoft Download Center:


NotesDem.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.



The property ID of the NOTES field is 0x170041. It contains binary data in the RichInk control format. There is an article "\Windows CE Platform SDK\Support\RichInk\RichInk.doc" that describes how to use the RichInk control.

Reading the NOTES field is not very difficult. The following code taken from NotesDemo.exe shows how you could read the field into a RichInk control:
   HANDLE h_contact;
   CEPROPVAL* propval;
   WORD  propsrecv = 1;
   CEPROPID ceprops[] = {0x170041};
   DWORD buflen = 0;
   PEGOID id = GetAddressCardOid(m_CardIndex);
   DWORD index;

   h_contact=CeOpenDatabase(&contactsid,_T("Contacts Database"),0,0,NULL);
   CeSeekDatabase(h_contact,CEDB_SEEK_CEOID,id,&index);

   if(!CeReadRecordProps(h_contact,CEDB_ALLOWREALLOC,&propsrecv,
                         ceprops,(unsigne d char**)&propval,&buflen))
   {
      MessageBox(_T(" Failed to read data! "));
   }

   ::SendMessage(m_hRichInkCtrl,IM_CLEARALL,0,0);
   ::SendMessage(m_hRichInkCtrl,IM_SETDATA,
                 (WPARAM)propval->val.blob.dwCount,
                 (LPARAM)propval->val.blob.lpb);
   CloseHandle(h_contact);
				
The NotesDem.exe sample also demonstrates how to write to the NOTES field.

NOTE: RichInk.h includes the calerror.h file. This file was not distributed with the Windows CE Toolkit for Visual C++ 5.0. This include can be commented out for the build. This control does not exist for the x86 emulation mode.

REFERENCES

Windows CE Programmers Guide: Accessing Persistent Storage

Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbfile kbinfo kbSample KB190972