Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Listing child windows for the Windows desktop
Switching between keyboard layouts
Accessing Adobe Reader 7.0 main menu from VFP application
How to control Adobe Reader 9.0 (SDI mode) from VFP application
Storing the environment strings in cursor
Validating the heap of the calling process
Winsock: retrieving the host information corresponding to a network address
GDI+: Storing DLL icon resources in image files
How to print FoxPro form -- II
Reading and setting explicit Application User Model ID for the current process (Win7)
Retrieving IP statistics for the computer
Using InternetGoOnline function
Using Common Controls: the Header Control
Class library providing access to the System Registry
How to display advanced Task Dialog (Vista)
How to find which fonts Windows uses for drawing captions, menus and message boxes
Obtaining some properties for the Windows desktop using the GetWindowPlacement function
Pocket PC: Folder Viewer
Reading STARTUPINFO structure for the current VFP session
Retrieving list of all active RAS connections
Displaying standard progress dialog box when copying files
Drawing a window caption using the DrawCaption routine
Enumerating the subkeys of a user-specific key
How to register custom Event Log source
Pocket PC: retrieving data from the Contacts Database

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
Start ActiveSync and establish connection with your Pocket PC before the testing.

The code is based on base RAPI Database class and on custom RAPI Database class for operating with the Object Store Databases. Download both class modules prior to testing this code.
 
SET PROCEDURE TO clsRapi ADDITIVE
SET PROCEDURE TO clsRapiDb ADDITIVE
 
LOCAL oRapi As TrapiDb
oRapi = CREATEOBJECT("TrapiDb")
 
IF NOT oRapi.Connected
    = MESSAGEBOX("Mobile device is unavailable.     ", 48, "Error")
    RETURN
ENDIF
 
LOCAL db, nIndex, firstname, middlename, lastname, email,;
    cellphone, homephone, note23, ex As Exception
 
TRY
    db = oRapi.databases.GetDatabase("Contacts Database")
*    db = oRapi.databases.GetDatabase("dbContactsCopy")
 
    IF db.OpenDatabase()
        CREATE CURSOR contacts (firstname C(15), middlename C(15),;
            lastname C(25), cellphone C(20), homephone C(20),;
            email C(50), note23 M)
 
        FOR nIndex=0 TO db.dbreccount-1
            db.goto(nIndex)
 
            firstname = FromUnicode(db.props.GetValue("14854", ""))
            middlename = FromUnicode(db.props.GetValue("16420", ""))
            lastname = FromUnicode(db.props.GetValue("14865", ""))
            email = FromUnicode(db.props.GetValue("16515", ""))
            cellphone = FromUnicode(db.props.GetValue("14876", ""))
            homephone = FromUnicode(db.props.GetValue("14857", ""))
            note23 = db.props.GetValue("23", "")
 
            INSERT INTO contacts VALUES (;
                m.firstname, m.middlename, m.lastname,;
                m.cellphone, m.homephone, m.email, m.note23)
        ENDFOR
        db.CloseDatabase
    ELSE
        = MESSAGEBOX("Could not open requested database.     ",;
            48, "Error")
    ENDIF
 
CATCH TO ex
    = MESSAGEBOX("Error: " + TRANSFORM(ex.ErrorNo) + ". " +;
        ex.Message + ".     ", 48, "Error")
ENDTRY
 
IF USED("contacts")
    SELECT contacts
    GO TOP
    BROWSE NORMAL NOWAIT
ENDIF
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1552 bytes  
Created: 2004-07-02 16:56:56  
Modified: 2009-02-15 19:31:15  
Visits in 7 days: 88  
Listed functions:
Printer friendly API declarations
My comment:
To make it short: the mobile database model is quite different from the relational model. The Contacts Database records retrieved in this example most likely will have various number of properties per record (those we call "fields" in FoxPro). Though each record has unique object identifier assigned by the system.

What RAPI calls a database is actually a table. And RAPI database volume has some resemblance to database as storage of data and integrity log.

There is no table header with field parameters. Instead of field names the property identifiers are used. For the Contacts Database, for example, identifier 14876 means "Mobile Phone Number". The property is described by identifier, data type, flags and value.

It looks like any application working with the Contacts Database must be aware of this particular PropertyID to Caption translation as well as of the others:

14856=Work Tel
14857=Home Tel
14876=Mobile Tel
14878=Car Tel
14884=Work Fax
14885=Home Fax
14895=Home2 Tel
16388=Asst. Tel
16391=Work2 Tel
16393=Pager
16458=Other Street
16459=Other City
16460=Other State
16461=Other Zip
14853=Suffix
14854=First Name
14865=Last Name
14870=Company
14871=Title
14872=Department
14873=Office Location
14877=Radio
16386=Assistant
16390=Children
16392=Web Page
16394=Spouse
16403=File As
16419=Mr/Mrs/Dr
16420=Middle Name
16448=Home Street
16449=Home City
16450=Home State
16451=Home Zip
16452=Home Country
16453=Office Street
16454=Office City
16455=Office State
16456=Office Zip
16457=Office Country
16462=Other Country
16515=Email1
16531=Email2
16547=Email3

These property ids have some resemblance to WordPerfect Address Book codes. Other than that I have no idea where these values came from and if any White Paper exists on them.

API functions used in the base class:
CeCloseHandle
CeEnumDBVolumes
CeFindFirstDatabaseEx
CeFindNextDatabaseEx
CeGetLastError
CeOidGetInfoEx
CeOpenDatabase
CeRapiInitEx
CeRapiUninit
CeReadRecordProps
CeSeekDatabase
LocalFree
WaitForSingleObject


#kwd: sln_pocketpc.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.234.231.49)
5 sec.Example: 'List of addresses in the AutoDial mapping database'
Google
Advertise here!