Page 1
Page 2
Page 3
This small program demonstrates using various API,
(Application programming Interface), functions necessary to create a magnification
lens for a windows based PDA. It proved to be quite interesting since some
of the most common API calls were either not available or could not be used
on a PDA. It was written as an experiment rather than for a commercial application.
The program demonstrates the following:
- Using two forms. One is for the lens form and the
other for the options.
- Setting the properties of one form from another.
- Showing and hiding of the forms.
- Determining the screen metrics of the device using
GetDeviceCap and GetDC API.
- Basic form centering and acontrol scaling example.
- Creating a VB GetDesktopWindow function work around
from code using several API calls.
- Using the StretchBlt API to magnify an area on
the desktop.
- Using the SetWindowsPos API to keep the lens always
on top.
- Using the hardware cursor, scroll and enter buttons.
- Using a stylus drag to move the viewable area.
- Displaying of the hourglass. Please note that
this code is present but not executed.
API declarations used
GetWindow
GetParent
GetWindowText
GetWindowTextLength
For the cursor hourglass event:
LoadCursor and SetCursor
For keeping the form Topmost:
SetWindowPos
For determining the device screen size:
GetDeviceCaps
To copy the desktop area to the form and magnify it:
StretchBlt
GetDC
ReleaseDC
Two views of the Main form

Default Magnification

Increased Magnification
The two forms, the main form or lens area and an options
form could have easily been coded with just one form and a menu so lets
get started with the main form.
Start a new project and create a standard form named
FrmMain. The height and width of the main form will be calculated run
time, so just as a reference, use a width of 240 and a height of 80. Also,
change the Scalemode to 3 - Pixel.
The only controls you will need on the main form will
be a red reference line at the bottom and timer. I elected to put a reference
line on the form because it was difficult at times to see the separation
between the lens and the background. Being a scalable form, the load event
will handle the width and positioning of the reference line.
A timer control is used to align the form whenever
it is moved. The code within the timer event will save the forms coordinates
and if they change, the form will then shift so that it remains within
the screen. The timer interval of 250 seems to work quite well.
That's all the forms designing that will be needed
for the main form. The options form is described later.
Opening the code window establish the API declarations
and constants that will be needed. (see source) Use the API text viewer,
which comes with the embedded tools to copy the code into your program.
Next Page