Quicktour - how to...
If you think that mobile application development is a difficult task, read this section and discover how fast and easy it is to add advanced features in your HB++ applications. Complex tasks can be carried out with just a few line of intuitive HB++ code!
How to use databases?
- Use Recordset objects to add a powerful and fast access to your databases. The Recordset class implements all the methods necessary to manipulate a table or a recordset resulting from a SQL query, and contains all the common properties and methods used to manage databases.
- It works just like Visual Basic®!
dim rsCustomer as new Customers
rsCustomer.OpenTable hbModeOpenAlways+hbModeReadWrite
rsCustomer.AddNew
rsCustomer.Name = "Kevin Smith"
rsCustomer.Address = Me.fldAddress.Text
rsCustomer.Town = Me.fldTown.Text
rsCustomer.ZIP = Me.fldZIP.Text
rsCustomer.Country = Me.lstCountry.ItemData(lstCountry.ListIndex)
rsCustomer.Update
rsCustomer.Close
End Sub
dim rsCustomer as new Customers
rsCustomer.OpenRecordset "Name LIKE '" & fldSearch.Text & "*'", hbModeOpenExisting+hbModeReadOnly
If rsCustomer.RecordCount > 0 then
lstCustomers.Clear
rsCustomer.MoveFirst
While not rsCustomer.EOF
lstCustomers.AddItem rsCustomer.Name, rsCustomer.Customer_ID
rsCustomer.MoveNext
Wend
Else
Msgbox "No customer found!",hbMsgBoxInformation
End if
rsCustomer.Close
End Sub
How to use infrared communications?
- HB++ features several classes enabling programmers to easily manage IR transmission functions. The StreamExg class implements a stream allowing data transfers between two handheld devices via the Palm OS® Exchange Manager.
- For example, if you want your application to beam itself to another device, the following lines of code are all you need.
Dim sExg as new StreamExg
sExg.Connect App.Info.Name & ".prc"
Write sExg, App.Info
sExg.Disconnect
End Sub
How to manage expansion cards?
The StreamFile class allows the manipulation of files stored on external media such as a Secure Digital or MultiMedia cards for example.
Dim s as New StreamFile
v.FindFirstVolume
s.Open v.Reference, "/tmp.txt", hbModeWrite+hbModeCreateAlways
Write s, "Hello World !"
s.Close
Use the StreamFile and the DatabaseInfo classes to copy databases from the handheld device memory to a memory card and vice versa. You can easily implement Backup and Restore functionality in a few lines:
Dim sf as New StreamFile
On Error Goto ERR
sf.Open iVolRef, "/" & db.Name & ".prc", hbModeCreateAlways+hbModeReadWrite
Write sf, db
sf.Close
CopyDatabaseToVFS=0
Exit Function
ERR:
CopyDatabaseToVFS=Err.Number
End Function
Public function RestoreDatabaseFromVFS(ByVal iVolRef as Integer, ByRef sName as String) as Integer
Dim di as New DatabaseInfo
Dim sf as New StreamFile
On error goto ERR
sf.Open iVolRef, sName, hbModeOpenExisting+hbModeReadOnly
Read sf, di
fd.Close
Exit Function
ERR:
RestoreDatabaseFromVFS=Err.Number
End Function
How to use graphics?
- HB++ provides advanced graphics functions. You will find these functions in the Display class and all the classes deriving from it.

- Using double buffering for fluid graphics and animation without flickering is possible :
Private Sub Form_Paint()
me.CopyArea 0,20,160,140,myOffscreenBitmap,0,0
End Sub
Networking
- The StreamSocket class implements a standard TCP/IP client socket:
Dim objSock as New StreamSocket
Dim cmd as String
cmd = "GET /MiniBrowser.html HTTP/1.1" & chr(10) & "host: www.handheld-basic.com\n\n"
objSock.Connect "www.handheld-basic.com", 80
objSock.Timeout=5000
'send the http query
Write objSock, cmd[Len(cmd)]
... - You can also use telephony functions to send SMS from a mobile phone connected to your handheld.
Notifications and Launch codes
- You can register various notifcations, in order to implement specific behaviour for your application using the Application class: For example, the following lines tells the system that your app have to be launched with a specific Launch code each time a HotSync® operation ends or when the device is started up:
RegisterNotify hbNotifySyncFinishEvent
RegisterNotify hbNotifyEarlyWakeupEvent - Then, each time the HotSync® operation ends or when the device is started up, the following method will be called:Private Sub Application_Notify(ByVal eNotify As HbNotify)
If eNotify = hbNotifySyncFinishEvent then
' Manage databases operations for example
....
End if
End Sub - Using alarm and reminders is also very easy - Add an alarm to your application just with the following line of code:
App.Alarm=Now()+3600.0/86400.0 'in one hour - Custom launch codes can also be used to enable communications between your app and other applications.
Building your own user control
- HB++ lets you build easily your own custom controls and extend your HB++ projects as far as you want with reusable and powerful custom controls. Take a look at the following tutorial: User control tutorial - how to create an enhanced Label custom control.
And more!
Download the Documentation, browse the Online Documentation, or directly try HB++.
