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 

But this means we will need to decide where to put it on the screen. With IDSSAPI, we can easily use the registry to save where the windows was located the last time it was displayed and use that position to place the window the next time it is displayed. Doing this is simply a matter of adding the following calls to IDSSAPI:

Private Sub Form_Load()
'place this form on the screen based on the position saved in the registry
Me.Top = IDSS_Reg.GetSetting(irkHKEY_CURRENT_USER, "IDSSAPI_Demo", "Top", 0)
Me.Left = IDSS_Reg.GetSetting(irkHKEY_CURRENT_USER, "IDSSAPI_Demo", "Left", 0)
End Sub

Private Sub Form_OKClick()
IDSS_Reg.SaveSetting irkHKEY_CURRENT_USER, "IDSSAPI_Demo", "Top", CLng(Me.Top)
IDSS_Reg.SaveSetting irkHKEY_CURRENT_USER, "IDSSAPI_Demo", "Left", CLng(Me.Left)
App.End
End Sub

With the IDSSAPI registry functions, the only thing you have to worry about is passing the right parameters. In both GetSetting and SaveSetting, the first three parameters specify what value in the registry we are dealing with (note that IDSSAPI provides much more flexibility than even VB6 in this aspect). The only difference between the two functions is the fourth parameter. In SaveSetting, the fourth parameter specifies the value to be saved. On the other hand, GetSetting uses the fourth parameter to specify a default value that it will return if the key does not exist. In the sample code above, we use a default value of 0 for both settings, therefore the first time the program is run, the Window will be shown in the very top-left of the screen.

Handling hardware button presses is also extremely easy with the help of IDSSAPI. The following lines tell the operating system to notify your form when a specific button is pressed:

IDSS_Win.SetAppKeyWindowAssociation iakAPP1, Me.hWnd
IDSS_Win.SetAppKeyWindowAssociation iakAPP2, Me.hWnd
IDSS_Win.SetAppKeyWindowAssociation iakAPP3, Me.hWnd
IDSS_Win.SetAppKeyWindowAssociation iakAPP4, Me.hWnd

After you've done this, the operating system will call your form's Form_KeyPress method whenever a hardware button is pressed - even if another program has the focus. To handle this function call, you can use a Select…Case statement like:

Select Case KeyAscii
'first hardware button pushed
Case IDSSAPI.iakAPP1

'second hardware button pushed
Case IDSSAPI.iakAPP2

'third hardware button pushed
Case IDSSAPI.iakAPP3

'fourth hardware button pushed
Case IDSSAPI.iakAPP4

End Select

Finally, we can use a simple Timer control to periodically update the statistics gathered by IDSSAPI.

'update the memory statistics
CurMem = IDSS_Mem.MemoryLoad
If CurMem > MaxMem Then
MaxMem = CurMem
ElseIf CurMem < MinMem Then
MinMem = CurMem
End If

'update the power statistics
CurPwr = IDSS_Pwr.BatteryLifePercent
If CurPwr > MaxPwr Then
MaxPwr = CurPwr
ElseIf CurPwr < MinPwr Then
MinPwr = CurPwr
End If

In conclusion, IDSSAPI is a great tool that gives eVB users easy access to complex features. While IDSS is actively improving the product and creating more examples, there are a few minor drawbacks. However, the small price is well worth the hours of debugging and research it is likely to save you.

Previous Page