Palm Buttons
The Palm’s buttons can also be captured and used to trigger debugging statements or functions. You might use this technique to asynchronously trace a program’s state information at various points in its execution. The most common Palm buttons are shown in Figure 10-2.
Figure 10-2. Common Palm buttons
The AppForge system library contains two functions that allow your program to register and release the keycode associated with a button.
-
RegisterKeyCode
Registers a keycode for a corresponding button
-
ReleaseKeyCode
Releases the keycode for a corresponding button
In addition to registering a keycode, you must set the active
form’s KeyPreview
property to
True
. Registered keys are then received as a
Form_KeyDown
event within your program. Example 10-3 shows how this works in code.
Example 10-3. Key registration and release
Public Const vchrHard1 = &H204 ' Leftmost hard key Public Const vchrHard2 = &H205 ' Center-left hard key Public Const vchrHard3 = &H206 ' Center-right hard key Public Const vchrHard4 = &H207 ' Rightmost hard key Private Sub Form_Load( ) #If AFDEBUG Then RegisterKeyCode vchrHard1 RegisterKeyCode vchrHard2 RegisterKeyCode vchrHard3 RegisterKeyCode vchrHard4 #End If End Sub Private Sub Form_Unload(Cancel As Integer) #If AFDEBUG Then ReleaseKeyCode vchrHard1 ReleaseKeyCode vchrHard2 ReleaseKeyCode vchrHard3 ReleaseKeyCode vchrHard4 #End If End Sub
We start ...
Get Programming Visual Basic for the Palm OS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.