Skip to main content

Past Blast

Featured Products

Windows Mobile Developer Controls
Windows Mobile Developer Controls
Stay in touch using the DEVBUSS RSS feeds.
 

News

Windows Mobile Developer Controls
Windows Mobile Developer Controls

IDSSAPI Part 2 & 3 - A useful set of API wrappers for eVB developers

Written by Robert Levy  [author's bio]  [read 34393 times]
Edited by Derek

Page 1  Page 2  Page 3 

With that out of the way I'd like to demonstrate how to use some of the functionality provided by IDSSAPI. After creating a reference to IDSSAPI in your project, the next step is to create an instance of each class it provides that you intend to use. Being that we will want to have access to IDSSAPI from anywhere in the program, add a new module to your project and put the following code in it:

Option Explicit

'define an object for each class in IDSSAPI
Public IDSS_Core As IDSSAPI.Core
Public IDSS_Reg As IDSSAPI.Registry
Public IDSS_Pwr As IDSSAPI.Power
Public IDSS_Mem As IDSSAPI.Memory
Public IDSS_Win As IDSSAPI.WindowHelper
Public IDSS_Lst As IDSSAPI.ListViewHelper

Private Sub main()

'create an instance of each class in IDSSAPI
Set IDSS_Core = CreateObject("IDSSAPI.Core")
Set IDSS_Reg = CreateObject("IDSSAPI.Registry")
Set IDSS_Pwr = CreateObject("IDSSAPI.Power")
Set IDSS_Mem = CreateObject("IDSSAPI.Memory")
Set IDSS_Win = CreateObject("IDSSAPI.WindowHelper")
Set IDSS_Lst = CreateObject("IDSSAPI.ListViewHelper")

Form1.Show
End Sub

Next, in the "Project Properties" dialog box, select "Sub Main" from the "Startup Object" list. You will want to remove lines from the above code that refer to portions of IDSSAPI that you don't plan on using as well as changing the "Form1.Show" if the main form in your program is not named "Form1". Now that this is done, using the functionality of IDSSAPI is very straightforward. For example, you can play a .WAV file from anywhere in your program by simply adding a single line of code such as:

IDSS_Core.PlaySound "\windows\alarm1.wav"

For the remainder of this article, we will examine a project I've put together to demonstrate how to use a variety of IDSSAPI's features. But first, I'd like to reiterate that the IDSS web site is an excellent source of sample code demonstrating many more features as well as how to achieve some of those things by accessing the WinCE API directly rather than using IDSSAPI.

Personally, one of my favorite features of IDSSAPI is the ability to hide specific portions of the PocketPC user interface (such as the SIP menu) and even make a form appear in full-screen mode. To make a form appear in full-screen mode, simply change the "Form1.Show" line in the above code to read "FullScreen Form1" and add the following function to the module:

Public Sub FullScreen(frm As Form)
frm.Show
IDSS_Win.HideMenu frm.hWnd
IDSS_Win.HideTaskbar frm.hWnd
IDSS_Win.HideStart frm.hWnd
IDSS_Win.MakeFullScreen frm.hWnd
End Sub

This displays the form and then uses the WindowHelper class in IDSSAPI to hide the various PocketPC GUI features and then resizes the form to take up the entire screen. Note that it is important to do things in that order to get the desired results. Next, let's expand our full-screen form to act like a splash-screen with a progress bar. You've probably noticed that eVB does not come with a ProgressBar control, but with the use of IDSSAPI, we can easily create something that gives the same effect. Simply add the PictureBox Control Component to your project and place a PictureBox control on your form. The following code demonstrates how to implement a ProgressBar:

Dim i As Integer
Dim xpos As Long
xpos = 0
For i = 0 To PictureBox1.Width Step PictureBox1.Width / 100
PictureBox1.DrawLine xpos, 0, xpos + i, PictureBox1.Height, vbRed, vbLineBoxFill
xpos = xpos + 1

IDSS_Core.Sleep 5

IDSS_Core.DoEvents
Next i

In an actual program, we would want the progress bar to increment as the program loads data or performs other "processor intensive" operations - but since this is merely a demonstration program with no such operations, we'll take advantage of IDSSAPI's Sleep function which pauses execution of the program for a given number of milliseconds to simulate doing something significant. The most important part of this is the call to IDSSAPI's DoEvents. DoEvents, among other things, tells the operating system to take a moment to update the user interface - without this call to DoEvents, the operating system would wait until the entire loop has been completed before updating the display, preventing the user from seeing the progress bar move.

For the rest of this sample, we will create a small dialog box which is controlled using the hardware buttons (the ones below the PocketPC screen marked with icons for calendar, contacts, etc.) that displays memory load and battery life statistics. We'll design it so that pressing the first hardware button causes memory load information to be displayed, the second displays battery life, and the third (just for kicks) causes the device to perform a soft reset. Since this dialog box is not showing very much information, we will not make it fill the screen.

Previous Page  Next Page