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
Sapphire Soltuions

Focus on Building the Console - Part 2 of 2

Written by Brent Pinkley  [author's bio]  [read 40297 times]
Edited by Derek

Download the code

Page 1  Page 2  Page 3  Page 4 

Completing the Picture

A critical piece to developing any application for the Pocket PC is understanding how to utilize the reduced screen size to good benefit. This mandates learning how to account for the Software Input Panel (SIP), and to come up with some creative ways of getting around its invasive use of real estate. The article "Use eVB to create a scrollable form on your Pocket PC" describes the basic process of using scrollbars with a frame to allow the screen to scroll up and down, as well as account for the presence of the SIP. With a few modifications to fit the requirements of the Console, it looks like this:

' ScrollBar size
Const gScrollMin = 2820 ' SIP visible
Const gScrollMax = 4020 ' SIP hidden

Private Sub SetupScrollBar()
' Is SIP visible?
If Console.SIPVisible Then
intSize = gScrollMin
Else
intSize = gScrollMax
End If

' Configure scroll bar
sbrMessage.Height = intSize
sbrMessage.Max = _
fraMessage.Height - intSize
' Keep bar from moving with frame
sbrMessage.Min = 0

' Set increments
sbrMessage.SmallChange = sbrMessage.Max / 100
sbrMessage.LargeChange = sbrMessage.Max / 10
End Sub

Private Sub Form_SIPChange(bSIPVisible As Boolean)
' Adjust ScrollBar size
SetupScrollBar
End Sub

Private Sub sbrMessage_Change()
' Move frame inversely to ScrollBar movement
fraMessage.Move 0, -sbrMessage.Value
sbrMessage.Move 3360, sbrMessage.Value
End Sub

These procedures size the scroll bar to the available screen height, with an allowance for the SIP. They also move the frame inversely in position to the movement of the scroll bar thumb. This allows the frame to have the appearance of scrolling.

It became apparent about mid-way through the project that there also needed to be some way to retrieve the identity of the Pocket PC in order to determine if a queue was local to the device or a remote queue. This required the extraction of the Pocket PC name from the registry. In order to do this, it was necessary to declare a few API functions and then use them to retrieve the value by key name:

' In Module
Public Const HKEY_LOCAL_MACHINE = &H80000002

' Registry API Declarations
Public Declare Function RegOpenKeyEx Lib _
"Coredll" Alias "RegOpenKeyExW" _
(ByVal hKey As Long, _
ByVal lpSupKey As String, _
ByVal upOptions As Long, _
ByVal samDesired As Long, _
phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib _
"Coredll" Alias "RegQueryValueExW" _
(ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal lpReserved As Long, _
lpType As Long, ByVal lpData As String, _
lpcbData As Long) As Long
Public Declare Function RegCloseKey Lib _
"Coredll" (ByVal hKey As Long) As Long

' In Form
Public strIdentName As String

Private Sub Form_Load ()
lngSize = 256
strIdentName = String(lngSize, 0)

' Get handle for the "Ident" key
lngResult =
RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
"\Ident", 0, 0, hlngSubKey)

' Read "Name" value from key
lngResult = RegQueryValueEx(hlngSubKey, _
"Name", 0, lngType, strIdentName, _
lngSize)

' Release handle to key
lngResult = RegCloseKey(hlngSubKey)
End Sub

You could add the RegCreateKeyEx and RegSetValueExString API functions included in the source code to create and update application settings that you later retrieve to maintain user preferences or state. This would allow you to maintain personalization, such as whether a user prefers gridlines, or likes the columns displayed in a certain order. The more your application strives to "know" the person who is using it, the better the response will be to using the application on a frequent basis. For more information of how to easily incorporate registry functionality in your projects, you might want to check out "Retrieve the Pocket PC Owner Information Using eVB".

Crossing the Finish Line

Take some time to look through the source code for the Console application, and you will see a lot of the plumbing that you often miss on a single frame project that has multiple buttons to demonstrate different techniques. My hope is that by creating a full application, it will be easier to see how many different techniques can be brought to work together.

I would challenge you to expand upon the framework set out in the application and add your touches to it. You could even alter its focus entirely and create a File Manager type application with the same tree view and list view structure that you find on the main frame of the Console.

If you are looking for ideas, one addition would be to develop an eVC component to provide subclassing for the list view control, and/or the tree view, so that real tap and hold menus would be an option. There are already a couple of commercial controls out there that allow your applications to handle windows' messages, if you don't want to "roll your own".

As a final suggestion, you could utilize the registry, as mentioned earlier, to improve the user's experience by maintaining information on preferences. You could automatically save the user the effort of setting up the application the way they like it every time. Likewise, you could set the default queue to the location the last message was sent to. This works really well for remote queues, since they involve a decent amount of typing. If you are like me, using the stylus to "type" in the SIP is not really one of the greater joys in life. Minimize their effort and maximize their efficiency.

I have learned a great deal from the articles on this site as well as the messages posted in the forums, so I am happy to have the chance to give a little back. I welcome your thoughts and suggestions. I also look forward to hearing about any improvements you make!

Previous Page