` Unparalleled Instruction
`
`Development Skills to
`Work on Windows CE
`
`and Advice from the
`
`Acclaimed “Dr. CE”
`
`Put Your Windows
`
`o Featured on the CD:
`
`Wo—h-w—mn.-.—-.....—-—-—--II—v.
`
`
`
`"“WIJW'
`
`"an
`
`“Iv-I-
`,_...,.-,-,—nr,.
`
`' Sample Code
`- Free ActiveX Control for CE
`
`' Evaluation Software
`
`' Links to Important CE
`Web Sites
`
`' Electronic Reference to the
`
`CE API and the C Runtime
`
`Library Functions
`
`3: Exhibit 1031
`
`Starbucks Corp. Exhibit 1031
`
`
`
`w owsc
`
`Developer's Handbook
`
`Here's the book that helps every Windows
`programmer become a Windows CE pro!
`
`The Windows CE Developer's Handbook is for experienced Windows developers who
`
`are ready to apply their skills to the rapidly expanding world of Windows CE. Inside, a
`
`CE expert offers an unflinching look at the realities of CE programming, including con(cid:173)
`
`straints on memory and processing power, a proliferation of device-specific capabilities,
`
`and a reduced API and runtime library. Can you meet these challenges' This book
`
`ensures that you can, providing in-depth coverage of the toughest tasks you'll face:
`
`• Porting existing C/MFCIVB applications
`to Windows CE
`
`• Creating CE installation and help files
`
`• Using CE databases with C and MFC
`
`• Working around CE devices' varying
`
`input and display capabilities
`
`• Getting desktop applications to talk to
`
`CE devices
`
`• Equipping your CE applications with
`
`support for key communications
`technologies: serial 1/0, PCMCIA,
`
`infrared, and Win sock
`
`• Building custom RAPI applications
`
`• Taking complete advantage of each
`hardware platform's features
`
`• Getting your application " logo-approved"
`
`• Recreating file access functions missing
`
`from stdio.h
`
`• Mastering the latest CE API calls
`
`• Optimizing your code for the low(cid:173)
`
`resource environment of CE
`
`Featured on the CD: The enclosed CD contains all the sample code
`referred to in the book, a free ActiveX control for Windows CE, and evaluation
`
`software. including CE development utilities. You 'll also find links to CE vendors. useful
`
`CE development Web sites, and PDF versions of the full documentation of CE's API
`and C runtime library functions.
`
`ABOUT THE AUTHOR
`
`Terence "Dr. CE" Goggin, a recognized Windows CE expert, is the author of numerous
`
`books and articles on Windows programming and the Internet. He is currently a consultant
`
`working on cutting-edge Windows CE solutions.
`
`USER LEVEL
`
`INTERMEDIATE/ ADVANCED
`
`BOOK TYPE
`
`HOW-TO/ REFERENCE
`
`Sr13E)(®
`
`CATEGORY
`
`PROGRAMMING
`
`c
`-o
`n
`
`m
`> z
`
`U.S. $49.99
`
`ISBN 0-7821 - 2414-3
`90000
`
`0 2521122414
`
`4
`
`9 780782 124149
`
`Starbucks Corp. Exhibit 1031
`
`
`
`-
`
`Windows® ({ Developer's Uandbook™
`
`Terence A. Goggin
`with
`David L. Heskett and
`Jason M. Maclean
`
`..6IfT w
`
`SYBEX
`
`San Francisco • Paris • Dusseldorf • Soest • London
`
`Starbucks Corp. Exhibit 1031
`
`
`
`Associate Publisher: Gary Masters
`Contracts and Licensing Manager: Kristine O'Callaghan
`Acquisitions & Developmental Editor: Brenda Frink
`Editor: Sally Engelfried
`Project Editor: Bronwyn Shone Erickson
`Technical Editor: John Psuik
`Book Designer: Kris Warrenburg
`Graphic Illustrator: Tony Jonick
`Electronic Publishing Specialist: Robin Kibby
`Proofreader: Judy Weiss
`Project Team Leader: Shannon Murphy
`Indexer: Meg Fortune McDonnell
`Companion CD: Ginger Warner
`Cover Designer: Design Site
`Cover Photographer: The hnage Bank
`
`Developer's Handbook is a trademark of SYBEX Inc.
`
`The HP Jomada is a trademark or registered trademark of
`Hewlett-Packard Company, copyright ©1999.
`
`The Casio E-11 is a trademark or registered trademark of Casio,
`Incorporated, copyright ©1999.
`
`The Casio PA-2400 and Casio PA-2500 are trademarks or regis(cid:173)
`tered trademarks of Casio Business Solutions Group, copyright
`©1999.
`
`TRADEMARKS: SYBEX has attempted throughout this book to
`distinguish proprietary trademarks from descriptive terms by fol(cid:173)
`lowing the capitalization style used by the manufacturer.
`
`The author and publisher have made their best efforts to prepare
`this book, and the content is based upon final release software
`whenever possible. Portions of the manuscript may be based
`upon pre-release versions supplied by software manufacturer(s).
`The author and the publisher make no representation or war(cid:173)
`ranties of any kind with regard to the completeness or accuracy
`of the contents herein and accept no liability of any kind includ(cid:173)
`ing but not limited to performance, merchantability, fitness for
`any particular purpose, or any losses or damages of any kind
`caused or alleged to be caused directly or indirectly from this book.
`
`Copyright ©1999 SYBEX Inc., 1151 Marina Village Parkway,
`Alameda, CA 94501. World rights reserved. No part of this publi(cid:173)
`cation may be stored in a retrieval system, transmitted, or repro(cid:173)
`duced in any way, including but not limited to photocopy,
`photograph, magnetic or other record, without the prior agree(cid:173)
`ment and written permission of the publisher.
`
`Library of Congress Card Number: 99-61299
`ISBN: 0-7821-2414-3
`
`Manufactured in the United States of America
`10 9 8 7 6 5 4 3 2 1
`
`Starbucks Corp. Exhibit 1031
`
`
`
`12
`
`Chapter 1 • What Does CE Do for Me?
`
`CE Devices
`
`There are currently four distinct types of CE devices, each with its own purpose:
`
`•
`
`Palm-size PC devices
`
`• Handheld PC devices
`
`• Handheld PC/Pro devices
`
`• Devices that don't fall into the above categories
`
`Palm-Size PC Devices
`Palm-size PCs (or PPCs) are usually the smallest of the Windows CE devices,
`with approximately the same dimensions as a package of 3 x 5-inch index cards.
`They have a long, narrow, portrait-oriented display; no true keyboard; a touch
`screen; and integrated voice recording features. In addition, all PPC devices have
`a Compact Flash slot, which can be used to add additional memory or peripheral
`devices to the PPC.
`
`The shape and portability of PPC devices make them ideal for applications that
`allow the user instant, "on the road" access to some specific kind of data, with a
`minimum of data entry. Figure 1.1 shows an example of a Palm-size PC device,
`the Casio E-11.
`
`There are several features that make PPCs different from other CE devices:
`
`• Display
`
`• Lack of a true keyboard
`
`• The Ink control
`
`• The Cap Edit control
`
`• Voice recording and playback services
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`13
`
`FIGURE 1.1:
`
`The Casio E-11
`
`~t.CE
`
`ftlwsday' January 15, 1998
`
`8110 AM Plarnng Meeting
`10:00 AM Start Meemg
`llllCh with Bctl
`12:00 PM
`1:00PM Con1aren:e call with Cra-dell
`3:00 PM crandell project review
`15:30 PM WCI'kout at O..tl
`
`t sero Mom's brthday gift
`! Slimlt 8lQ")8I1Se reports
`Prepcwe ootli'le
`~ Pk:k ~ package
`
`Copyright Casio © 1999
`
`Display
`
`The first thing that makes the display on a PPC so unique is that it is portrait(cid:173)
`oriented, as illustrated in Figure 1.2. As you probably realize, this is a sharp con(cid:173)
`trast to the Desktop world, where everything is more landscape-oriented than
`anything else.
`
`In addition to its unusual orientation, the display on a PPC is very small, typi(cid:173)
`cally around 240 x 320 pixels. This, too, contrasts to the Desktop world where we
`can expect at least 640 x 480. Obviously, this means that a lot more thought must
`go into the design of dialogs and windows to get them to look decent in such a
`tight space.
`
`The final element of the display that makes it unusual when compared with
`our Desktop programming is that it is only a four-color grayscale LCD. In the
`Desktop world, we can count on 16 colors at the bare minimum.
`
`Starbucks Corp. Exhibit 1031
`
`
`
`14
`
`Chapter 1 • What Does CE Do for Me?
`
`FIGURE 1.2:
`
`Portrait vs. landscape
`orientation
`
`NOTE
`
`As this book was going to press, HP announced a color PPC device.
`
`Together, these elements mean that you're going to have to pay much more
`attention to your visual design. In many cases, you will end up having to reduce
`the width of any control on your windows or dialogs simply because you've got
`to fit everything into such a small space. Figures 1.3 and 1.4 show sample dialogs
`designed for Windows 98/NT and a Palm-size PC, respectively.
`
`FIGURE 1.3:
`
`A dialog designed for
`Windows 98/NT
`
`Drahng Properloes
`
`My Locatlons I
`
`11 ~ I
`-=
`::::J ~ ~emove I
`~=:~0< ~---·-;_]
`I Un1ted States of Amenca
`:i:J
`
`lom!liainglrom: jiiAftlli!illlfilt
`
`1 am 1'1
`---KK--
`How I rial from !lis loc«<on
`
`To occess on j!Uiside line. liot riot j
`for loco!. jtor long distance.
`CJlar>ge I
`r Diai~CalngCard: !lu1efPrw•r,.·•
`r Thro locotionhoscall~ Toditable~.riel: r---3
`The phooe syolom at this loc<llion ...... r. lone diolng r fUse dialing
`
`OK
`
`Concel
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`15
`
`FIGURE 1.4:
`
`A dialog designed for a PPC
`device
`
`per ttes
`
`[::::113
`
`Location:
`
`!Home
`
`[ N-;;;;J I Remove I
`
`local settings
`Area code: [818 @Tone dialing
`Country code:[_ __ 0 Pulse dialing
`0 Disable call waiting; cl•; I
`[3
`Dialing patterns - - - - - (cid:173)
`Local/ Long Distance 1 International:
`G
`lFG
`Oll,EFG
`
`Edit ...
`
`As you can see, making this dialog work on a PPC involved stacking the vari(cid:173)
`ous controls a little more closely and making each control just a little bit narrower.
`If we wanted to, we could also have used a tabsheet control to help break up the
`various controls into two distinct sections.
`
`Lack of a True Keyboard
`
`Palm-size PCs do not have a physical keyboard. Instead, they have a "virtual key(cid:173)
`board," a pop-up panel, called the System Input Panel, that displays letters and
`numbers in a QWERTY arrangement. The user taps out the keys on this panel
`with the stylus. The System Input Panel can be raised and lowered as needed, as
`shown in Figures 1.5 and 1.6, respectively.
`
`As you can imagine, this can create havoc for your program. When the Input
`Panel is raised, it occupies roughly one-third of the display area. To accommodate
`it and to give your program some control over how it interacts with the Input
`Panel, there are two modifications you need to make to any PPC application:
`
`• Programmatically raise and lower the Input Panel
`
`• Detect when the user pops up the Input Panel
`
`Starbucks Corp. Exhibit 1031
`
`
`
`16
`
`Chapter 1 • What Does CE Do for Me?
`
`FIGURE 1.5:
`
`The Input Panel raised
`
`FIGURE 1.6:
`
`The Input Panel lowered
`
`Programmatically Raise and Lower the Input Panel You need to be able
`to raise and lower the Input Panel programmatically because not all of your pro(cid:173)
`grams will use the Input Panel in the same way, or to the same extent. For example,
`if you designed a blackjack game forCE, you would probably want to hide the
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`17
`
`Input Panel when the game started because the user probably won't need the
`keyboard in a blackjack game.
`
`Similarly, if you designed some kind of data entry application, it would make
`your program friendlier if you showed the keyboard when the program started.
`For these reasons, you need to be able to control the Input Panel's state. In Chap(cid:173)
`ter 15, we'll explore exactly how to do this.
`
`Microsoft already provides code to lower the Input Panel, so you only have to
`write the code to raise the Input Panel. The original lowering code, as provided
`by Microsoft, looks like this:
`
`BOOL LowerSip( void )
`{
`
`BOOL fRes = FALSE;
`SIPINFO si;
`memset( &si, 0, sizeof( si ) );
`si.cbSize = sizeof( si );
`if( SHSiplnfo( SPI_GETSIPINFO, 0, &si, 0))
`{
`
`si.fdwFlags &= - srPF_ON;
`fRes = SHSiplnfo( SPI_SETSIPINFO, 0, &si, 0 );
`
`return fRes;
`
`What's happening here is that you're first filling a structure (si) of type SIPINFO.
`For our purposes here, though, you're only interested in one member of the struc(cid:173)
`ture, fdwFl ags, which you'll use to set the state of the panel. There are three pos(cid:173)
`sible values for the fdwFl ags member:
`
`•
`
`•
`
`•
`
`NOTE
`
`SIPF _ON The panel is visible.
`
`SIPF _DOCKED The panel is attached to the Taskbar.
`
`SIPF _LOCKE The panel is locked in place, and its state cannot be changed
`by the user.
`
`These values can then be combined by using the AND (&&)and OR ( 1 1) operators.
`Although the second two fdwFl ags values are not of interest to us here, they do
`have meaning for other programs. For instance, with regard to the second value
`SIPF _DOCKED, some Input Panels allow themselves to be detached from the tool(cid:173)
`bar and dragged around the screen much like a dockable toolbar.
`
`Starbucks Corp. Exhibit 1031
`
`
`
`18
`
`Chapter 1 • What Does CE Do for Me?
`
`To lower the panel, all you have to do is remove the SIPF _ON value from the
`fdwFl ags member. Do this by using AND on the current value of fdwFl ags with
`the logically negated SIPF _ON code. Then, write your si structure back to the
`Input Panel, and it lowers itself. Return the result of your work, and you're done.
`The following code is an example of this procedure:
`
`si .fdwFlags &= - srPF_ON;
`
`Then, write your si structure back to the Input Panel, which then lowers itself:
`
`fRes = SHSiplnfo( SPI_SETSIPINFO, 0, &si, 0 );
`
`Return the result of your work, and you're done:
`
`return fRes;
`
`Using this piece of code as a model, you can see that to get a routine that raises
`the Input Panel, all you need to change is the line that sets the value of fdwFl ags.
`In other words, instead of removing the SIPF _ON flag, use OR on fdwFl ags, as in
`the following:
`
`si .fdwFlags i= SIPF_ON;
`
`Or, when put into the full routine:
`
`BOOL RaiseSip( void )
`{
`
`BOOL fRes = FALSE;
`SIPINFO si ;
`memset( &si, 0, sizeof( si ) );
`si .cbSize = sizeof( si );
`if( SHSiplnfo( SPI_GETSIPINFO, 0, &si, 0 ) )
`{
`
`i= SIPF_ON;
`si .fdwFlags
`fRes = SHSiplnfo( SPI_SETSIPINFO, 0, &si, 0 );
`
`return fRes;
`
`But raising and lowering the Input Panel is only one of the two requirements
`you need to take care of to manage the Input Panel's interaction with your pro(cid:173)
`grams. The second requirement is much more involved.
`
`Detecting When the User Pops Up the Input Panel You've got to be able
`to detect when the user pops up the Input Panel because the Input Panel occupies
`so much of the screen area when it's visible. Your application will be much more
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`19
`
`user-friendly if it resizes itself and allows the user to scroll the window whenever
`the Input Panel is shown.
`
`You can observe this behavior in the Owner control panel applet. With the
`Input Panel lowered, all of the controls are visible and the window does not have
`a scroll bar, as shown in Figure 1.7. When you show or raise the Input Panel, the
`Owner window actually resizes itself and adds a scrollbar on its right side, as
`shown in Figure 1.8. The user can then scroll to that portion of the window that
`would otherwise be obscured by the Input Panel.
`
`FIGURE 1.7:
`
`The Owner applet with the
`Input Panel lowered
`
`FIGURE 1.8:
`
`The Owner applet with the
`Input Panel raised
`
`lrerence Goggin
`Company:
`INuts_hell Software
`Address:
`terenceg~nutshellsottware.com
`
`Work phone: II
`
`Home phone:
`
`At power-on - - - - - (cid:173)
`~ Display owner identification
`
`tll:J £I
`
`Owner Prupertres
`IdentrfrcatiDn JNotesl
`Name:
`lrerence Goggin
`Company:
`INutshe II Sottw are
`
`Starbucks Corp. Exhibit 1031
`
`
`
`20
`
`Chapter 1 • What Does CE Do for Me?
`
`As you can probably guess, CE provides a way to detect the state change in the
`Input Panel, and Microsoft even provides a sample of how to do this. However,
`their sample is incomplete in that it doesn't show how to add the scroll bar to the
`application based on the state of the Input Panel. To get your application working
`as smoothly as possible, you'll need to take their sample and make it complete.
`
`This can get a bit confusing, so let's start by looking at some simplistic pseudo(cid:173)
`code for the logic at work here:
`
`If we're showing our scroll bar
`and If the input panel is not visible
`Then let's hide our scroll bar.
`Otherwise (we're not showing our scroll bar)
`and If the input panel is visible
`Then let's show our scroll bar.
`
`WARNING
`
`This logic assumes that your application doesn't normally need a scroll bar and
`that it only displays one when the user pops up the Input Panel.
`
`Start by adding a handler for the Windows CE message that tells you one of the
`system settings has changed. When the Input Panel's state changes, CE will send
`you a WM_SETIINGCHANGE message with the wParam value set to SPI_SETSIPINFO:
`
`case WM_SETTINGCHANGE:
`switch( wParam )
`{
`
`case SPI_SETSIPINFO:
`
`Then, just as you did when you wanted to show or hide the Input Panel, fill
`your si variable (of type SIPINFO) with information about the Input Panel:
`
`memset( &si, 0, sizeof( si ) );
`si.cbSize = sizeof( si );
`if( SHSipinfo( SPI_GETSIPINFO, 0, &si, 0))
`{
`
`Your next task is to check whether or not your application already has a scroll bar
`visible. Do this by retrieving the current window style by calling GetWi ndowlong()
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`21
`
`and passing GWL_STYLE as the second parameter. GetWi ndowlong() returns a Long
`integer; store it into a variable called lWndStyl e:
`
`lWndStyle = GetWindowlong(hWnd, GWL_STYLE);
`
`Then check to see if you're already displaying a scroll bar by comparing lWnd(cid:173)
`Styl e against WS_VSCROLL style:
`if (lWndStyle & WS_VSCROLL)
`{
`
`If you are already showing a scroll bar, then you've got to decide whether or
`not to hide it based on whether or not the Input Panel is hidden. You must then
`check the fdwFl ags value of your si (SIPINFO) variable to see if the Input Panel
`is still visible:
`
`if (!(si.fdwFlags & SIPF_ON))
`{
`
`If the Input Panel is hidden, use AND on lWndStyl e and the logical negation of
`WS_VSCROLL together in order to remove the WS_VSCROLL style and, therefore, the
`scroll bar itself:
`
`lWndStyle &= - ws_VSCROLL;
`
`Finally, make your changes take hold by calling SetWi ndowlong(), passing in
`the newly modified style:
`
`SetWindowlong(hWnd, GWL_STYLE,
`
`lWnd-
`
`Style);
`
`If, however, you're not showing your scroll bar and the Input Panel is visible,
`show your scroll bar by using OR on the WS_VSCROLL style with your lWndStyl e:
`
`else
`
`if (si.fdwFlags & SIPF_ON)
`
`lWndStyle 1= WS_VSCROLL;
`
`Starbucks Corp. Exhibit 1031
`
`
`
`22
`
`Chapter 1 • What Does CE Do for Me?
`
`Then-just as you did above-make your window take on the new style by
`calling SetWi ndowlong(), passing in the new lWndStyl e:
`
`SetWindowlong(hWnd, GWL_STYLE,
`
`lWnd-
`
`Style);
`
`Next-and this is the core piece from the Microsoft sample code-resize your
`window to whatever the visible screen area is. The SIPINFO structure, which has
`as one of its members a RECT representing the visible desktop area, allows you to
`do this. In code, the entire operation can be done in one call to MoveWi ndow():
`
`MoveWindow(
`hWnd,
`si .rcVisibleDesktop.left,
`si.rcVisibleDesktop.top,
`si.rcVisibleDesktop.right -
`
`si .rcVisibleDesktop.left,
`
`si .rcVisibleDesktop.bottom(cid:173)
`si .rcVisibleDesktop.top,
`TRUE ) ;
`
`break;
`
`Finally, to ensure that your application can detect the state of the Input Panel
`when it starts, you must manually send your program a WM_SETIINGCHANGE mes(cid:173)
`sage in the WM_CREATE message handler:
`
`SendMessage(hWnd, WM_SETTINGCHANGE, SPI_SETSIPINFO, 0);
`
`You're finished. Now your applications will behave correctly and interact as
`efficiently as possible with the Input Panel.
`
`NOTE
`
`You ' ll also need a message handler for the WM_VSCROLL message to handle any
`requests that the user might make while the scroll bar is visible. This code is
`included on the CD in the samples for this chapter.
`
`The Ink Control
`
`Because most of the input to the system is done via a touch screen, it seems only
`natural that the PPCs have a control that accepts handwriting input. It's called the
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`23
`
`Ink control, and it will record any mixture of handwritten and typewritten data.
`This control is especially useful in applications where a signature is needed.
`
`WARNING
`
`The Ink control does not do any handwriting recognition; any handwritten data
`that it stores is stored as graphical, rather than textual, data.
`
`Working with the Ink control is a bit trickier than you might imagine. In fact,
`there are three steps required just to create an individual Ink control within your
`own application.
`
`1.
`
`Initialize the common control library:
`
`InitCommonControls();
`
`2. Specifically initialize the Ink (or InkX as it is alternately called) control:
`
`Ini tlnkX();
`
`3. Call CreateWi ndow(), specifying WC_INKX as the window class:
`
`hlnk = CreateWindow(WC_INKX, TEXT(""),
`WS_VISIBLE I WS_CHILD I WS_BORDER,
`5, 90, 200, 160, hWnd,
`NULL, hlnst, NULL);
`
`WARNING
`
`Note that WC_INKX is not an l pCl ass Name string, but rather a defined constant to
`be passed in place of the l pCl ass Name string.
`
`The CapEdit Control
`
`To allow for easier data entry, Microsoft added a special kind of edit control called
`the CapEdit control. The CapEdit control looks and behaves like a standard Edit
`control, with one exception: the first letter typed in the control is automatically
`capitalized. This allows users to enter data much faster because they do not have
`to press the Shift key before entering the first letter.
`
`There are a number of situations where this is important, such as when a user
`enters an address where, typically, the first letter of every piece of data is capital(cid:173)
`ized. If the user doesn't have to worry about capitalization, it's easier to enter
`addresses.
`
`Starbucks Corp. Exhibit 1031
`
`
`
`24
`
`Chapter 1 • What Does CE Do for Me?
`
`Using the CapEdit control is very easy-all you have to do is call SHini tExtra(cid:173)
`Control s() to initialize the control, then call CreateWi ndow(), specifying
`"CAPEDIT" instead of" EDIT" as the class name, as in this example:
`
`#include <aygshell.h> //for SHinitExtraControls
`
`II ...
`
`SHinitExtraControls();
`hEdit = CreateWindow(TEXT("CAPEDIT"), TEXT('"'),
`WS_VISIBLE I WS_BORDER WS_CHILD,
`5, 5, 150, 21, hWnd,
`NULL, hlnst, NULL);
`
`Voice Recording and Playback Services
`
`Although all of the CE devices offer some kind of voice recording software, the
`PPC platform is the only CE platform that exposes this functionality to develop(cid:173)
`ers in the form of a control. The "control" in this case is a dialog box that can be
`launched from within a program. The dialog will then send notification messages
`to the calling program, indicating the user's actions.
`
`The PPC Taskbar
`Although the PPC does follow the Windows 98/NT user interface very closely, there is one
`subtle difference that can take some getting used to. PPC devices have a Taskbar, but run(cid:173)
`ning applications don't show up there as they do under desktop versions of Windows. The
`reason for this is that the Taskbar is already so narrow because of the form factor of the
`device itself that there isn't enough room to maintain a button for each application that
`the user starts.
`Instead, it's Microsoft's intent that a PPC program shouldn't really be closed or exited in
`the normal fashion . As you can see in any of the Microsoft Pocket Outlook applications,
`it's preferred that a program not have a File> Exit menu, or a system close (X) button.
`
`Instead, as we'll be exploring very shortly, applications are supposed to stay running indef(cid:173)
`initely, hidden in the background. It is the responsibility of the developer to ensure that
`the user cannot start two copies of the same program. When the user tries to start a pro(cid:173)
`gram, the program should first check if there's already a copy of itself running. If it finds
`another copy, it should bring that to the front rather than opening a new copy of itself.
`Likewise, when the system is running low on memory, it will ask the running programs to
`close down.
`
`Continued on next page
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`25
`
`Of course, it's worth pointmg out that many developers have ignored the PPC style of pro(cid:173)
`gram management and have exposed all of the standard means of closing an application .
`That's probably because they believe that users are more comfortable with a program that
`can be closed . The examples in this book generally include at least the system close (X)
`button, as this seems more comfortable to use while debugging and testing.
`
`Handheld PC Devices
`Handheld PCs (or HPCs) are usually the midrange models, being moderately
`larger than the PPCs (about 4 x 71/2 x 1 inches), yet possessing less-than-full-size
`keyboards. Designing programs for HPCs has a more familiar feel to it since the
`displays are landscape-oriented and applications are represented on the Taskbar
`when running. In addition, most HPC devices have both a Compact Flash slot
`and a PCMCIA (Type II) slot, either of which can be used to add additional mem(cid:173)
`ory or peripheral devices to the HPC. However, like the PPCs, HPC devices have
`a touch screen instead of a mouse.
`
`The shape and portability of HPC devices make them ideal for pocket or mini
`versions of some Desktop applications, with reduced sets of features and not as
`much data entry as, say, a Desktop application might require. Figure 1.9 shows an
`example of a Handheld PC device, the Casio PA-2500.
`
`There are several noteworthy features that make HPCs different from other CE
`devices:
`
`• Display
`
`• A true keyboard
`
`• The HTML Viewer control
`
`Starbucks Corp. Exhibit 1031
`
`
`
`26
`
`Chapter 1 • What Does CE Do for Me?
`
`FIGURE 1.9:
`
`The Casio PA-2500
`
`~ it
`
`(~ C.Y.IM'b
`
`>cu.
`
`~Jw.dce
`
`Copyright Casio Business Solutions Group © 1999
`
`Display
`
`The first thing that makes the display on an HPC different from other CE devices
`is that it is landscape-oriented, just like Desktop machines. In addition, the dis(cid:173)
`plays on HPCs typically measure about 640 x 240. That's twice as large as the
`screens on the PPC devices. Of course, that's still quite small when compared to
`resolutions available on Desktop machines, but this increase in size does help(cid:173)
`especially when you're designing an application that displays lots of information
`and you really need the extra room.
`
`The final characteristic of HPC displays that makes them unique is that there
`are some color HPCs. However, not all HPCs have color displays, so it's still a
`good idea to play it safe and not make any assumptions about your user's ability
`to see colors.
`
`A True Keyboard
`Handheld PCs have an actual physical keyboard. From a development stand(cid:173)
`point, this means that you can design the HPC version of your program to require
`some data entry. Of course, because the keyboard is not really a full-size key(cid:173)
`board, you won't want to insist on intensive data entry.
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`27
`
`The HTML Viewer Control
`
`Because HPCs have a larger display and are therefore better for viewing data,
`they have a special control called the HTML Viewer control. As you can guess,
`it's a control that you can use in your own programs to display HTML pages.
`The tricky part about this control is that it notifies your application of any HTML(cid:173)
`based event. For example, when an HTML page contains a request for an image,
`the HTML Viewer control notifies your application, passing in the URL of the
`image, so that you can then download and display the image. Similarly, when a
`user clicks on a link, the HTML Viewer control notifies your application, passing
`in the text of the link, so that you can then choose to retrieve and display the
`requested page.
`
`NOTE
`
`WARNING
`
`The HTML Viewer control does not actually manage the retrieval of documents
`over the Internet. Rather, it is a means of displaying HTML data. Your application is
`still responsible for actually fetching the document from a server and then sending
`it to the HTM L control.
`
`Be aware that if you're developing for both the PPC and the HPC that the HPC
`does not support the Cap Edit control! The Ink control is supported, although it is
`undocumented as of this writing.
`
`Handheld PC/Pro Devices
`Handheld PC/Pro devices (or HPC/Pros) are the top-of-the-line models. They
`are typically the size of a small laptop, about 10 x 7 x 11/2 inches. HPC/Pros have
`a laptop-size keyboard, which is more than adequate for any amount of data
`entry by the user. Their screen is landscape-oriented and huge compared to the
`other CE devices, a full640 x 480.
`
`Further, at least one HPC/Pro model has a mouse pointer instead of a touch
`screen. In addition, most HPC/Pro devices have both a Compact Flash slot and a
`PCMCIA (Type II) slot, either of which can be used to add additional memory or
`peripheral devices to the HPC/Pro. Of all the CE platforms, the HPC/Pro is the
`most powerful and the most familiar-looking device. Figure 1.10 shows an example
`of an HPC/Pro, the Hewlett-Packard Jomada.
`
`Starbucks Corp. Exhibit 1031
`
`
`
`28
`
`Chapter 1 • W hat Does CE Do f or M e?
`
`FIGURE 1.10 :
`
`The Hewlet-Packard
`Jornada
`
`Copyright Hewlett-Packard © 1999
`
`The form and design of the HPC/Pro devices make them an ideal platform for
`doing just about anything short of compiling code. As noted earlier, the keyboard
`is easy to type with, and the battery on an HPC/Pro device lasts up to 10 hours.
`
`There are several features that make HPC/Pros unique from other CE devices:
`
`• Display
`
`• VGA-outport
`
`• A laptop-size keyboard
`
`• The HTML Viewer control
`
`Starbucks Corp. Exhibit 1031
`
`
`
`CE Devices
`
`29
`
`Display
`The displays on HPCs typically measure about 640 x 480. That's twice as large as
`the screens on the HPC devices, and four times the size of the PPC screens. And
`it's not too far out of line with the resolutions available on Desktop machines.
`
`The final characteristic of HPC/Pro displays that makes them unique is that all
`of the HPC/Pros have color displays capable of displaying 256 colors.
`
`VGA-Out Port
`
`Some HPC/Pros, such as the Hewlett-Packard Jomada, offer a VGA-out port, so
`that your application can send data to a standard VGA monitor in a number of
`resolutions not supported directly by the CE device's own display. While it does
`take some additional battery power to drive the VGA-out port, this is still an excel(cid:173)
`lent feature for any application that needs to display presentation-oriented data.
`
`As a demonstration of this feature, let's borrow some simple graphics code that
`paints simple shapes from one of the MSDN samples and modify it to display its
`output on the VGA-out port.
`
`In order to activate the VGA-out port, we'll set up a simple window with a
`large button marked "VGA!!!". When the user clicks the button, we'll change the
`caption of the button (to "End VGA"), activate the VGA-out port by calling Cre(cid:173)
`ateDC() with a special parameter, and launch a separate thread (which we'll also
`write) to do the drawing. When the user clicks the button a second time, we'll
`change its caption back to the original "VGA!!!", set a flag to stop the drawing,
`and do any necessary cleanup.
`
`Your first task is to create the handler for the button click event by adding a
`block of code to your WM_COMMAND message handler. First, test to make sure that
`the WM_COMMAND message refers to your button:
`
`case WM_COMMAND:
`if ((HWND)lParam == hButton)
`{
`
`If it does, next check a Boolean flag, bVGA, to see if you're already displaying
`something on the VGA-out port:
`
`if (bVGA)
`{
`
`Starbucks Corp. Exhibit 1031
`
`
`
`30
`
`Chapter 1 • What Does CE Do for Me?
`
`If bVGA is set to TRUE, that means you're currently using the VGA-out port. If
`you arrive at this point, it means that the user would like to end the VGA graph(cid:173)
`ics show. Your first job then is to reset the bVGA flag so that your graphics thread
`can terminate:
`
`bVGA = FALSE;
`
`Then delete the special VGA-out HOC you created with a call to CreateD((),
`which we'll look at in just a moment. Next, reset the caption of your button so
`that it now reads "VGA!!!" again:
`
`DeleteDC(hVGA);
`SetWi ndowText(hButton, TEXTCVGA! ! ! "));
`
`Then exit the procedure:
`
`return TRUE;
`
`If, however, the bVGA flag was not set, you'll know that you need to initialize
`the VGA-out port and begin drawing to it. In order to open the VGA-out port,
`call CreateD(() but pass as the first parameter the name of the DLL that serves
`as the VGA-out port driver. On the Hewlett-Packard Jomada, there are three such
`DLLs to choose from, as illustrated in this table:
`
`Driver DLL Name
`
`VGA disp