Intermec 6100 Reference Guide

Page of 328
SECTION 3
Supporting Windows Applications
3-12    PEN*KEY
R
 6100 Computer Programmer’s Reference Guide
plications to run if they have messages, which keeps your application WindowsĆ
friendly.  But if there are no pending message for anyone, PeekMessage()
immediately returns to its caller and does not allow the Windows kernel to beĆ
come idle.  The result is an application that calls PeekMessage() more or less conĆ
tinuously with short breaks while other applications process their messages.  In
other words, a cooperative busy loop" is the result.  The powerĆfriendly way to
implement a PeekMessage() loop is to implement the following:
Call PeekMessage()
if no messages, perform background processing
if there is no background processing to do, then
 
call GetMessage()
or
call WaitMessage()
"
NOTE:
Some Windows application libraries are not written with mobile computing in mind and may
make use of PeekMessage() busy-loops in their message handlers.
Holding Off Suspend Time-outs
If an application is busy with communication or processing, for extended periods
of time with no user interaction, the system might time out into suspend during
processing.  In order to prevent this, the application should fail SUSPENDREĆ
QUEST broadcasts while performing CPUĆbound tasks.  As mentioned above,
USERSUSPEND requests can also be failed, but the application should inform
the user about this type of action, otherwise the user may think that the system
is locked up (since the Suspend/Resume button does not work) and might reset
the system or take some other drastic measure.
APM Event Broadcasts
The APM BIOS specification defines event codes for various power management
events.  NORWINPM.DRV collects these events from the APM BIOS and either
handles them directly or broadcasts them to the system components (Windows
drivers, applications and DOS TSRs).  System components can use the events to
monitor system power state changes.  Some APM events have responses which
can implement cooperative power management.
Receiving APM Event Broadcasts
NORWINPM.DRV broadcasts APM events to Windows applications, system drivĆ
ers, installable drivers, VxDs, DOS drivers, and DOS TSRs loaded installed in
the System VM.  Each device has a different broadcast API.  The most common
APIs are documented below.
Windows Applications
Windows applications receive APM event broadcasts via the message procedures
of any topĆlevel windows that they own.  The message format is:
Msg:
WM_POWER (defined in WINDOWS.H)
wParam:
PWR_* event code defined in APMCODES.H or WINDOWS.H.
lParam:
Undefined
Returns:
Application should return PWR_FAIL (from WINDOWS.H) if it wishes to
reject an event. Otherwise, PWR_OK should be returned.
3. Windows
Applications