APPENDIX A Setting Up Your Development Environment: A Quick- Step-Through
THIS MAY VERY WELL BE the shortest appendix in the history of publishing. Well, that may be an exaggeration, but this appendix will be short and to the point. The purpose here is to give you a feel for what you need to have installed to do a particular job in the world of .NET Compact Framework programming. The way to do that is to give you step-by-step instructions for what you need to do to get your environment up and running.
Install a Decent Operating System
By "decent," you might be thinking that I mean you shouldn't use Wmdows if you want a decent OS. Sorry, but no snide comments here! What I mean is you shouldn't use Windows 95 or Windows 98. Visual Studio 2003 requires you to use one of the following operating systems:
• Wmdows XP Professional
• Wmdows Server 2003
• Wmdows 2000 Professional (SP3 or later)
• Wmdows 2000 Server (SP3 or later)
It's possible to use Wmdows XP Home Edition, but if you do, you won't be able to write or host ASP. NET pages or Web services.
907 Appendix A
Install Visual Studio .NET 2003
This should be obvious, but I want to be complete. It's also important to note that the .NET Compact Framework is part of the 2003 release ofVS .NET. The previous version, called the Smart Device Extensions, was provided as a separate add-on and installation to Visual Studio 1.0. For some "official" information on Visual Studio .NET 2003, you can check out either of these two Microsoft Web sites:
• Visual Studio .NET Home Page-http:/ /msdn.microsoft.com/vstudio/
• Support Center for Visual Studio-http: I I support. microsoft. com/ default.aspx?scid=fh;EN-US;vsnet
Install ActiveSync
ActiveSync is the software that synchronizes the data from your desktop com• puter to your PocketPC. Download the latest version of ActiveSync from http://www.microsoft.com/downloads/details.aspx?FamilyiD=67e9e87c-ca96-48b4- bSd4-f3e047ca5108&displaylang=en and install it on your computer. And really, that's all that is required to get started. The remaining tools you need are included in Visual Studio 2003. Of course, you may want to install some optional packages, and we'll discuss those next. You might also find a significant number of "toys" and other downloads interesting. The last portion of this appendix will contain links to some of those items.
Install SQL Server and SQL Server CE
If you don't plan on using SQL Server or SQL Server CE, then you don't have to worry about this section. But if you have a desire to use SQL CE by itself or to synchronize data with SQL Server, then this might be worth reading. With the problems that exist from a variety of hacking attempts and suc• cesses, everyone should have the latest service pack for SQL Server installed. At the time of writing, that is SP3. As was discussed in Chapter 11, installing SQL CE over SP3 can get a bit dicey. You can find a description of SP3 and a link to down• load it from this Web site: http: I lwww. microsoft. com/ sql/downloads/2000/ sp3. asp. Now, when you install SQL CE 2.0, you have to install client and server tools. If you installed SP3, then you can use the SQL CE installation for client tools, but you must install a service update on the server that is hosting liS. The following links point you to the important pages on the Microsoft Web sites that provide detailed information:
908 Setting Up Your Development Environment: A Quick Step-Through
• General SQL CE site-http: I /www. microsoft. com/ sql/ eel
• SQL CE 2.0 download site-http: I /www. microsoft. com/ sql/ eel downloads/ ce20.asp
• SQLEC service update-http: I /www.microsoft.com/sql/downloads/ce/sp3 .asp
When you install these upgrades, they will bring your Microsoft Data Access Components (MDAC) up to version 2. 7.
Install the eMbedded Tools
No, I don't know why Microsoft capitalizes the M and not the e. But I do know that you should install eMbedded Visual Tools 3.0 on your development machine. If you've previously used the embedded tools, you know that they include a vari• ety of tools that let you look at processes, files, and other details of the emulator or device. These tools aren't included in Visual Studio 2003, and in time you'll need them for debugging or curiosity, whichever comes first. You can set up the Tools menu in Visual Studio to launch the utilities from right inside the IDE. The SDKs that get installed with the tools also provide you the header files that can be used to build your own Declare or Dllimport statements to call unmanaged code. TWo versions of the eMbedded tools are currently available. Version 3.0 is the old standby that has been used for years to write applications for devices. The new kid on the block is eMbedded Visual C++ 4.0. This version, with Service Pack 2 installed, lets you target Windows CE 4.0, 4.1, and 4.2. At this time, Visual C++ 4.0 doesn't have an SDK to allow you to target the Pocket PC or Smartphone. Following are the URLs you'll need to access and learn more about the eMbedded Visual Tools:
• eMbedded Visual Tools Web site• http://msdn.microsoft.com/vstudio/device/embedded/default.aspx
• eMbedded Visual Tools 3.0- http://www.microsoft.com/downloads/details.aspx?Family!d=F663BF48-31EE- 4CBE-AACS-OAFFDSFB27DD&displaylang=en
• eMbedded Visual C++ 4.0- http://msdn.microsoft.com/vstudio/device/embedded/datasheet.aspx
• eMbedded Visual C++ 4.0 SP2-http: I /microsoft. com/ downloads/ details.aspx?Family!d=CE7F1AAA-54EB-4989-812B-7F95560SDCB8&display• lang=en
909 Appendix A
Once you digest all of the preceding Web sites and pages, you can get a gen• eral overview of application development for devices from the following site:
• Device development overview-http: I lmsdn. microsoft. comlvstudiol deviceloverview.aspx
Summary
This short appendix covers everything you need to get started. There are many sites that you can visit for downloads, help, and tools. Rather than add a large list of URLs here that you would have to type in by hand, you can get a list of links at either http: I lwww .larryroof. com or http: I lwww. forestsoftwaregroup. com. Appendix D tells you the exact location of these sites, from which you can also download ver• sions of the source code.
910 APPENDIX B Working with the Emulator
THE Focus OF THIS APPENDIX is to show you how to get the most out of the emula• tor. Before we get started, let me say that I'm not a big fan of emulators. Obviously, if you don't have a device, they're your only option. While I may grant this con• sideration for students, I can't see any possible scenario in which corporate or commercial developers would be without a device. The obvious and most important reason for testing on a device is that no matter how good a job the emulator does, it isn't a device. You don't interact with an emulator using a stylus; you use a keyboard and mouse. You don't hold it in your hand; it sits on your virtual desktop. It has different processor capabilities. With that said, I have to tell you that I have from time to time used the emu• lator. In situations where you don't want to hook up a device, such as on an airplane, the emulator is a nice alternative. Additionally, the emulator provided with the Smart Device Extensions is a vast improvement over previous Pocket PC emulators.
Launching the Emulator
You can launch the emulator in two ways: from within the Visual Studio .NET IDE and from the command prompt.
Launching the Emulator from Within VS .NET
There are two ways to launch the emulator from within the Visual Studio .NET IDE. The first way is as follows:
1. Start a Smart Device Extension project.
2. Select Pocket PC 2002 Emulator from the Deployment Device combo box, which is located on the toolbar.
3. Run your application.
911 AppendixB
The emulator will be automatically loaded in preparation to running your application. The second way to launch the emulator is to attempt to establish a connec• tion to the emulator from within the Visual Studio .NET IDE. This can be accomplished by clicking the Connect to Device button, which is located on the toolbar, or through the Connect to Device menu item on the Tools menu.
, ·1 ; TIP To speed the development process, it's best to leave the emula• tor open and running between builds and tests ofyour application. I've found that the slow start time of the emulator interferes with the build, test, refine, and repeat development process.
Launching the Emulator from the Command Prompt
To launch the Wmdows CE emulator from the command prompt, perform the following steps:
1. Open the command prompt.
2. Either define the path to, or navigate to, the directory where the emula• tor executable resides. By default, the emulator resides in the following directory: C:\Program Files\MicrosoftVisual Studio .NET 2003\ CompactFrameworkSDK\ConnectionManager\Bin.
3. Enter the command emulator, along with any command-line argu• ments, and press Enter. The emulator will start.
Table B-1 shows command line arguments for the emulator application.
Table B-1. Emulator Command Line Arguments
ARGUMENT DESCRIPTION /CEimage Represents the path to the operating system image to load into the emulator. The image must match the target device. This argument is required. /Ethernet Enables or disables an Ethernet adapter for use with the emulator. Acceptable values are none, shared, virtualswitch, or the MAC address of an adapter to use. /Skin Specifies the XML file defining the skin to use with the emulator. /Video Defines the resolution and bit depth for the emulator; for example, 240X320X 16.
912 Working with the Emulator
Default images, along with their skins, are included under the default folder hierarchy ofC:\Program Files\MicrosoftVisual Studio .NET 2003\ CompactFrameworkSDK\ConnectionManager\Bin\Images.
Running the Emulator Without a Network Connection
The emulators provided with Smart Device Extensions will not operate unless the development PC on which it's running has a network connection. If your PC doesn't have a network connection, you can still use the emulator by installing the Microsoft Loop back Network Adapter. This adapter simulates a network con• nection and effectively fools the emulator into running.
Installing a Loopback Adapter Under Windows 2000
Under Wmdows 2000, the process for installing the Microsoft Loop back Network Adapter is as follows:
1. From the Control Panel, click Add/Remove Hardware.
2. On the Welcome page of the Add/Remove Hardware WIZard, click Next.
3. Select Add/Troubleshoot a device and click Next. The process will pause while your system is scanned for plug-and-play devices.
4. From the Choose a Hardware Device page, select Add a new device and click Next.
5. On the Find New Hardware page, select No, I want to select the hard• ware from a Hst and click Next.
6. From the Hardware Type page, select Network adapters and click Next. There will be a brief delay while a list of network adapters is generated.
7. On the Select Network Adapter page, first select Microsoft from the Manufacturers list box, then select Microsoft Loopback Adapter from the Network Adapter list box. Click the Next button.
8. From the Start Hardware Installation page click Next. The loopback adapter installs.
913 AppendixB
Configuring a Loopback Adapter Under Windows 2000
Like any network adapter, installing a loopback adapter is only half of the process. You also need to configure your new adapter. Perform the following steps to configure the loop back adapter:
1. From the Start menu, select Settings, then Network and Dial-up Connections, and finally Local Area Connection. The Local Area Connection Status dialog box displays.
2. Click the Properties button. The Local Area Connection Properties dia• log box displays.
CAUTION At this point, check to make sure that you're working with the right connection. The Connection Using field of this dia• log box should read Microsoft LoopbackAdapter.
3. Select Internet Protocol (TCP/IP) and click the Properties button. The Internet Protocol dialog box displays.
4. Configure the IP address properties.
5. Click the OK button to close the Internet Protocol dialog box.
6. Click the OK button to close the Local Area Connection Properties dialog box.
7. Click the Close button to close the Local Area Connection Status dialog box.
Configuring the Emulator
You can divide the topic of configuring the emulator into two categories: config• uring the "hardware" environment and configuring the instance of the Pocket PC operating system that's running in the emulator. I'm not going to discuss the process of configuring the operating system, as it's identical to how you would configure an actual device. Instead, in this section I'm going to focus on config• uring the hardware environment-that's to say, the virtual device on which the emulator runs.
914 Working with the Emulator Defining the Emulator's Hardware
The hardware configuration of the emulator is defined through the Visual Studio .NET IDE. This configuration defines the virtual device in which the emulator runs. In most cases, you can simply use the default settings, which define a device with 32 megabytes of RAM, a 240X320 screen with 16 bits of color depth (as shown in Figure B-1), and no COM or parallel ports.
Figure B-1. Default emulator settings
To alter the hardware configuration of the emulator, perform the follow• ing steps:
l. From within the Visual Studio .NET IDE, select Options from under the Tools menu.
2. Under the Devices folder of the Options dialog box, select Devices.
3. In the Devices list box, select Pocket PC 2002 Emulator, as shown in Figure B-l.
915 AppendixB
General + Devices Cl HTML Designer EJ Projects Windows Forms Designer [] XML Designer
Figure B-2. Specifying the device in the Devices list box
4. Click the Configure button.
5. The Configure Emulator Settings dialog box displays. Define your new emulator settings and click the OK button.
The Configure Emulator Settings dialog box has three tabs: Display, System, and Hardware. On the Display tab, you can specify the size and color depth of the emulator screen. From the System tab, you can define the emulator's mem• ory size and the host key, which provides a shortcut to emulator control features (see Figure B-3). The Hardware tab allows you to associate serial and parallel ports on your development PC to the emulator (see Figure B-4).
916 Working with the Emulator
Figure B-3. System tab settings
Figure B-4. Hardware tab settings
NOTE As with actual devices, the Pocket PC emulator is limited to 64 megabytes ofRAM. Even though the dialog box will allow you to set the amount of memory to 256 megabytes, the emulator will in fact only have 64 megabytes. This is a limitation of the Pocket PC 2002 operating system, which applies as well to the emulator.
' I ' TIP A common reamn to increase the memory size configuration of the emulator is to handle testing applications that make use of large SQL Server CE databases.
917 AppendixB Setting Up an ActiveSync Partnership
You may need to establish an ActiveSync connection to the emulator to test spe• cific features or functionality of your application. To create a connection to the emulator, your development PC needs at least two COM ports. The emulator and the development PC will each need a port for use with the ActiveSync connection. To establish the physical connection between your development PC and the emulator, perform the following steps:
1. Connect a null modem serial cable between the two serial ports.
2. Configure the emulator's hardware to include a serial port. This will be the emulator's ActiveSync connection.
3. On your PC, launch the ActiveSync application.
4. Under the File menu of the ActiveSync application, select Connection Settings.
5. On the Connection Settings dialog box, confirm that the setting Allow serial cable or Infrared connection to this COM port is selected.
6. Using the combo box, configure the COM port to one of the COM ports on which you connected the serial cable. Note that this should NOT be the port you added to the emulator.
7. Click the OK button to close the dialog box.
To establish a partnership between your development PC and the emulator, perform the following steps:
1. Start the emulator if necessary.
2. Press and hold the control key (CTRL) on your development PC.
3. In the emulator, click and hold on the clock in the upper-right comer of the title bar. After a brief pause, a shortcut menu displays.
4. From this menu, select Run.
5. In the Run dialog box, type repUog. The repllog executable is the device• side component of ActiveSync. It initiates the connection to a PC.
6. The ActiveSync module on your desktop PC will detect the emulator's attempt to connect. The New Partnership Wtzard will start. 918 Working with the Emulator
7. Complete the wizard, specifying the types of data to synchronize between the emulator and your development PC.
At this point, you have a functioning ActiveSync connection between the emulator and your development PC.
NOTE You should use ActiveSync version 3.6 or later when working with Smart Device Extensions and the .NET Compact Framework.
Changing the EmulatorJs Skin
This is another one of those things that falls into one of two categories: Either you have too much time on your hands or you're being paid by the hour. The emulator allows you to modify and customize the skins used by the emulator. If you're not already familiar with the term, skins define the appear• ance of an application. In this case, that application is the emulator. You define the skin for the emulator with an XML file. Listing B-1 shows an example of the default skin shipped with Visual Studio .NET. Through this file, you can configure the size and position of the emulator, the graphical images that define the interface, and tooltips.
' I , TIP You may choose to define custom tooltips in situations where your application is taking control over the hardware buttons.
Listing B-1. The Default Skin
919 AppendixB
NOTE For more information on creating skins, see the emulator help file, which is accessible through the Help menu from the emulator.
Resetting the Emulator
Like regular Pocket PC devices, you can reset the emulator. This can be either a soft or a hard reset. The soft reset restarts the emulator while maintaining any existing configurations. The hard reset restarts the emulator while restoring it to its original state. That's to say, you'll have to go through the Startup Wtzard and will lose any existing configurations. You use both of these resets just as you would on a device, to restore a test• ing environment.
Saving the Emulator State
When you exit the emulator, you'll be prompted to save the current configura• tion, or state, of the emulator. The saved state automatically restores the next time the emulator starts. This feature enables you to create and reuse a specific emulator configuration that is best suited for your testing needs. A single file stores the state of an emulator. This file is placed in the follow• ing location:
(:\Documents and Settings\
where "account name" is the name of the user account under which you logged in; the filename for the state file is {GIUD}.vsv. You'll notice this file by its rela• tively large size.
Moving Files to the Emulator
The last topic that I want to discuss is how you go about moving files to the emu• lator. These files, used for testing purposes, might include anything from simple text files all the way to databases. 920 Working with the Emulator
Earlier versions ofWmdows CE/Pocket PC emulators offered two distinct approaches to creating the emulator environment. The first generation of emulators used a closed environment, which was inaccessible from standard Wmdows-based file management tools found on the development PC. Any files that you needed on the emulator had to either be created within the emulator or copied to the emulator using specialized utilities that were included with the eMbedded Visual Tools. Second generation emulators provided a more open environment, one that was accessible using common tools, such as File Explorer. The emulator direc• tory structure existed in a subdirectory on the development PC. Copying files to and from the emulator was a simple drag-and-drop operation. The emulator included with Smart Device Extensions returns you to the closed emulator environment. To complicate matters, unlike earlier versions of the eMbedded Visual Tools, Smart Device Extensions doesn't include a file man• agement tool. This absence requires some creative workaround on your part. There are three common ways to provide files within the emulator environ• ment. One way is to create the files through applications that run on the emulator. I don't believe that this approach requires any additional discussion here. You can use any of the other approaches detailed throughout this book to create text, XML, or database files. What I'm going to focus on in the remaining part of this appendix is the other two ways of providing files within the emulator: adding files to your proj• ect and copying files from a share.
Adding Files to Your Project
The easiest method to move files to the emulator is to include them as part of your project. The other advantage to using this approach is that in the event that you perform a hard reset on the emulator, you simply need to rebuild your proj• ect to resume testing. The process for using this approach is as follows:
1. Open your project within Visual Studio .NET.
2. Under the Project menu, select Add Existing Item.
3. From the Add Existing Item dialog box, select the file that you want to copy to the emulator.
4. Click the Open button. The file will be added to your project.
5. In the Solution Explorer window, select the file you added.
921 AppendixB
6. In the Properties window, verify that the Bulld property is set to Content. Items configured as "Content" are copied to the target device as separate files. Items configured as "Embedded Resource" are part of the application's executable.
7. Build the project. The file copies to the device along with your application.
Copying Files from a Share
The second approach offers more flexibility with a minimal amount of addi• tional work. It makes use of the network file sharing functionality built into the Pocket PC operating system, which subsequently is made available through the emulator included with Smart Device Extensions. There are two parts to this approach: setting up a share on your develop• ment PC and then accessing that share through the emulator's File Explorer. Setting up a share requires two configurations. First, you must configure your PC to enable sharing. Second, you must configure individual folders to share. To enable sharing on a development PC runningWmdows 2000, perform the following steps:
1. Under the Start menu, select Settings, select Network and Dial-up Connections, and then specify your local area network connection.
2. From the Local Area Connection dialog box, click the Properties button.
3. From the Local Area Connection Properties dialog box, enable FOe and Print Sharing for Microsoft Networks.
4. Click the OK button to close the Local Area Connection Properties dialog box.
5. Click the Close button to close the Local Area Connection dialog box.
At this point, you've configured your development PC to allow file sharing. Next you need to share the folder in which you'll place the files you wish to copy to the emulator. To share a folder underWmdows 2000, perform the fol• lowing steps:
1. Launch File Explorer.
2. mFile Explorer, right-click the folder you wish to share.
3. A pop-up menu will display. From this menu, select Properties. 922 Working with the Emulator
4. From the Properties dialog box, click the Sharing tab.
5. On the Sharing tab, select to share the folder and provide a name for the share.
6. Click the OK button to close the Properties dialog box.
With your development PC configured, you're ready to copy files. First, you'll need to place all of the files destined for the emulator in the shared folder. Then, to move the files to the emulator, perform the following steps:
1. Launch the emulator. Refer to the instructions on launching the emula• tor at the start of this appendix, if necessary.
2. From within the emulator start File Explorer.
3. From the File Explorer menu, select Open.
4. The Open dialog box will display. Specify the name of your development computer followed by the name of the share you created using this for• mat: \ \mycomputer\myshare.
5. Tap the OK button.
6. Depending upon the security settings on your development PC, you may be prompted for a user name and password before being allowed to access the share.
At this point, you're ready to copy files to and from the share on your devel• opment PC and the emulator.
NOTE These same approaches for copying files work equally well with a device with one known issue. Pocket PC devices by default have a device name "Pocket PC: Unless you change this name, you won't be able to access a share.
923 APPENDIX C Resources
THIS APPENDIX PROVIDES vou with a variety of sources for information and prod• ucts that relate to either the .NET Compact Framework or mobile development.
CAUTION As with any printed materials that include references to Web sites, there is always the possibility that a URL will have changed between the time a book goes to print and the time you purchase and read that book. For an up-to-date list ofmobile devel• opment-related resources, check out http: I /'iMtl.larryroof. com.
News groups
The most active newsgroups of interest to the NETCF-based mobile developers are all sponsored by Microsoft. They include the following:
• microsoft. public. dot net. framework. compactframework-Discussions on developing with the .NET Compact Framework.
• microsoft. public. mobility. miserver-Topics on Microsoft's Mobile Information Server, the server-based ActiveSync manager.
• microsoft. public. pocketpc-General information about the Pocket PC, focusing on the hardware and operating system.
• microsoft. public. pocketpc. developer-A somewhat useful forum for Pocket PC developers. Although, unlike the .NET Compact Framework newsgroup, this newsgroup isn't product specific, it's useful in that it cov• ers a variety of topics, including working with hardware, Pocket Internet Explorer, and the eMbedded development tools (eVC++ and eVB).
• microsoft. public. smart phone. developer-Provides discussions on Smartphone-related topics.
• microsoft. public. sqlserver. ce-Focuses on the SQL Server CE product. The best source for mobile database-related questions.
925 AppendixC
• microsoft.public.webservices-While technically not a NETCF or a mobile group, in situations where your mobile solution needs to leverage a Web service, information found in this newsgroup may be helpful.
• microsoft. public. windowsce. app. development-You'll find discussions on general Windows CE-related topics within this newsgroup.
• microsoft. public. windowsce. embedded. vb-The newsgroup for developers working with eMbedded Visual Basic (eVB).
• microsoft. public. windowsce. embedded. vc-The newsgroup for developers working with eMbedded Visual C++ (eVC++).
Web Sites
Numerous Web sites provide useful information for mobile developers. In this section, I've divided these sites into several categories for easier reference.
Web Sites: Developer Programs
If you're developing commercial applications that target the Pocket PC, you may be interested in participating in one or both of the following two programs: Microsoft's Mobile Solution Partner Program is a worldwide initiative designed to aid you in the development and marketing of mobile solutions. You can obtain additional information on this program at http: I /www. microsoft. com/ mobile/partners/default.asp. Microsoft's Moblle2Market Program is a comprehensive program for the certification and delivery of mobile applications designed for Pocket PC and Smartphone. It connects independent software vendors to mobile operators and retailers, strengthening the marketplace for mobile applications by creating new revenue opportunities for mobile applications, reducing your time to market, and improving your customer's user experience. For more information on this program, seehttp://www.microsoft.com/mobile/developer/developerprograms/ mobile2market/default.asp.
Web Sites: Developer Information and Tools
Following is a list of sites that cater to mobile developers, offering articles, sam• ple applications, and forums:
926 Resources
• http: II smartdevices. microsoftdev. com-Microsoft's Web site for smart device development, where you will find articles, downloads, and other items for developers who are targeting the Pocket PC, Pocket PC 2002, Pocket PC 2003, Pocket PC Phone Edition, Smartphone, Handheld PC, and other devices runningWmdows CE version 4.1 or later.
• http: II samples. gotdotnet. com/ quickstart/CompactFramework-Microsoft's site that targets developers who are just starting to work with the .NET Compact Framework. The QuickStart site provides guidance in a variety of areas. It offers mobile development techniques and workarounds for dif• ferences between the full .NET Framework and the .NET Compact Framework.
• http: //msdn. microsoft. com-Microsoft's MSDN site contains a number of articles and white papers on working with the .NET Compact Framework and SQL Server CE. On this site, you'll find the MSDN Voices column "1\vo for the Road," which presents monthly articles on mobile development.
• http://www. devbuzz. com-A comprehensive repository of articles, samples, and forums on the .NET Compact Framework and SQL Server CE.
• http://www. innovati vedss. com-The forums offered at this site include a variety of topics related to the .NET Compact Framework.
• http://www .larryroof. com-Here you'll find links to Larry Roof's articles on developing with the .NET Compact Framework and SQL Server CE.
• http://www. forestsoftwaregroup. com-Dan Fergus's site offers a variety of code examples and articles on working with NETCE
• http://www. opennetcf. org-A site that provides a repository for informa• tion and open-source projects specifically targeting the .NET Compact Framework.
• http://www. pocketpcdn. com-This site offers a large number of articles that focus on mobile development. While NETCF content is minimal, this site still is a good source for Pocket PC-related topics.
• http: //pocketprojects. pocketgear. com-Here you'll find a large variety of forums on mobile development, including the .NET Compact Framework.
927 AppendixC
• http://www.microsoft.com/mobile/assets/PocketPC_SoftApp_Handbook.doc-• This link brings you to "Designed forWmdows for Pocket PC, Handbook for Software Applications," Microsoft's guidelines for developing applica• tions that target the Pocket PC.
• http: I lwww. ragingsmurf. com/vbcsharpconverter. aspx--This site will convert code written in C# .NET to its VB .NET equivalent. This feature can be of great aid in situations where the only sample of a particular technique that you have is in C# and you want to work in VB.
Web Sites: Pocket PC Software
Although you'll find a number of Pocket PC software sites on the Web, three of these sites merit mentioning for their usefulness to mobile developers:
• http: I lwww. pocketpc. com--The "home" site of the Pocket PC. This site includes everything from "getting started" tips for the end user, to brief development articles, software updates, and development kits and tools.
• http: I lwww. handango. com--The premier commercial portal for software that targets the Pocket PC. Whether you are looking for end-user software, developer tools, or a market for your applications, Handango is the place to start.
• http: I lwww. microsoft. com/mobile/ catalog/--Microsoft's catalog of applica• tions certified for the Pocket PC and Smartphone. This catalog is a showcase of products that carry the Microsoft Designed for Windows logo certifica• tion and is part of the Mobile2Market Program discussed earlier in this appendix.
Web Sites: Pocket PC Hardware and Accessories
In this section you'll find links to information about commercial and industrial versions of Pocket PC, as well as miscellaneous equipment for your mobile device.
Commercial Devices
A large number of companies now make some variation of Pocket PC devices. I'm not going to list them all here, as the list of vendors and the models they pro• vide change on a regular basis. Instead, I would recommend you reference the 928 Resources following page on Microsoft's Pocket PC site that provides a fairly up-to-date listing of current products offered by Pocket PC vendors. The link is http://www.microsoft.com/windowsmobile/buyersguide/compare/default.mspx.Fronn this page you can select fronn various global regions to obtain information on devices that are nnarketed in your area.
Industrial Devices
There are several nnanufacturers that nnake industrialized versions of Pocket PC devices.
• Syinbol-Provides a wide variety of ruggedized devices that incorporate barcode scanning, wireless networking, printing, nnagnetic strip card reading, and GSM/GPRS connectivity. Synnbol offers an SDK for develop• ers working with the .NET Connpact Frannework that nnakes it easy to incorporate their devices' hardware features into your nnobile solutions. For nnore details, see http://www. symbol. com/products/mobile_computers/ mobile_computers.html.
• Intennec-Provides a connplete product line of ruggedized devices, like Synnbol, that offer scanning, wireless networking, printing, nnagnetic strip card reading, and GSM/GPRS/CDMA connectivity. Intermec offers develop• ers connponents to use with the .NET Connpact Frannework for leveraging the features of their devices. For nnore product information, see the Intermec site at http://www. intermec. com.
• TimbaTec-Offers an industrialized, all-weather device that incorporates wireless networking functionality. The TirnbaTec device is connpletely sealed so that it can be used in extrenne clinnate conditions. You can select fronn a variety of plug-in nnodules, including barcode and serial port func• tionality, that extend the capabilities of this device. For nnore information, see TinnbaTec's site at http://www. timbatec.com.
• .Amaga--Offers a rugged, expandable device for both nnilitary and industrial use. Available add-ons include wireless networking, GPS, GSM/GPRS/CDMA, and Bluetooth. For nnore information, visit the Annaga site at http://www. myagama. com.
• Casto-Provides a nunnber of industrial devices based upon the Pocket PC form factor. Most units are expandable so that you can add barcode scan• ning, wireless networking, or a nnagnetic strip reader. See Casio's site at http://www.casio.com.
929 AppendixC Miscellaneous Equipment
This category includes CF cards, PC Cards, cases, keyboards, modems, and other equipment that extends or enhances the effectiveness of a Pocket PC. Listing all of the vendors that provide such equipment is beyond the limits of this appen• dix, and such a list would be out of date the day that this book went to print. Instead, I would suggest visiting the Mobile Planet Web site at http: I l'tltrtl. mobile• planet. com. Mobile Planet offers a comprehensive assortment of equipment for the Pocket PC.
Developer Tools
While the number of third-party companies that cater to mobile developers is but a mere fraction of the volume of companies providing aid to the desktop market, you should be aware of certain key products and companies, as we'll discuss in this section.
Hardware Tools
The most important hardware tool that I would suggest you consider as a mobile developer is to add an Ethernet connection to the device you're using for testing. Whether that connection is tethered or wireless depends upon your project needs, but whichever you choose, you will find that developing over Ethernet dramatically improves your productivity. While a number of manufacturers offer both tethered and wireless CF Ethernet cards for use with the Pocket PC, I'm particularly fond of the offerings from Socket. They are battery friendly, meaning they are designed to use as little power as possi• ble. You can find out more about Socket's offerings at http: I l'tltrtl. socketcom. com.
Programming~ Testing~ and Deployment
While not a large number of tools are available for mobile developers, you may want to consider adding a few key products, discussed in this section, to your creative arsenal.
Pocket Controller
This utility is comprised of two components, desktop and device. This pair of components works together, providing both a visual and input interface between a desktop PC and a device.
930 Resources
1\vo main benefits are offered through Pocket Controller. First, it enhances your productivity, as it allows you to enter data from your PC rather than from the device. What this means is that you can use your computer keyboard and mouse instead of the stylus, enabling you to speed up your testing processes. Second, Pocket Controller is ideal for presentations, as it allows you to proj• ect the screen of a device through a connecting PC. All that you need to do is attach a projector to your computer to demonstrate applications running on a Pocket PC. Additional features include
• Ability to remotely capture and print screens
• Support for both portrait and landscape view
• Four levels of zoom off the device interface
• Ability to transfer data between desktop and mobile device clipboards
• File transfer support
• Ability to remotely activate or stop applications and processes
• Ability to create video recordings of screen activities as they occur on a device
Pocket Controller is a product of Soti and is available online at http://www.soti.net.
P/Invoke Wizard
If you need to incorporate Wmdows CE API function calls into your mobile solu• tions, then you should consider purchasing the PI Invoke WIZard offered by Paul Yao, at http://www. paulyao. com. The wizard works by reading values found in the include (.H) files ofVisual C projects. It takes the various C/C++ declarations and produces a compatible .NET version in your choice of C# or VB .NET. One of the hardest parts of being able to use Wmdows CE API functions from within a .NET Compact Framework application is the process of translat• ing the calls from their native format to the format required by NETCE This wizard makes quick work of that process and is a tool that will pay for itself many times over.
931 AppendixC PocketConsole
Microsoft provides a console, or what is frequently thought of as a DOS prompt, with Wmdows CE. Unfortunately, the Pocket PC OS doesn't. While not in great demand for mobile developers, in certain situations you'll need such a console as part of your mobile solutions. PocketConsole, from SymbolicTools, provides a console device for Pocket PCs. This console manages input and output for character-mode. applications. For more information on PocketConsole, see the vendor's Web site at http://www.symbolictools.de.
EzSetup
This free setup utility allows you to create installations for your Pocket PC appli• cations. The installations generated by EzSetup are easy for your end user to follow. This utility allows you to include readme files and licensing information and generates compressed, self-contained, self-extracting installations. Installations can be created for a variety of languages and integrated with the installation component of ActiveSync. Best of all, this setup utility is free. For more information, see http: I /www. softspb. com.
Controls and Components
The selection of third-party controls and components for use with the .NET Compact Framework is steadily growing. Following are some of the more useful controls available.
CFCOM
This component provides a solution to one of the largest limitations of NETCF-being able to use COM objects and ActiveX controls. With CFCOM, you will be able to
932 Resources
• Use ActiveX controls in NETCF applications.
• Use COM components in NETCF applications.
• Build your own managed controls and components based upon ActiveX controls and COM components.
• Support both ActiveX and COM events.
• Include full designer support for Visual Studio .NET.
Included with this utility are complete examples with source for wrappers for ADOCE, Pocket Outlook, and Media Player. You can obtain CFCOM from Odyssey Software at http: I lwww. odysseysoftware. com.
ADOCE .NET Wrapper
This component provides both read and write access to Pocket Access databases from your NETCF applications. With this component, you can also access under• lying system tables that are stored in the Object Store. The ADOCE .NET Wrapper uses an object model that is similar to ADOCE itself, making development easier for eVB programmers switching over to the .NET Compact Framework. The wrapper provides support for NETCF features such as data binding, providing you with the best of both worlds from ADOCE andNETCR The ADOCE .NET Wrapper is available from InTheHand Software at http://www.inthehand.com.
Pocket Outlook .NET
Pocket Outlook .NET is a set of .NET classes that enable you to incorporate the appointments, contacts, and tasks that are stored in Pocket Outlook into your NETCF applications. Delivered as a DLL wrapper to the underlying POOM COM component, Pocket Outlook .NET provides a set of classes, methods, and prop• erties that make it easy to query, add, and update information stored within Pocket Outlook. Pocket Outlook .NET is available from InTheHand Software at http://www.inthehand.com.
933 AppendixC
Document List
Products such as Pocket Word and Pocket Excel make use of a standard list interface for displaying available documents. InTheHand Software offers a lightweight component, Document List, that allows NETCF developers to easily incorporate this interface into their applications. Using this component rather than OpenFileDialog will dramatically improve the appearance of your user interfaces. Document list is available from InTheHand Software at http://www.inthehand.com.
Identity
Stored away in the registry of every Pocket PC is the device owner's information. Using InTheHand Software's Identity component, you can access this informa• tion easily from your NETCF application. You can use this information to customize your application and to perform key-based registration, such as that used by Handango. The Identity component is available on InTheHand Software's Web site at http://www.inthehand.com.
DateTimePicker Control
One of the many controls that didn't make it into the .NET Compact Framework, the DateTimePicker control is a mainstay of user interface development for mobile applications. IntelliProg, realizing this shortcoming, was quick to provide an alternative for use under NETCE For more information, see IntelliProg's Web site at http: I lwww. intelliprog. com.
HTMLViewer Control
While certainly not as robust in functionality as the Web controls offered with the .NET Framework, IntelliProg's HTMLViewer control enables you to render and display HTML content within the interface of your mobile applications. For more information, see IntelliProg's Web site at http://www.intelliprog.com.
Richink Control
NETCF is incredibly limited in the ways it provides developers for displaying text content. IntelliProg addresses this shortcoming with its Richlnk control. This
934 Resources
control supports entry, editing, and display of text in a variety of formats includ• ing Rich Text Format (RTF). An additional feature of this control is its support for ink, enabling your users to enter content in written form. For more information on the Richlnk control, see IntelliProg's Web site at http:llwww.intelliprog.com.
IP*Works
This suite of controls from nSoftware greatly simplifies the development of Web-enabled applications. Included as part of this package are controls that implement the HTTP, FTP, SMTP, POP3, and NNTP protocols, as well as many more. You can obtain more information on IP*Works at the company's Web site: http:llwww.nsoftware.com.
Training
If you are looking for either face-to-face or video-based training to jump-start your development projects, then look no further than http: I lwww .larryroof. com, where you will find the finest in NETCF application development training. Larry Roof's 5-day training class will enable you to quickly begin developing robust mobile solutions using the .NET Compact Framework. You'll be led through the complete process of developing effective Pocket PC applications, from design, through development, and finally to distribution. You'll learn firsthand from one of the industry's best. Are you unable to get away from work to attend a 5-day training class? Then let Larry bring his training to you in the form of his industry-leading video train• ing. This isn't simple computer-based training as you seen offered by other vendors; instead, it's high-quality, DVD-based content that is unmatched by any• one today. You can purchase the full set of training modules or only the topics you're interested in. If you just need to learn how to work with SQL Server CE, or to create Web services, then you can buy just those modules. For more information on either Larry's face-to-face or video-based training, visit Larry's Web site at http: I lwww .larryroof. com.
935 APPENDIX D Sample Applications
THE SAMPLES THAT ACCOMPANY this book are available as a download from three sources: the Apress Web site, Larry Roof's Web site, and Dan Fergus's Web site. The Apress Web site is at http: I IWtM. a press. com. Once there, you'll need to navigate to the page for this title. On that page, you'll find a Source Code link. Clicking that link will take you to a page from which you can download the source code. You can also get the samples from either Larry's or Dan's Web site. Ifyou go to http: I l'v~i~N .larryroof. com, on the left side of the main page, you'll find a menu. From this menu, select pubUshed works, then books, and finally The Definitive Guide to the .NET Compact Framework The page that details this book will load. From that page, select Download the Source. At Dan's site, http: I l'v~i~N. forestsoftwaregroup. com, navigate to the samples by using the Publication link on the main page's left -hand menu. That will take you to a page giving details on the book and directions on how to access the sample applications.
Unpacking the Sample Applications
You receive the source for this book as a zipped archive. You'll need a utility, such as WmZip (http: I IWtM. win zip. com), to uncompress the archive. The archive will unzip to a series of individual folders, with each folder con• taining the samples for a chapter.
Obtaining Sample Updates
To correct errors and omissions, updates to the samples may be made available periodically. These corrections will be bundled into a samples archive and will be available from the two sources detailed earlier in this section.
Loading a Sample Application
All of the samples are in the form of a completed VB .NET project. You can load an individual project by performing the following steps:
937 AppendixD
l. Start Visual Studio .NET.
2. From the File menu select Open, and then Project.
3. Through the Open Project dialog box, navigate to and select the sample project you wish to load.
4. Click the Open button to load the desired project.
Running a Sample Application
Almost all of the sample applications provided for The Definitive Guide to the .NET Compact Framework run without any additional configuration. In some instances, particularly with the database-related samples, you may need to con• figure either the sample and/ or the target server before running the sample. In those instances, details provided within this book specify the steps you need to perform. To run a sample application, perform the following steps:
l. Select either Pocket PC Device or Pocket PC Emulator from the Deployment Device combo box.
2. Select Release from the Solution Configurations combo box.
3. Click the Start button.
The individual projects are configured to load to the \Windows\Start Menu\Programs\Apress folder on either your device or in the emulator. This allows you to manually launch applications through the Start menu later. Simply tap the Start menu, then Programs, tap the Apress folder, and finally tap the desired application.
Removing an Application
Applications built and deployed from within the Visual Studio .NET IDE are not "installed" on the device. They are simply copied to the device. To remove an application from your device, you only need to delete its executable. You can use the Pocket PC File for this.
938 Sample Applications
To remove an application, perform the following steps:
1. Start File Explorer.
2. Navigate to Windows\Start Menu\Programs\Apress.
3. Tap and hold on the application you wish to delete.
4. From the pop-up context menu, select Delete.
5. From the Confirm File Delete dialog box, tap Yes to complete the dele• tion.
Problems with a Sample Application
If you run into any problems with a sample application, first verify that you have performed any additional configurations. If you are still having trouble, you should check to see if there is an update to the book's samples available. If you have the latest updates and still can't resolve your problem, you can register your problem at http: I /www .larryroof. com. On the left side of the main page, you'll find a menu. From this menu, select publlshed works, then books, and finally The Deftnltive Guide to the .NET Compact Framework. The page that details this book will load. From that page, select Request Help with a Sample.
939 APPENDIX E Error Handling
No DISCUSSION ON DEVELOPMENT would be complete without including a conver• sation on error handling. By definition, the mobile development environment is prone to runtime errors. Think about it; you're mixing wireless networking, cell phone communication, database synchronization, Web services, custom com• munication modules, battery-powered devices, and mobile users all together in one environment. As far as development goes, if this isn't asking for trouble, I don't know what is. The bad news is that you're going to have to lace your mobile applications with error handling. The good news is that the .NET Compact Framework offers a robust set of tools for addressing this need. It combines the best of the Visual Basic world (On Error Go To) along with the new .NET-based exception handling (Try, Catch, Finally). If you're an eMbedded Visual Basic developer switching over to NETCF, let me just say that you're in for a treat. Now, I should take a moment to point out a key terminology difference between Visual Basic and VB .NET. Error handling, as you have come to know it in your developer journeys, is exception handling in the world of the .NET Compact Framework. Whether you refer to it as error or exception handling, it all boils down to the same thing: handling problems that occur during the running of your application.
Handling Errors Visual Basic Style
The .NET Compact Framework provides support for what I like to refer to as "old school VB error handling." The foundation of this style of error handling is the On Error Goto Label statement. Obviously, the key benefit to using this approach is that Visual Basic developers are already familiar with how it works, what it offers, and how to use it within an application. VB-style error handling will certainly appeal to eMbedded Visual Basic developers migrating over to the .NET Compact Framework. After all, they've survived for years on the minimalist version of this, the On Error Resume Next statement, what I affectionately refer to as the "crash-and-bum school of error handling."
941 AppendixE
NOTE The .NET Compact Framework does provide support for the On E"or Resume Next statement, although for the life of me I couldn't think ofa good reason to use it.
Is this VB style of error handling the best approach to error handling offered by the .NET Compact Framework? Certainly, it's not. Is it a suitable approach to error handling? Usually it is. I guess what I'm saying is that if you're a VB or eVB developer switching over to the NETCF world, struggling with the idiosyncrasies of .NET, and are searching for development techniques that you're already famil• iar with, this might be just what you're looking for. Certainly, though, at some point, you should learn the new approaches to error handling offered through the .NET Compact Framework.
Implementing VB-Style Error Handling
The easiest way to understand the VB style of error handling is through the examination of a sample. Listing E-1 shows the basic structure ofVB-style error handling.
Listing E-1. ImplementingVB-Style Error Handling
Private Sub Buttonl_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Buttonl.Click
Dim sw As System.IO.StreamWriter
' Enable error handling. On Error GoTo ErrorHandler
' Open the file. sw = New System.IO.StreamWriter("\Storage Card\text.tmp")
' Add some text to the file. sw.Write("This content was written at: ") sw.Writeline(DateTime.Now)
' Close the file. sw.Close()
' Jump over the error handler code. Exit Sub
942 Error Handling
ErrorHandler: Select Case Err.Number Case 76 ' Cannot access the CF card. MsgBox("Please insert the CF card into the device and tap OK.", _ MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly) Resume
Case 101 ' Another common error. Resume Next
Case Else ' Handle general purpose errors here. MsgBox("Number: " & Err.Number.ToString _ & " Description: " & Err.Description) End Select
End Sub
It all starts by enabling error handling, which is to say letting NETCF know that if any errors occur, you'll handle them. You accomplish this with the follow• ing statement:
On Error GoTo ErrorHandler
What this statement does is redirect the execution of code to the label ErrorHandler when a runtime error occurs. Usually, you'll find this statement near the top of a procedure, placed such that it will enable you to handle any and all errors that occur within the procedure. The label serves as a declaration point for your error handling code. It's located near the bottom of Listing E-1, in a common place for this type of code. You implement labels by including the name of the label followed by a colon. Now, I'd like to point out a key component to this style of error handling. It's what I refer to as the "error handler speed bump." This single line of code pre• vents your application from erroneously executing your error handling code. You place the speed bump directly above the start of your error handler as shown in Listing E-1. Its comprised of a simple statement, either Exit Sub or Exit Function. It's sole purpose is to exit the routine in which it's placed, skipping past your error handling code. Trapping errors is only half of the problem. Handling errors is the other half. At the bottom of Listing E-1 is the code that handles errors. Typically, this will be a Select Case statement, with a set of individual Case statements handling all of the errors you anticipate encountering.
943 Appendix£
The Select Case statement evaluates the Number property of the Err object. This property holds the number of the last error that occurred. Note the inclu• sion of the Case Else branch with this statement. To handle errors that you might not have anticipated, it's always good practice to include a fail-safe branch in the form of a Case Else statement.
The Err Object
At the heart of this legacy form of error handling is the Err object. This object provides access to details on the last runtime error that occurred within your application. Table E-llists the key properties of this object.
Table E-1. Key Properties of the Err Object PROPERTY DESCRIPTION Description The description of the error Number The error number of the error Source The source of the last error
'" · 1 ' TIP The easiest way to determine runtime error numbers encoun• tered by your application is to add a simple error handler with ONLY a Case Else branch. Within this branch, display the Number and Description properties of the Err object.
There are two key methods of the Err object: Raise and Clear. The Raise method is useful in generating a runtime error within your application, such as from within a custom control, with the purpose of passing the error back to the hosting application. The Clear method resets the Err object and is most useful in situations where you are using the On Error Resume Next form of error handling.
NOTE Use the Raise method within controls, components, and DLLs to force a runtime error to occur, which in tum passes back to the host program. For an example of using the Raise method in this fashion, see Chapter 5.
944 Error Handling Recovering from a Runtime Error
Within your error handling code, you'll need to define how to respond to various runtime errors encountered. Listing E-2 provides a simple example of the most commonly used options.
Listing E-2. Recovering from a Runtime Error
ErrorHandler: Select Case Err.Number Case 76 ' Cannot access the CF card. MsgBox("Please insert the CF card into the device and tap OK.", _ MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly) Resume
Case 101 ' Another common error. Resume Next
Case Else ' Handle general-purpose errors here. MsgBox("Number: " & Err.Number.ToString _ &" Description: " &Err.Description) End Select
In this example, two errors, numbers 76 and 101, have specific handlers. All other errors will fall into the Case Else branch of the Select statement. The error handling code for the 76 error includes the Resume statement. Error 101 has the Resume Next statement. These two statements differ in a subtle way. Executing a Resume statement causes your program to go back to the offending line, which is the line of code that originally caused the runtime error. Commonly you would use the Resume statement in situations where your error handling code resolves the root cause that generated the error in the first place. Take for example an application that stores its data on a CompactFlash (CF) card. If the CF card isn't in the device when the application attempts to open a file on that card, a runtime error will occur. All that you need to do to correct this runtime error is 1) instruct the user to insert the card back into the device, and 2) reexecute the offending line of code. In comparison, the Resume Next statement causes the execution within your program to resume at the line of code immediately following the line that generated the original runtime error.
945 Appendix£
CAUTION In general, you should do nothing within your error handling code that could potentially result in the generation of a runtime error. Handling such a situation is at best problematic. At its worst, it will result in the termination ofyour application.
The Try, Catch, Finally Statements
Now that we've looked at the legacy approach to error handling, let's look at the far more powerful, elegant, and flexible functionality provided through the .NET Compact Framework. The foundation of error, or exception handling, as it's referred to within the world of .NET, is implemented through the trio of Try, Catch, Finally statements. This combination of statements allows you to handle exceptions encountered while executing a body of code. Listing E-3 shows a simple example using these statements. At the top of the example is the Try component. Within the Try section, you would place your application's code. For example, you might be opening a database connection or establishing a connection to a Web service.
Listing E-3. The ny, Catch, Finally Statement
Try ' Implement some functionality. Catch ex as Exception ' Handle general exceptions. Finally ' Executed regardless of whether an exception occurred . End Try
The second part of this example is the Catch component. The code within this section executes when, and only when, an exception occurs. Your exception handling construct can include a single Catch statement or multiple Catch state• ments. When you define a Catch statement, you specify the type or category of exception that it handles. The example shown in Listing E-3 defines a single, general-purpose exception, ex. This argument contains information on the exception that occurred. The third part of the example is the Finally component. The code within this section executes all of the time, regardless of whether an exception occurs. You use this section to perform cleanup operations.
946 Error Handling Catching Exceptions
As I noted in the previous section, you use the Catch statement to handle excep• tions that occur. There can be one or more Catch statements as part of a Try, Catch, Finally structure. Having multiple Catch statements allows you to handle specific varieties of exceptions, where each type of exception may have details spe• cific to that exception. Listing E-4 provides an example of using multiple Catch statements. In this case, there are three Catch statements. The first Catch statement handles excep• tions related to the SqlCllent namespace. The second Catch statement addresses exceptions from the SqlServerCe namespace. The third Catch statement handles all other exceptions. This approach of using a single general-purpose Catch statement followed by a series of specific Catch statements is common to Try, Catch, Finally constructs.
Listing E-4. Multiple Catch Statements
Try ' Implement some functionality. Catch ex As SqlClient.SqlException ' Handle exceptions related to the SqlClient namespace. Catch ex As SqlServerCe.SqlCeException ' Handle exceptions related to the SQLCE Client. Catch ex As Exception ' Handle exceptions. Finally ' Executed regardless of whether an exception occurred. End Try
NOTE Matching and performing the code within a particular Catch statement terminates checking all remaining Catch state• ments. Because of this, you should place Catch statements in the order of 1) selectiveness, and 2) preferable execution.
TIP You should always include a general-purpose Catch statement as part ofyour error handling. While namespace-specific Catch statements are useful in isolating and handling exceptions, you need some way to handle those errors that you just don't think of
947 AppendixE Handling Exceptions
Catching an exception is only half of the solution. The other half involves identi• fying and possibly handling the root problem. This brings up a key point: Not all exceptions are terminal, nor for that matter unexpected. Take for example the following scenario: You've created an application for use in a warehouse. This application talks to an enterprise server via a wireless Ethernet connection to store data. The application is simple. It scans bar codes and sends the scan on to the server. As is often the case, the wireless coverage within the warehouse is less than complete. There are dead spots where the device can't connect to the network. When the device can't connect to the network, it obviously can't access the enterprise server, and can't store data. Is this a fatal error? Yes. Is it an application ender? No. You know that there are dead spots in your network. You also know that the user has to scan in these areas, so you had better handle these situations. That's where Catch statements come in. They allow you to 1) identify when an exception occurs, 2) determine what the exception is, and 3) respond in an appropriate manner. To identify the occurrence of an exception, you specify an exception condi• tion with a Catch statement. There are two ways to determine the exception. The first way· is to have a Catch statement that checks for a specific type of exception. listing E-5 shows an example of this. In this example, a Catch handles the FneNotFoundExcepdon, which occurs, as you might expect, when a file that your application attempted to reference isn't found.
Listing E-5. Checking for a Specific Exception
Try ' Implement some functionality. Catch fileNotFound As System.IO.FileNotFoundException ' Handle exceptions related to a missing file. Catch ex As Exception ' Handle exceptions. Finally ' Executed regardless of whether an exception occurred. End Try
This is a perfect example of handling a specific type of exception through the Catch statement. The second way to determine what exception occurred is through the argu• ment provided by the Catch statement. The Message property of the exception is a good place to start because it defines the exception. listing E-6 shows an example of displaying the Message property.
948 Error Handling
Listing E-6. Displaying the Message Property ofan Exception
Try ' Implement some functionality. Catch ex As Exception ' Handle exceptions . Dim mb As MessageBox mb.Shaw{ex.Message) Finally ' Executed regardless of whether an exception occurred. End Try
TIP Whenever possible, find ways to not code Finally statements. You'll find that by doing so you get into the habit ofcleaning up your objects.
How you respond to an error depends on your application's needs. On the simple end of the scale, you may just display an error message. You know, one of those "something real bad has happened, so call someone who cares" deals. On the more robust end of the scale, you may perform any number of activi• ties to guarantee that you deliver the data gathered through your application. In our wireless scenario, that could involve queuing data up in a local SQL Server CE database, placing it in an XML file, or dropping it into Microsoft's message queue (MSMQ). Remember, as with the error handling techniques used with Visual Basic and eMbedded Visual Basic, it's possible within the Catch statement to gracefully handle and correct the root cause of exceptions. The more complete you can make the exception handling and recovery, the more likely your application will be successful. This isn't an area of development where you should scrimp.
Creating an Exception "Safety Net"
Whether you're using the old style ofVisual Basic error handling, or the new excep• tion handling functionality provided through the .NET Compact Framework, any unhandled runtime errors have the same effect-they terminate your application. If I may state the obvious, having your application come to an abrupt halt is never a good thing. Having it crash with some obscure message is even worse. You can rectify this problem with a few lines of simple code, creating what I like to refer to as a "safety net" for your application.
949 AppendixE
To be able to handle runtime errors appropriately, it's important that you have a solid understanding of what happens within your application when an error occurs. Applications built upon the .NET Compact Framework handle errors in the following manner. First, they look for an error handler within the procedure where the error occurs. If either that procedure has the legacy-style On Error Go To statement or the new 'Ii'y, Catch, Finally statements, control passes to that code. If error handling code doesn't exist, then control is passed to the calling routine, which is the routine that called the procedure in which the runtime error occurred. This process continues until either error handling code is found or the top of the calling chain is reached. In the event that there's no error han• dling code found, an unhandled exception message is generated, and your application terminates. Providing a "safety net" for your application is simple. All that you need to do is add a few lines of code into the Main subprocedure, which is responsible for controlling the launch of your application. Many of you may not be familiar with this procedure. It's added automatically to Pocket PC projects, existing with the Windows Form Designer-generated code region of a form. By default, the Main subprocedure appears as shown in the following code snippet:
Public Shared Sub Main() Application.Run(New Forml()) End Sub
Adding a "safety net" to this procedure requires only a few lines of code as shown in Listing E-7. A 'Ii'y, Catch construct handles any errors that may bubble up to this level, keeping your application from ending in an uncontrolled fash• ion. Note, in this example, I'm still halting the application. I'm just providing a more descriptive error message, something that hopefully will help in the process of determining what went wrong within the application.
Listing E-7. An Application-Wide Exception Handler
Public Shared Sub Main() Try Application.Run(New Forml()) Catch ex As Exception MessageBox.Show("An fatal error occurred. Please contact tech support " & "and provide them with this information: " &ControlChars.Crlf &_ ex.Message.ToString &ControlChars.Crlf &"Application is terminating." Application.Exit() End Try End Sub 950 E"or Handling Obtaining Detailed Error Information
In order to keep the .NET Compact Framework as compact as possible, Microsoft moved error strings to a separate DU.. This DU., System.SR, is by default not configured as part of new NETCF projects. You'll need to add a refer• ence to your project. If this DU. isn't present on the target device, all exceptions will contain the message "Cannot load resource assembly." Obviously, this is less than helpful as part of a debugging process. Microsoft's idea here is to allow you to add the System.SR DU. during your testing process and exclude it when you distribute your application, saving the space required by the DU..
Tracking Exceptions
Developing mobile applications presents developers with a completely new set of problems to overcome, including how to handle errors that occur when the user is in the field. By "in the field," I mean anywhere away from the office. They might literally be in a field avoiding muck, or they could be on a delivery route in a truck. Maybe they're at a customer's site or in their hotel room at night, in the user's car or showing off tech toys at the bar. What happens when they encounter a problem? It isn't likely they can walk down the hallway and talk to you, or for that matter can you get up from your desk and walk to them. You might not know when an error occurred, for what reason it occurred, or how your application responded. At best, users might tell you at a later date and time that "something went wrong." On questioning users, they will probably give the typical responses of "I don't know what I was doing" (or the ever more popu• lar "I wasn't doing anything"), followed up by "I don't remember what happened next." Ah, just the detailed information you need to successfully debug an appli• cation. And you wonder why they don't let tech support personnel carry sidearms. . How you handle the problem is one thing. How you find out that exceptions did, in fact, occur is something completely different. When designing an application, I like to build in some type of exception log. This log records exceptions when they occur. It doesn't need to be anything fancy. A simple log with date-stamped records will suffice. It can be nothing more than a comma-separated text file. I like to include the exception, the source, and any other pertinent information. Periodically you'll need to upload this log to a server for processing. This can be incorporated into your data syn• chronization process. It doesn't take much work to create a general-purpose routine that imple• ments this type of functionality. You can use this routine with all of your applications. Listing E-8 demonstrates a simple audit trail function, LogError.
951 Appendix£
This function accepts as arguments the path to the audit trail file, the exception/ error message, the source of the error (which I commonly use to store the offending procedure's name), and any additional comments that you might have.
Listing E-8. The AuditTrail Class
Public Class AuditTrail
Function LogError(ByVal LogFile As String, ByVal Message As String, _ ByVal Source As String, ByVal Comments As String) As Boolean Dim strlogRecord As String Dim sw As System.IO.StreamWriter
Try
' Open the log. sw = New System.IO.StreamWriter(LogFile, True)
' Add the item to the log. strlogRecord = Now. ToString & "I" & Message & "I" & Source & "I" & Comments & "I" sw.Writeline(strlogRecord)
' Close the log. sw.Close()
' Return a positive result. LogError = True
' A runtime error was generated. Return a negative result. Catch LogError = False
End Try
End Function End Class
New entries append at the bottom of any existing entries, just as you would expect from an audit trail. To accomplish this, you must open the log file in append mode.
NOTE For more on working with simple text files, refer to Chapter B.
952 Error Handling
Arguments that comprise an entry are separated with pipe ( I ) characters, instead of the more commonly used comma-separated approach. This allows you to use commas within log file output. Figure E-1 shows the contents of the log file after running this sample application.
1212312002 10:09:32 AMIA test error.lbtnlogError_Ciickltesting log file ... l
Figure E-1. The contents of the audit trail
NOTE Make sure that you periodically purge or delete your audit trail. If not, it may cause memory use problems down the road.
Usting E-9 shows the Cllck event routine used to test the audit trail routine. A Throw statement triggers the exception, which in turn results in the Catch statement executing.
Listing E-9. Testing the AuditTrail Class
Private Sub btnLogError_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnLogError.Click Dim at As New AuditTrail
' Generate an exception for testing purposes. Try Throw New System.Exception("A test error.")
' Handle the exception by writing an entry to the log. Catch ex As Exception If Not (at.LogError("\My Documents\audit trail.log", _ ex.Message.ToString, _ "btnlogError_Click", _ "testing log file ••• ")) Then MsgBox ("Could not write to the audit log.", MsgBoxStyle.Exclamation) End If
End Try
End Sub 953 Appendix£
NOTE The examples in this section are from the Audit Trail proj• ect, which is included under Appendix E in the Samples folder.
Causing Exceptions to Occur
At initial glance, this t.opic may seem to be counterproductive to the rest of this chapter. After all, we've been focusing our efforts on controlling and limiting errors. Suddenly, I'm talking about purposefully causing exceptions. Bear with me. There are good, practical programming reasons for triggering exceptions. Commonly, you'll find this technique used within components designed for use within other applications. I'm using the word components here in a fairly broad fashion. By components, I mean controls, class modules, DLLs, or any other self-contained programming nugget. The key point here is that you use these components within another appli• cation, which might be your own application or someone else's. Since these components are just a part of another application, you most likely will want to pass runtime errors and exceptions onto the host application for processing. There are two common ways of accomplishing this: using either the Raise method of the Err object or the Throw statement.
Triggering a Runtime Error Using the Err Object
The Visual Basic approach to triggering a runtime error is through the Raise method of the Err object. The syntax for this method is
Err.Raise(number, source, description, helpfile, helpcontent)
Table E-2 describes each of these parameters in further detail.
954 E"or Handling
Table E-2. Raise Method Parameters PARAMETER DESCRIPTION Number An integer value between 0 and 65535. The range between 0 and 512 is reserved; this will be accessible to the developer through Err.Number. Source Defines the source of the error; I like to set this to a combination of the control and property names; this will be accessible to the developer through Err.Source.
Description The description of the error; this will be accessible to the developer through Err.Description. Help File Path to a help file that provides additional information on this error; this parameter is of no use with mobile applications. HelpContent Context ID that defines a topic within the help file; this parameter is of no use with mobile applications.
Following is an example of calling the Raise method:
Err.Raise(vbObjectError + 1234, "scheduler.rating", _ "An invalid property value was provided")
Triggering an Exception with the Throw Statement
The .NET Compact Framework equivalent of the Err object's Raise method is the Throw statement. The syntax for this statement is
Throw expression
The single part required by the Throw statement, expression, provides infor• mation on the expression to throw. Following is an example of the Throw statement. In this example, I'm caus• ing a custom error to occur. I could just as easily trigger a specific error.
Throw New System.Exception("A test error.")
955 AppendixE Summary
Whether you call it error or exception handling, whether you use legacy Visual Basic or new .NET Compact Framework approaches, it's paramount that you include robust error management within your mobile applications. I happen to think that it's even more important than with desktop applications, due to the combination of the complexity of the mobile environment and the fact that the mobile user frequently is without ready access to the help desk. Regardless of whether you're using the VB or the NETCF approach to error handling, it's important that you make error handling a part of your design and development process right from the start. It's only then that you'll have effective error handling that integrates itself seamlessly into your applications.
956 APPENDIX F Custom Controls 1n• C#
CHAPTER 7 PRESENTED A TUTORIAL that built a custom button using Visual Basic code. The only problem with VB, as we discussed then, is that you can't create a design-time control that can be dropped on your form. The problem? Both the VB and C# compilers generate warnings when you compile the code for design mode. The difference is that C# ignores the warnings and Visual basic treats them as errors. This problem means that if you stick with Visual Basic, you can't build a design-time component for your custom controls. This appendix will show you how to create a C# button control, identical to the one in Chapter 7, and also how to build a design-time component. To make the comparison with Chapter 7 as obvious as possible, I'll walk you through the same steps that you did in Chapter 7. But instead of adding VB code, you'll add C# code in the project. In addition to the originall2 steps, you'll perform a few more steps that will add extra code to make the design• time component. Once completed, I'll walk you through the command line compile that you need to do to create the control.
Step-by-Step Tutorial: Creating a New Button
In this tutorial, you'll create a new Command Button control that has rounded edges and a colored button surface. This control will have multiple properties related to its visual appearance, (e.g., colors, enabled state, etc.), and will also handle various events. This tutorial will not go into detail about portions of con• trol development that were covered in Chapter 5. Any new features of control development will be covered, but this tutorial is meant to be strictly a graphics tutorial.
Step 1: Starting a New Project
In practice, you would want to create a separate project for your control and a project to test the control. So, to keep this tutorial as realistic as possible, you'll develop two separate projects. Begin this step-by-step exercise by creating a new project using the following steps:
957 AppendixF
1. Start Visual Studio .NET if necessary.
2. From the Start Page, select New Project.
3. From the New Project dialog box, select Smart Device Application.
4. Specify the project name RoundButton Demo.
5. Select a location to create the project
6. Select the project type Class library and click the OK button
Step 2: Adding References
To configure the target output folder for your project, perform the following steps:
1. In the Solution Explorer, right -click References and click Add Reference.
2. Select System.Drawing from the Component Name column and then click the Select button.
3. Select System.Windows.Forms from the Component Name column and then click the Select button.
4. Click the OK button.
Step 3: Configuring the Project
Because you created your project as a class library, only a small subset of refer• ences were added by the wizard. To add the references to your project, perform the following steps:
1. Under the Project menu, select RoundButton Properties.
2. Under the Device page of the Text File Property Pages dialog box, set the output file folder to \Wlndows\Start Menu\Programs\Apress.
Step 4: Naming Your Control Class
To change the control's name from Classl.cs to RoundButton.cs, perform the fol• lowing steps: 958 Custom Controls in C#
1. Click the filename Classl.cs in the Solution Explorer.
2. Change the filename in the Properties window to RoundButton.cs.
3. Open the RoundButton Class module.
Step s: Inheriting the Control Class
The RoundButton control is based upon the Control class. You accomplish this by adding a single line of code to your Class module. Perform the following steps to add the line of code to inherit the Control class:
1. Open the RoundButton Class module.
2. Insert : System.Wlndows.Forms.Control in the Class module as shown:
public class RoundButton : System.Windows . Forms .Control { }
Step 6: Creating Class-Level Variables
You need variables to hold the enabled and disabled color of the button. You also need to track the button state as either up or pressed. (You'll see why later.) Add the declarations to the editor so that your code appears as shown: public class RoundButton : System.Windows.Forms.Control, !Disposable { bool _buttonDrawnDown = false; Color _btnColor = Color . LightGreen; Color _btnDisabledColor = Color.DarkGreen; }
NOTE There is no step telling you to add the using statements (analogous to the Imprts statement in VB) at the beginning of the file, so I'll remind you here. Be sure to add imports for System, System.Drawing, and System. Windows.Forms.
959 AppendixF Step 7: Adding the OnPaint Event
You need to draw the control in several other locations rather than just in the OnPaint event. Keeping that in mind, you have a very small and simple event to code. Perform the following steps to add this procedure:
1. Open the RoundButton Class module.
2. Add the following code to the Class module:
protected override void OnPaint(PaintEventArgs e) { DrawButton(e.Graphics, this.ForeColor, _btnColor); base.OnPaint (e); }
This procedure calls out to your DrawButton routine, which we'll get to shortly. In the meantime, notice that you are passing three arguments to the method. The first is a Graphics object that you pull from the PaintEventArgs parameter. The second argument is the control's own foreground color. Since you are deriving it from Control, you can use the control's existing colors, among other properties, by referencing your base class through the Me keyword.
Step 8: Creating Your DrawButton Method
You need to draw the control in several other locations rather than just in the OnPaint event. Keeping that in mind, you have another very small and simple event to code. Perform the following steps to add this procedure:
1. Open the RoundButton Class module.
2. Add the code in Listing F-1 to the Class module.
Listing F-1. Custom Drawing Your Own Button
public void DrawButton(Graphics g, Color foreColor, Color backColor) { II Use the button height as the diameter of the round end. int bRadius = this.ClientRectangle.Height I 2; int aTop = this.ClientRectangle.Top; int aleft = this.ClientRectangle.Left; int aWidth = this.ClientRectangle.Width; int aHeight = this.ClientRectangle.Height; 960 Custom Controls in C#
Brush sb = null; Font fnt = null; Try { if( this.Enabled ) sb = new SolidBrush(_btnColor); else sb = new SolidBrush(_btnDisabledColor);
g.FillEllipse(sb, aleft, aTop, 2 * bRadius, 2 * bRadius); g.FillRectangle(sb, aleft + bRadius, aTop, aWidth - (2 * bRadius), aHeight); g.FillEllipse(sb, aWidth - (2*bRadius), aTop, 2*bRadius, 2*bRadius);
II Now write the text to the button face. fnt = new Font(this.Font.Name, this.Font.Size, this.Font.Style);
SizeF siz = g.MeasureString(this.Text, fnt); g.DrawString(this.Text, fnt, new SolidBrush(foreColor), _ (aWidth - siz.Width)l2, (aHeight-siz.Height)l2); } catch { } finally { fnt. Dispose(); sb.Dispose(); } }
Step 9: Adding the OnEnabledChanged Event
The basic button is now done and will work. However, you want it do more than just sit there. If the user changes the state of the button, you need to force the button to change its color appropriately. Perform the following steps to add this procedure:
1. Open the RoundButton Class module.
2. Add the following code to the Class module:
961 AppendixF
protected override void OnEnabledChanged{EventArgs e) { Graphics g = this.CreateGraphics(); Try { DrawButton(g, this.ForeColor, _btnColor); } catch { } finally { g.Dispose(); base.OnEnabledChanged{e); } }
The OnEnabledCbanged event is raised when the Enabled property of the control is changed. This can occur from code or at design time. You don't have a Graphics object passed to you in this method, so you need to create your own~ Your form has a CreateGrapbics method that you use to get a current Graphics object. Remember, you need to dispose of the object when you are done. Just like your mother always told you, "Clean up after yourself!"
Step 10: Handling More Events
Since this is a graphics tutorial, we'll skip the explanation of some of the work in adding multiple events. What is important here is that you see how you need to force a redraw of the button face again after the mouse has touched or released. Again, let me emphasize the fact that you need to create a Graphics object, pass it to the draw routine, and then dispose of it. It's also important to call the base class's OnMouseUp and OnMouseDown events to let the base control do its pro• cessing. Add the following code to the RoundButton Class module:
protected override void OnMouseDown(MouseEventArgs e) { Graphics g; try { g = this.CreateGraphics(); DrawButton(g, Color.White, Color.Black); buttonDrawnDown = true; } catch 962 Custom Controls in C#
{ } finally { g.Dispose(); base.OnMouseDown(e); } } protected override void OnMouseUp(MouseEventArgs e) { Graphics g; try { g = this.CreateGraphics(); DrawButton(g, this.ForeColor, _btnColor); buttonDrawnDown = false; } catch { } finally { g.Dispose(); base.OnMouseUp(e); } }
Step 11: Adding Two Simple Properties
You need two properties to set the button face color when it's enabled and dis• abled. Add the following code to the RoundButton Class module: public Color ButtonColor { get { return _btnColor; } set { _btnColor = value; } } 963 AppendixF
public Color DisabledButtonColor { get { return _btnDisabledColor; } set { _btnDisabledColor = value; } }
NOTE Having this property return a Color object has a very nice side effect. When this control is selected on the form, the ButtonColor property in the Properties window will display the color palette, the same as any standard .NEI' control does when selected. All without writing any code-cool huh?
Step 12: Moving the Stylus Off of the Button
When the stylus touches the button and is then "rolled" off the button face, the button needs to revert to its normal color state. It then needs to be painted back to its depressed state when the stylus again moves over the button. That takes some fancy code, which you can add now to the RoundButton Class module:
protected override void OnMouseMove(MouseEventArgs e) { try { if( e.Button == MouseButtons . Left ) { if( (e.X < this.ClientRectangle.Top I I e.X > this.ClientRectangle.Width) I I (e.Y < this.ClientRectangle.Top I I e.Y > this.ClientRectangle.Height) ) { if( buttonDrawnDown ) { Graphics g = this.CreateGraphics(); DrawButton(g, this.ForeColor, _btnColor);
964 Custom Controls in C#
g.Dispose(); buttonDrawnDown = false; } } else { II Moving inside the button if( !buttonDrawnDown ) { Graphics g = this.CreateGraphics(); DrawButton(g, this.ForeColor, Color.Black); g.Dispose(); buttonDrawnDown = true; } } } base.OnMouseMove(e); } catch { } }
Updating the Code for Design Time
You need to perform two extra steps to take this control and make a design-time component. First, the code needs to include an attribute that, when compiled, will mark your class as a control that can be added to the toolbar in the IDE. The first attribute you'll add is the one that gives your control a name. The following code snippet should be added to the source code just before the class definition:
#if NETCFDESIGNTIME [assembly: System.CF.Design.RuntimeAssemblyAttribute("RoundButton, Version=0.90, Culture=neutral, PublicKeyToken=null")] #endif public class RoundButton System.Windows.Forms.Control { }
That takes care of signing your control and letting the runtime know that this is an assembly that is to be used at design time. The RuntimeAssemblyAttribute also lets you specify the version of the assembly along with setting the assembly's
965 AppendixF
culture and a public key. This attribute is exclusive to NETCF, taking the fully qualified name of the runtime assembly. This example will not be using the Culture or PublicKeyToken fields of the attribute. The import fields are the name and the version. Now, what would a design-time control be without some properties that you can set during design? To mark the properties that you're going to expose through the Properties window, make the following additions to your code. Before the ButtonColor property, add the following attribute:
#if NETCFDESIGNTIME [ System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The color for the Button face when Enabled") ] #end if
Before the Disabled property, add the following attribute:
#if NETCFDESIGNTIME [ System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The color for the Button face when Disabled ") ] #end if
Building Your New Control
Along with the attributes that you added, you also added a preprocessor variable with each attribute. The NETCFDESIGNI'IME variable is set to true when you are building the design-time control so that the attributes aren't included in your runtime version of the control. This allows you to use the same code to generate two distinctly different controls. The build step must accomplish three major objectives. First, your script should build the runtime version of your control. You'll see a little later why this is important. Second, the script must build the design-time component, and third, it must copy the newly built design control to the designer reference path so that .NET can find it. If you've never written a batch file or done any com• mand line compiling, this build script may be a little daunting, but never fear. It's designed so that all you need to do to make this script work for any new control you write in the future is to change four of the first six lines to use the name of the new control being built. As the old saying goes, "How do you eat an ele• phant? One bite at a time." So let's take the first bite of this build script.
966 Custom Controls in C#
Before anything else is done, the script sets five variables. The first is a name for the control. In the following portion of the script, the control is named Apress.RoundButton.dll.
@ECHO OFF CLS SET BLDCTRL_DLL=Apress.RoundButton.dll SET BLDCTRL_SRC=RoundButton.cs SET BLDCTRL_ASM=Assemblyinfo.cs SET BLDCTRL_SLN=RoundButton.sln SET BLDCTRL_PFX=Designer
ECHO Batch Build for .NETCF Designer Controls ECHO. ECHO ------• ECHO Round Button Example ECHO The Definitive Guide to the .NET Compact Framework ECHO Apress, 2003 ECHO Dan Fergus and Larry Roof ECHO ------ECHO.
The next three variables are set to tell the script what files are to be com• piled. BillCTRL_PRX is a designation that is prefixed to the name of the control to signify that it's a design-time control. The next series of script lines are output lines that dump information to the console window during the build.
NOTE While I'm the one showing this batch file now, the original version was included as a sample that ships with Visual Studio .NET. This version has been modified a little from the original. You can also find all of the C# code, titled RoundButton, along with the batch file, in the Appendix F folder of the Samples folder for this book. See Appendix D for more information on accessing and load• ing the sample applications.
This build script must be run from a particular command prompt that has all of the paths set correctly for the compiler to run and find the required files. You can find this command prompt from the Start Menu by selecting Microsoft Visual Studio .NET 2003 and Visual Studio .NET Tools. The script file verifies this before doing the compiling.
967 AppendixF
IF "%VSINSTALLDIR%"=="" GOTO NoVSEnv SET NETCFDIR=%VSINSTALLDIR%\ .. \ .. \CompactFrameWorkSDK\v1.0.SOOO\Windows CE\
The NETCFDIR variable is the location to which the controls will be copied. Now it's time to build the controls. Your script will build the design-time version of the control.
ECHO. ECHO [BUILDING %BLDCTRL_PFX%.%BLDCTRL_DLL% from %BLDCTRL_SRC%] esc /noconfig /define:NETCFDESIGNTIME /target:library /out:%BLDCTRL - PFX%.%BLDCTRL - DLL% %BLDCTRL - SRC% %BLDCTRL - ASM% /r:"%NETCFDIR%Designer\System.CF.Design.dll" /r:"%NETCFDIR%Designer\System.CF.Windows.Forms.dll" /r:"%NETCFDIR%Designer\System.CF.Drawing.dll" /r:System.Windows.Forms.dll /r:System.dll /r:System.data.dll /nowarn:1595
ECHO. ECHO [COPYING %BLDCTRL_PFX%.%BLDCTRL_DLL%] COPY "%BLDCTRL_PFX%.%BLDCTRL_DLL%" "%NETCFDIR%Designer\" IF EXIST ".\%BLDCTRL_PFX%.%BLDCTRL_DLL%" DEL ".\%BLDCTRL - PFX%.%BLDCTRL - DLL%"
Command line compiling can look rather complex, especially with the variable names being used in this code. The C# compiler, esc, defines the NETCFDESIGNTIME variable so that the code, when compiled, includes the attributes, thus making it a design-time control. The output name is built by joining the various variables that were defined in the first part of the script. After this, the required references are specified. Note that the references aren't the standard references that you would specify in a project. They are all system assemblies targeted exclusively at building design-time controls. When you build a project in the IDE, the references are added to the com• piler command line without your being aware of it. But when you build using the command line compiler, you must be sure to specify all required references. The most inconspicuous portion of the compiler command line, and the most important, is /nowarn:l595. This is why Visual Basic can't build design• time controls. The C# compiler can simply ignore this warning, but the Visual Basic compiler can't. The VB compiler sees this as an error and therefore can't build the control. Once built, the design-time control is copied to the designer folder in the CF directory, and the local file is deleted.
968 Custom Controls in C#
The next step is to build the runtime version of the control. The command line for this is very similar to that of the design-time control. The name of the control doesn't have the prefix added to it, and the NETCFDESIGNTIME variable isn't defined. The big difference is the references. Note that there are a larger number of references and that they are the ones you should be used to seeing from adding them in the Visual Studio IDE.
ECHO. ECHO [BUILDING %BLDCTRL_DLL% from %BLDCTRL_SRC%] esc /noconfig /target:library /out:%BLDCTRL_DLL% %BLDCTRL_SRC% %BLDCTRL_ASM% /r: "%NETCFDIR%mscorlib. dll" /r:"%NETCFDIR%System.dll" /r:"%NETCFDIR%System.XML.dll" /r:"%NETCFDIR%System.Data.dll" /r:"%NETCFDIR%System.Drawing.dll" /r:"%NETCFDIR%System.Windows.Forms.dll" /r:"%NETCFDIR%Designer\System.CF.Design.dll" /r: "%NETCFDIR%Designer\System. CF .Windows. Forms. dll" /r:"%NETCFDIR%Designer\System.CF.Drawing.dll" /nowarn:1595
ECHO. ECHO [COPYING %BLDCTRL_DLL%] COPY "%BLDCTRL_DLL%" "%NETCFDIR%" IF EXIST ".\%BLDCTRL_DLL%" DEL ".\%BLDCTRL_DLL%" ECHO.
Once the control has been built, it's copied to the control's directory under the NETCF folder tree and the local copy deleted. You now have two new assem• blies, one for design-time use and one for runtime use. It's time to test these controls.
Using the Batch File
There is a trick (isn't there always) to making the development and debugging of the control work smoothly. Instead of opening Visual Studio and pointing to a project or solution, this trick takes. a slightly different approach. Open a Visual Studio command prompt and navigate to the folder containing the control's code. From this command window, run the batch file. To work with the code, start Visual Studio by either typing start roundbutton.sln or by typing round• button.sln. When changes have been made and you want to rebuild the
969 AppendixF
design-time control, close the IDE and run the batch file. To debug and test, start the IDE backup and run the code. The reason behind this approach is simple: When your design-time control is loaded in the Toolbox, Visual Studio has a reference to it so you can't copy the DLL over to the design control's folder. Closing the IDE and then running the build file makes everything work fine. It's time for the last step, testing the design-time control.
Step 13: Testing the Paint Job
Create a new Smart Device Extensions Wmdows Application. Move your mouse over the Toolbox and click the right mouse button. You should see the context menu shown in Figure F-1.
0 UstView &dd Tab 2how All Tabs
~ cV>; !Jp
Move Do~n
Figure F-1. Adding an item to the Toolbox
Choose the Add/Remove Items menu item. In the Customize Toolbox dialog box, click the Browse button to locate and add the control. You can refresh your memory about where the file is located by looking back at the batch file descrip• tion. Once you select your control, notice in the dialog box that your control has a checked box next to it, as you can see in Figure F-2.
970 Custom Controls in C#
' Customize Toolbox [~]'
.NET Framework Components ICOM Components I
r.N=a~me~------~~~~~------~~~~~------~ 0 ReportCiass CrystaiDecisions, CrystaiReports •••• CrystaiDecisions .CrystaiReports. Engine ~ ReportDocument CrystaiDecisions, CrystaiReports ••• . CrystaiDecisions.CrystaiReports .Englne 0 ReportDocument CrystaiDecisions. CrystaiReports •... CrystaiDecisions.CrystalReports.Engine 0 ReportServiceBase CrystaiDecislons, Web. Services CrystaiDecisions .Web (9.1.5000.0) ~ RequiredFieldl/alidator System. Web.UI.MobileControls System .Web .Mobile (1.0.5000.0) ~ Requiredfieldl/a!idator System. Web .UI. WebControls System .Web (1.0.5000.0) ~R i ch TextBox System. Windows .Forms System. Windows.Forms (1 .0.5000.0) 13 RoundButton Apres$.1N1ndows.Controls Des1gnet APress.Round8utton (1.0.1. 13 RoundButton ForestSoftwareGroup. Windows. , . , Designer. FSG. RoundButton (1. 0. 1104.: 13 SaveFileDialog System. Windows .Forms ~ys~em . :~. ~indo~s . For~s _(7~~:~0~.0 . 1 ~ ~======~======-=-=-=-=--~~~~ ~
Browse .. . {!) Language: Invariant Language (Invariant Country) Version: 1.0.1.39468 (Retail)
OK Cancel Reset Help
Figure F-2. Finding your control to add
Click the OK button, and you'll be able to see your control listed in the Toolbox.
NOTE Don't be disturbed if the Toolbox has your control disabled. It will not show as enabled until you have a form open in the designer.
When you open the default form in the project, double-click your control in the Toolbox, just as you would with a real control, to add it to your form. Your design-time control will magically appear on the form's designer sudace. You can double-click the button to add an event handler for the button click. Add the fol• lowing code to the form: private void roundButton2_Click_l(object sender, System.EventArgs e) { MessageBox.Show("Button Pressed"); }
Run the test project, and you should see the message box shown in Figure F-3.
971 AppendixF
[!J' Forml ~E 4:34
Button Pressed
Figure F-3. Viewing your new control on the form surface
Summary
While the procedure described in this appendix by no means results in a com• plete, production-ready control, it does show you the basics of creating both a runtime and a design-time control using C# and the .NET Compact Framework. Writing a C# application isn't that much different from writing Visual Basic .NET application. Ifyou don't want to learn, you can probably find someone to help you with writing the C# code. As you work with VB controls on a form, without having the design component, you'll find how difficult it can be to lay out a form and make it work at runtime. Maybe the VB compiler will get an upgrade in a future version of .NET, but until then, you might want to consider creating a design-time component-how you decide to do it is up to you.
972 Index
A DataSet class, 392-403 clearing DataSets, 395 AcceptSocketnrrethod,598 DataSets, populating, 393-395 Access DataSets, refreshing. 395 Microsoft, 507 DataSets, saving, 396 Pocket, 22 DataTable class, 398-403 access,anonyrnous,465-466 DataSets, obtaining list of DataTables in, ActiveSync 400-401 download,908 DataTable colunrrns, obtaining list of, installing, 908 401 installing applications and, 864 DataTables, accessing data within, partnership, setting up, 918-919 402-403 version 3.5, 578 DataTables, populating, 400 ActiveThreads variable, 594 DataTables, searching, 403 Add nrrethod (ConrrboBox control), 143 DataView class, 407-409 Add Web Reference dialog box, 654 Systenrr.Data nanrrespace, 374-376 AddReg section syntax (Defaultlnstall), tutorial, Working with ADO.NET, 409-421 847-848 displaying data, 416-418 AddRow nrrethod, 404 interface, 410-412 ADOCE .NET Wrapper, 453, 933 preconfigured settings, 412-413 ADO.NET, 373-422 project, opening, 409-410 ADO.NET and ADO Exanlple and Best SQL Server CE, retrieving data fronrr, Practices for VB Progran1n1ers 414-415 (Apress), 499 SQL Server, retrieving data fron1, ADO.NET, Working with (code listing), 413-414 23-24 testing application, 419-421 Con1n1and classes, 383-387 XML files, retrieving data fron1, 415-416 SQL Server CE, executing con1n1ands XML files, saving data to, 418-419 against, 386--387 Agents, SQL CE, 455, 468 SQL Server, executing con1n1ands anonymous access, 465--466 against, 384-385 API calls SqlCeCon1n1and class, 385-386 Notification API Call, Setting Up for (code SqlCon1n1and class, 383-384 listing), 725 Connection classes, 380-382 Notification API, Calling (code listing), SQL Server CE, opening connection to, 725-726 382 Registry API Calls, Declarations for (code SQL Server, opening connection to, 381 listing), 705-706 SqlCeConnection class, 381-382 APis, enhanced support for, 25 SqlConnection class, 380 application settings, 809--826 data providers, 376--379 Base Interface class, 810-811 SQL Server CE provider, 377-379 GetPrivateProfile nrrethods, 810 SQL Server provider, 376--377 INI file settings, 812~18 DataAdapter classes, 389--392 interfaces, basing classes on, 810 SqlCeDataAdapter class, 391-392 registry settings, 824-826 SqlDataAdapter class, 390-391 SettingSupport class, 811 DataColunrrn class, 405-407 UserSettings class, 809 colunrrns, adding to DataTables, 407 XML file settings, 81H23 colunrrns, listing within DataTables, 406 XML settings file, reading fron1, 819--821 DataReader classes, 387-392 XML settings file, writing to, 821~23 SqlCeDataReader class, 388-389 applications SqlDataReader class, 387-388 adding code to, 54-55 DataRow class, 404-405 adding help to, 803 rows,nrro~g.405 Application Information, Getting (code rows, viewing contents of, 405 listing), 811 tables, adding rows to, 404-405 973 Index
Application Manager architecture launching, 834-835 help system, 789-790 monitoring, 864 RDA,523 Application Manager INI file replication, 539 creating, 863 SQL Server CE, 455-456 Format of (code listing), 833-834 arguments, optional not allowed (VB .NET}, Application XML config File (code listing), 21 818 arrays ApplicationLocation function, adding, 447 Arrays, Returning from Web Methods creating setups for. See setups, creating (code listing), 657 deploying. See deploying applications passing from XML Web services, 657~58 installing, 830-836 Web Method, Calling One That Returns an from CompactFlash (CF) cards, 831-833 Array (code listing), 658 from desktop, 833-835 zero-bound arrays, 21 manually on device, 830 articles, defined, 4 72 from networks, 836 ASP.NET Web Service Template, Starter Code origin of installation, selecting, 830 Provided with (code listing), 648 sample applications, 937-939 assemblies, referencing, 9-10 shutdown, 81 asynchronous calls to XML Web services, testing. See testing applications 670-874 titles, displaying, 76 aborting, 67H74 Applied .NETAttributes (Apress, 2003}, 690 callbacks,672~73 AppName directive (INF file}, 841-842 polling,670-871 appointments, 769-776 asynchronous HTTP requests, 587-592 adding, 774-775, 781-782 Asynchronous Responses, Processing (code Appointments, Adding (code listing), listing). 589-590 774-775, 781-782 asynchronous TCP communication, 60~06 Appointments, Displaying (code listing), attributes 773-774, 780-781 Applied .NETAttributes (Apress, 2003), 690 Appointments, Modifying Existing (code Attributes, Creating Documents Using listing), 775-776 (code listing), 560-561 Appointments object, 769-770 Attributes, Looking at All Dynamically Appointments property, 769 (code listing), 559-560 Appointments, Retrieving All (code listing), Attributes, XML Document Using (code 771 listing), 556-557 Appointments, Retrieving for Specific building XML files with, 549 Dates (code listing), 772-773 Elements and Attributes, listing a Appointments, Retrieving list of All (code Document's (code listing), 557-558 listing), 779-780 reading in documents, 557 Appointments, Selecting Subset of (code using in XML documents, 556-563 listing), 782-783 writing to documents, 560-563 Appointments, Working with (tutorial), XML Document Using Attributes (code 776-784 listing), 549 adding an appointment, 781-782 Audit'Ii"ail Class displaying an appointment, 780-781 code listing, 952-953 imports statement, adding, 778 Testing (code listing), 953 loading all appointments, 779-780 authentication loading select appointments, 782-783 authenticating RDA with liS, 528 module-level objects, declaring, 779 Basic authentication, 465, 532, 644 project, opening, 776-777 choices (SQL Server CE}, 465-466 references, adding, 778 digest, 644 testing application, 783-784 Integrated Wmdows authentication, user interface, 777-778 465-466,532 displaying, 773-774 Auto Save Feature, Toggling (code listing), given dates, retrieving appointments for, 292 772-773 automatic deployment (SDE), 34 modifying, 775-776 AutoRun.exe retrieving all, 770-771 copying to CF card, 832 App.Path method, 553 creating, 831
974 Index
B records adding new, 448-449 base classes, 7 deleting. 449 base controls, defining, 200-203 moving between, 448 Base Interface Class (code listing), 810-811 references, adding, 445 Basic authentication, 465, 532, 644 testing application, 449-450 Basic Class Module (code listing), 200 user interface, 444 batch files Bound Forms, Validating (code listing), building custom controls and, 969-970 435-436 viewing generated, 859 breakpoints, defined, 61 Battery Information Build Cab File (SDE), 35 Calling the System for (code listing), 701 BuildAction property, 57 Declarations for Retrieving (code listing), buttons 697-699 Button control, 137-139 battery usage, timing, 94 Button Control Click Event, Coding (code BeginWrite and BeginRead methods, 606 listing), 139 Beyond Anonymous (tutorial), 528-538 Button, Creating New Command (tutorial), directory security, setting, 529 957-972 login account, creating, 529 building control, 966-970 security class-level variables, creating, 959 setting in liS, 530-532 control class, inheriting. 959 setting in SQL Server, 532-535 control class, naming, 958-959 SQL CE, working with, 535-537 DrawButton method, creating, 960-961 Transact-SQL (T-SQL), running on remote events, handling, 962-963 server, 537-538 moving stylus off button, 964-965 Binary File Demo, Building (tutorial), OnEnabledChanged event, adding. 366-371 961-962 coding applications, 368-370 OnPaint event, adding, 960 interface, building, 367-368 project, configuring, 958 project configuration, 366 project creation, 957-958 project creation, 366 properties,adding,963-964 testing applications, 370-371 references, adding. 958 binary serialization, 17 testing application, 970-972 BinaryReader and BinaryWriter classes, updating code for design time, 356-358 965-966 BinaryReader /BinaryWriter classes, 354-355 Button Taps BinaryWriter, Writing to Files Using (code Handling (code listing), 281 listing). 356 respondingto,280-281 binding Responding to (code listing), 294 binding controls, 446-447 ButtonClick event, 280-281, 294 Binding to a DataGrid (code listing), Buttons argument values (Show method), 429-430 121 Binding to a ListBox (code listing), 426-427 Buttons, Custom Drawing (code listing), Binding to a PictureBox (code listing), 310 430-432 Cancel Button, Configuring (code listing), Binding to Simple Controls (code listing), 126, 132 424--425 displaying MessageBox with, 120 Binding Two TextBox Controls (code Load button, coding, 363, 368-369 listing), 446-447 and menus, order of, 78 BindingContext objects, 441-442 New button, displaying, 77 data. See data binding positioning of dangerous, 90-92 bitmaps, defined, 297 properties,138 Bluetooth support, 8 Save button, coding, 364, 369-370 Bound Controls, Working with (tutorial), 443-450 Applicationlocation function, adding, 44 7 c binding the controls, 446-447 C# .NET language. See also custom controls, database, adding, 444-445 inC#, 34, 247, 490 edits, canceling. 449 Cab files module-level objects, declaring. 445 building custom, 859 project, opening, 443
975 Index
Cab Build, Examining a Basic (tutorial), data and XML classes, 6 855-859 form-related classes, ~ batch rue, viewing generated, 859 GDI support, 7 custom cabs, building, 859 IrDA support, 7 INF rue, viewing generated, 855-858 a la carte features, 8 Cab WIZard application (Cabwiz.exe), 840 project references, viewing, 10-13 Cab WIZard utility syntax, 854-855 Visual Basic support, 7 copying to CF cards, 833 Web services, 6 generating,862-863 Class library project, 40-41 Cab files, building, 836-855 class modules, adding advanced Cab rues, 839-855 Hybrid TextBox, Creating, 224-225 CEDevice section, 842-844 inherited controls, 199-200 Defaultlnstall section, 844-849 Owner-Drawn Control, Creating, 240 DestinationDirs section, 851-852 Class template, 34 generating Cab rues, 854-855 ClassDemo Web Method, Calling (code INF rues, creating, 840-842 listing), 665 macro strings, 852 classes platform-specific settings, 853 AuditTrail Class (code listing), 952-953 SourceDisksFiles section, 850-851 AuditTrail Class, Testing (code listing), 953 SourceDisksNames section, 849-850 base, 7 basic Cab rues, 836-839 Base Interface class, 810-811 callbacks, asynchronous calls with, 672~73 BinaryReader and BinaryWriter classes, CalledOnFormThread method, 732-733 354-355,356-358 calls, asynchronous. See asynchronous calls Command classes, 383-387 to XML Web services Connection classes, 380-382 cancel buttons Control class, 6 Cancel Button, Configuring (code listing), CryptoAPI class, 712 126 Cryptography class, 709-710 configuring, 132 data and XML, 6 CancelCurrentEdit method, 434-435 DataAdapter classes, 389-392 captions, displaying MessageBox with, Datalnterface class, 524-525 119-120 DatalnterfaceDisconnected class, 515 CDATA constructs, 550-551 DataReader classes, 387-392 %CE1% macro string, 852 Directory and Directorylnfo classes, CeAppMgr.exe. See Application Manager, 332-333 monitoring DlllrnportsAttribute class, 69~91 CEDevice section (lNF rues), 842-844,860 Empty Class Structure (code listing), 240 CEShortcuts section syntax (Defaultlnstall), Exception class, 505-506 848-849 File and Filelnfo classes, 348 CEStrings section (INF rues), 841-842, 860 form-related,~ CFCOM component, 932-933 IniSettings class, 812 CheckBoxes IrDAlistener class, 62~21 CheckBox Control CheckStateChanged MessageWmdowclass, 727-733 Event, Coding (code listing), 141 RegistrySettings class, 824-825 control, 139-141 RequestState class, 587-588 properties and events, 140 SettingSupport class, 811 Checked property (menu items), 257 SipOperation class, 693, 722-723 checkmarks Socket class, 592 Checkmark Property of Menu Items, SQL Server CE database, 516-517 Toggling (code listing), 262 Stream.Write/Stream.Read classes, 581 toggling menu item, 262-263 StreamWriter and StrearnReader classes, CheckStateChanged event, coding CheckBox 353-356 control's, 141 String class, 817 child nodes, 188 System.Configuration class, 809 class-level variables, creating System.IO namespace classes, 330-331 Button, Creating a New (tutorial), 959 System.Net classes, 581 New Button, Creating (tutorial), 308-309 TextReader and TextWriter classes, 354, class library, .NET Compact Framework, 4-13 356-357 assemblies, referencing, 9-10 UserSettings class, 809 base classes, 7 WebRequest and HTTPWebRequest Bluetooth support, 8 classes, 580
976 Index
XML and data, 6 DomainUpDown Items, Defining from XML TextReader class, 558 Code (code listing), 151 XML Web service class, creating instance loading ComboBox control from, 143 of, 655-656 loading listBox control from, 159-160 XmlDocument class, 821-822 populating DataSets from, 394-395 XmlTextReader class, 823 restricting property values through, XmlTextWriter class, 554-555 212-213 Clear method (DataSets), 395 Server-Side Code That Retrieves Values click events Passed (code listing), 586 Button Control Click Event, Coding (code unmanaged. See unmanaged code listing)' 139 code listings (by chapter) Click Event Procedure for Cut, Copy, Paste ADO.NET, introduction to Menu Items (code listing), 294 DataAdapters, Populating DataTables Click Event Procedure for Menu Items Through,400 (code listing), 264 DataSet Schema, Defining. 395 Click Event Procedures for Context• DataSets, Obtaining list of DataTables Sensitive Menu Items (code listing), in, 401 271 DataTable Select Method, Filtering Rows coding Button control's, 138-139 Using, 403 menu,264 DataTables, Adding Columns to, 407 clients DataTables, Displaying Contents of, accepting client's connection, 621 402-403 client access licenses (CAL), 480 DataTables, Displaying Data from, Client Agent, SQL CE, 455--456 417-418 client project, opening. 612-613 DataTables, Loading ComboBox with Client Request Names of, 416 accepting (TCP servers), 597-598 DataTables, Obtaining List of Columns Processing (code listing), 610-611 Within, 401 client side (mobile applications), 585-586 DataViews, Setting Up, 408-409 connections, adding code to accept, SQL Server CE Database, Filling 608-609 DataSets from, 391-392 creating. 628-629 SQL Server CE, Executing Commands developing IrDA, 623-624 Against, 384 developing TCP. See under TCP objects SQL Server CE, Loading DataTables listening for (lrDAListener class), 620-621 from, 415 processing client's data, 622 SQL Server Database, Filling DataSets reading data passed from, 621 from, 391 receiving data from (TCP servers), 598-599 SQL Server Database, Saving DataSets user interface, 613 to, 396-397 XML Web service, creating. 653-656 SQL Server, Executing Commands Web references, adding, 653-655 Against, 384 Web service class instance, creating, SQL Server, Loading DataTables from, 655-656 413-414 Web service methods, 656 SqlCeDataReader Objects, Looping Close method, 556 Through,389 closing SqlDataReader Objects, Looping applications, 79 Through,388 andhidingforms, 115-116 Tables, Adding Rows to, 404-405 code XML Files, Loading DataTables from, adding 415--416 Hello World.NET tutorial, 68-70 XML Files, Saving DataSets to, 419 Panel-Based Interface tutorial, application settings 100-102 Application Information, Getting, 811 building menus from, 258-262 Application XML config File, 818 Code Access Security (CAS), 689 Base Interface Class, 810-811 Code Behind Click Event of Three Menu INI File Entries, Samples of, 815 Items (code listing), 101-102 INI File, Getting Ready to Access, 814 Code Used to Create Example Interface INI Files, Reading and Searching, (code listing), 107-109 815-817 coding context-sensitive menus, 269-270 Registry, Reading and Writing. 825-826 coding StatusBar, 283 RegistrySettings Class, Constructing, 825
977 Index
code listings (by chapter) (continued) ListView Control, Loading a, 163-164 XML Config File, Reading Values from, ListView Items, Defining Images for, 819-820 165-166 XmiDocument Class, Writing to XML OpenFileDialog Control, Working With, Settings File Using, 822-823 169-170 controls, creating ProgressBars, Working With, 176 Basic Class Module, 200 RadioButtons, Handling Multiple, 178 Collection Properties, Controlled SaveFileDialog control, Working With, Method of Implementing, 208-209 180 Collection Properties, Easy Scrolling Forms, Using ScrollBar to Implementing of, 207-208 Control, 193 Components, Simple, 246 SIP, Displaying, 156 Control Class, Starting with, 200 SIP, Hiding, 157 Custom Controls, Configuring, 232, 243 StatusBar, Updating a, 182 Empty Class Structure, 240 TreeView, Loading a, 190-191 Empty Property Procedure Structure, custom controls in C# 203-204 Custom Drawing Buttons, 960-961 Enumerated Data Types, Using, 211 data binding Events, Adding, 218-219 Binding to a DataGrid, 429-430 Events, Allowing to Fire Through, 220 Binding to a ListBox, 426-427 lnputPanel Functionality, Adding, 230 Binding to a PictureBox, 430-432 lnputPanel Property, Adding, 229 Binding to Simple Controls, 424-425 lnputPanel Property. Configuring, 234 Binding TWo TextBox Controls, Instance of a Control, Defining, 231, 243 446-447 Interfaces, Drawing, 237 Bound Forms, Validating, 435-436 KeyDown Event, Tracking, 233 Data Sources, Moving About, 433 KeyPress Event, Tracking, 233 Forms, Configuring Details Component KeyUp Event, Tracking, 234 of, 439 Locked Functionality, Adding, 227-228 Forms, Configuring Master Component Locked Property, Toggling, 232 of, 437-438 Mode Property. Adding, 241 PositionChanged Event, Saving Data Mode Property. Toggling, 244 Within,441 Object Properties, Working with, 215 device-based data OnPaint Event Procedure, Adding, 242 Databases, Creating, 512-513 Overriding Existing Properties, 215-216 DataReader, Using to Recall Data, 521 Properties, Checking Value of, 212-213 DataSet, Using to Recall Data, 521-522 Properties, Saving and Returning, 204 Integrated Security, Using, 534-535 Read-Only Property Procedure, 206 Pushing Data Back to Server, 527-528 Shadowing a Method, 218 Simple RDA, 524 Subprocedures, Implementing Simple SQL CE, Dropping Tables in, 536 Method with, 216-217 SQL CE Replication, 540-541 TextBox Control, Starting with, 202 SqlCeDataReader, Creating, 537 Write-Only Property Procedure, 206-207 Submitting Commands to Server, 538 controls, NETCF Subroutines, Using to Provide Common Button Control Click Event, Coding, 139 Functionality. 519-520 CheckBox Control CheckStateChanged Tables, Adding Data to, 519 Event, Coding, 141 emulators, working with ComboBox, Accessing Selected Items in, Emulator Skin, Default, 919-920 143 error handling ComboBox, Deleting Items from, 143 AuditTrail Class, 952 ComboBox, Loading a, 143 AuditTrail Class, Testing, 953 DataGrid, Displaying Tables in, 148 Catch Statements, Multiple, 947 Details View, Configuring, 163 Exception Handler, Application-Wide, DomainUpDown Items, Defining from 950 Code, 151 Exceptions, Checking for Specific, 948 Embedded Images, Displaying, 174 Exceptions, Displaying Message HScrollBar, Linking to TextBox, 153 Property of, 949 Images, Displaying, 174 Runtime Errors, Recovering from, 945 ListBox, Accessing Selected Items in, 160 Try, Catch, Finally Statement, 946 ListBox, Deleting Items from, 160 VB-Style Error Handling, Implementing, ListBox, Loading a, 159-160 942-943
978 Index rues and directories Dialog Boxes, Retrieving Values from, 128 BinaryWriter, Writing to Files Using, 356 Dialog Boxes, Returning the Values, Directories, Adding Checks to Moving 127-128 of, 342-343 Enter Key, Moving Between Fields with, Directory, Creating with Error Handling, 90 341 Form's Click Event for Displaying First Filenames, Iterating Through the Array Panel,101 of, 346--347 Forms, Closing from Another, 115-116 Files, Comprehensive Routine for Forms, Closing from Within, 116 Copying,350-351 Forms, Displaying, 115 GetSpecialFolderPath Wrapper MessageBox Response, Handling, 122 Function, 338-339 MessageBox with Text, Caption, Buttons, Load Button, Coding, 363, 368-369 and Symbol, 120 Save Button, Coding, 364, 369-370 Panels, Linking Scroll Bar to, 117 SHGetSpecialFolderPath Function, Property Procedure, Defining, 132-133 Declaring, 337-338 ShowPanel Routine to Handle SHGetSpecialFolderPath, Values Used Hiding/Displaying Panels, 100-101 with nFolder Argument of, 337 menus and toolbars StreamWriter, Writing to Files Using, Auto Save Feature, Toggling, 292 355,359 Button Taps, Handling, 281 Subdirectories, Iterating Through the Button Taps, Responding to, 294 Array of, 345 Checkmark Property of Menu Items, Text File, Reading in All in One Read, 358 Toggling, 262 graphics Click Event Procedure for Cut, Copy, Buttons, Custom Drawing, 310 Paste Menu Items, 294 Drawlmage with Rectangles, 318-319 Click Event Procedure for Menu Items, Drawing Eight -Sided Polygons, 303 264 Drawing Ellipses, 302 Click Event Procedures for Context• DrawRectangle, Using, 301 Sensitive Menu Items, 271 FillRectangle, Using, 301 Context-Sensitive Menu, Creating, 293 Rectangles, Drawing with Different Context-Sensitive Menus, Defining, Colors, 301-302 269-270 Scrolling an Image, 327 Edit Menu, Configuring, 261 help systems Edit Menu, Configuring Items Contacting Us Menu Item, Click Event Comprising, 261 Procedure for, 806--807 Edit Menu Items, Definition of, 260 Contents Menu Item, Click Event Edit Menu Items, Implementing, Procedure for, 805 291-292 CreateProcess Function, Declaration of, Edit Menus, Adding List of Recently 805 Accessed Files to, 264-265 Demo Help File, Contents for Topics MainMenu, Adding to Form, 262 Within, 801 MainMenu Control and Menu Items, Demo Help File Shell, 799 Adding to Form, 260 Find Keywords, Defining, 802 MainMenu Control, Definition of, 259 Getting Started Menu Item, Click Event Menu Items, Enabling, 263-264 Procedure for, 806 New Menu, Implementing, 291 Main Contents Definition for Calculator StatusBar Control, Setting Text Property Help File, 793-794 of, 283 Overview Menu Item, Click Event mobile networking Procedure for, 806 Asynchronous Responses, Processing, Table of Contents, HTML Defining, 800 589-590 interfaces, designing Client Request, Processing, 610-611 Cancel Button, Configuring, 126, 132 Data, Sending to Server, 616--617 Code Behind Click Event of Three Menu Dummy Scans, Code Used to Create, Items, 101-102 614-615 Code Used to Create Example Interface, IrDA Client, Implementing, 628-629 107-109 IrDA Server, Implementing, 627-628 Dialog Box and Response, Displaying, Messages, Sending to Server, 617-618 133 Packets, Processing, 611-612 Dialog Boxes, Defining the Structure, Pages, Retrieving from Web Servers, 127 582-584
979 Index
code listings (by chapter) (continued) Pocket IE, Launching and I>isplaying Ports, Opening and Starting to Listen, 595 Report, 875 ProcessPacket Function, 601 ~02 PrinterCE.NetCF Component Example, Request State, Class Used to Store, 884 587-588 PrintJob Function, Calling. 895-896 Requests, Initiating, 588-589 Report CE, Printing Reports Through, Responses, Reading. 590-592 904-905 Server-Side Code That Retrieves Values Report View, Controlling. 879 Passed, 586 Reports, Storing in Files, 874-875 TCP Client Connections, Watching for, RTF Files, I>isplaying Contents of, 897 60~09 server-based data .NET Compact Framework (NETCF) I>ataSets, Filling. 500 ADO.NET, Working with, 23-24 DataSets, Reading I>ata from, 501-502 Compiler Directives, Using, 29-31 No Data Is Returned, 492-493 Strings Module, Explicitly Referencing. Result Sets, Retrieving Multiple, 495-496 13 Sql Client Errors, Handling Multiple, 508 Strings Module, Working with, 12-13 SqlClient Errors, Handling. 506-507 Try-Catch-Finally Error Handling SqlCommand Object, Exploring. Structure, 25 486-487 POOM (Pocket Outlook Object Model) SqlDataReader Example, 491 Appointments, Adding, 774-775, SqlDataReader, Getting Data Back in, 781-782 493-494 Appointments, Displaying, 773-774, Stored Procedures, Using, 497 780-781 Stored Procedures, Using with Appointments, Modifying Existing, Parameters,498 775-776 'li'ansactions, How to Code, 503 Appointments, Retrieving All, 771 setups, creating Appointments, Retrieving for Specific Application Manager INI file, Format of, Dates, 772-773 833-834 Appointments, Retrieving list of All, CEI>evice Section, More Involved, 779-780 843-844 Appointments, Selecting Subset of, CopyFiles Section Example, 847 782-783 I>efaultlnstall Section, 861 Contacts, Adding. 759-760, 766-767 I>efaultlnstall Section Exllmple, 845 Contacts, Displaying. 758-759, 765-766 INF File Example, 839-840 Contacts, Modifying Existing. 760-761 Platform-Specific Settings Example, 853 Contacts, Retrieving All, 756 smart device extensions (SI>E) Contacts, Retrieving list of All, 764 Initializing Variables and Starting Timer, Contacts, Retrieving Range of, 757 69 Contacts, Selecting Subset of, 767-768 Marquee, Changing Direction of, 70 LoadAppointments Procedure, 780 Marquee, Controlling. 69-70 LoadContacts Procedure, 765 unmanaged code LoadTasks Procedure, 750-751 Battery Information, Calling the System Tasks, Adding, 745,752 for, 701 Tasks, Displaying, 744,751 Battery Information, I>eclarations for Tasks, Modifying, 746 Retrieving. 697~99 Tasks, Retrieving All, 742 Cryptography API, Required Tasks, Retrieving list of All, 750 Declarations to Use, 710 Tasks, Retrieving Select, 743 Data, Getting Back from Your Class, 704, Tasks, Selecting Subset of, 753 707-708 reports, producing Input Method Identifier, Getting the Customer Data, Retrieving from Current, 721 I>atabase,872-873 Local Heap, Allocating Memory on, Display Report Button Click Event, 726-727 Contents of, 872, 877-878 MessageWmdow, Deriving a Class from, HPMobilePrintSDKWrapper Module, 728-729 896 New Class, Generating Data to Display HTML Content of Reports, Generating, Using. 729-730 873-874 Notification API Call, Setting Up for, HTMLViewer Control, Displaying 725 Reports in, 878 Notification API, Calling, 725-726
980 Index
P/Invoke Calls to Registry, Making, Attributes, Looking at All Dynamically, 708-709 559-560 P /Invoke to Hide and Show the SIP. 693 Attributes, XML Document Using, Registry API Calls, Declarations for, 556-557 705-706 DataSets, Massaging XML Data with, SHSiplnfo for Visible State, Making a 571-573 Call to, 719 DataSets, Using Schemas with, 574 Siplnfo Unmanaged library, Function DOM, Reading Files Using, 568-569 Declarations for, 723-724 DOM, Writing to Documents with, 570 System Crypto Methods, Calling, Elements and Attributes, listing a 713-715 Document's, 557-558 XML Web services ReadElementString method of 9-Day Forecast Returned as XML, XmlTextReader, Using, 553-554 677-680 XML Document, Standard, 548-549 Arrays, Returning from Web Methods, XML Document Using Attributes, 549 657 XmlTextReader, Reading Files with, ASP.NET Web Service Template, Starter 551-552 Code Provided with, 648 XmlTextWriter, Writing XML Through, ClassDemo Web Method, Calling, 665 555 DataSet Updates, Saving from Client coding Application, 669 applications Demo Web Service's DISCO File, Building a Binary File Demo, 368-370 Contents of, 637 Building a Text File Demo, 362-364 Demo Web Service's WSDL File, Load button, 363, 368-369 Contents of, 638-643 Save button, 364, 369-370 DisplayCallback Routine, 672-673 Transactions, How to Code (code listing), DisplayStructureListing Routine, 503 661-662 collection properties DsDemo Web Method, Calling, adding and implementing (inherited 667-668 controls}, 207-210 DsDemo Web Method, Calling Controlled Method of Implementing (code Asynchronously, 671 listing), 208-209 DsDemo Web Method, Calling Easy Implementing of (code listing), Asynchronously with a Callback, 672 207-208 Forecast, Displaying for a Single Day, colors 682 defined,298 HelloWorld Method, 650 using for Pocket PC interfaces, 85-86 Methods Called Asynchronously, columns Terminating,673-674 adding to DataTables, 407 Stock Quotes Returned as XML, 684 DataTables, Adding Columns to (code Stock Service, Calling, 685-686 listing)' 407 StructureDemo Web Method, 661 DataTables, Obtaining list of Columns Structures, Creating Web Methods That Within (code listing), 401 Return,659-660 defined, 398 Structures, Defining for Use with Web listing within DataTables, 406 Methods, 659 COM components, leveraging, 18 Update Method, Adding to Web Service, combo boxes 669 ComboBox, Accessing Selected Items in WeatherService,Calling,680-682 (code listing), 143 Web Method, Calling One That Returns ComboBox, binding to, 426-428 an Array, 658 ComboBoxcontrol,141-144 Web Method, Creating One That accessing selected item in, 144 Returns an Object, 663-664 deleting item from, 143 Web Method, Defining the Class That loading from code, 143 Will Be Used with, 663 ComboBox, Deleting Items from (code Web Method That Returns a DataSet, listing), 143 666-667 ComboBox, Loading a (code listing), 143 WebMethod Attributes, Adding, 649 ComboBox, Loading with Names of XML, working with DataTables (code listing), 416 Attributes, Creating Documents Using, ComboBox properties, 142 560-561 and list boxes, 92
981 Index
Command classes, 383-387 Console Application project, 42 SQL Server CE, executing commands console.dll, 38 against, 38~387 constraints, defined, 399 SQL Server, executing commands against, Contacting Us Menu Item, Click Event 384-385 Procedure for (code listing), 8~07 SqlCeCommand class, 385-386 contacts, 754-761 SqlCommand class, 383-384 adding. 759-760, 76~767 command prompt, launching emulators Contact object, 754-755 from, 912-913 Contacts, Adding (code listing), 759-760, commercial devices. See devices, commercial 76~767 common dialog boxes, 81 Contacts, Displaying (code listing), Common Language Runtime (CLR), 3-4 758-759, 765-766 Common properties, 44-48 Contacts, Modifying Existing (code listing), Build properties, 45-46 760-761 Device properties, 47-48 Contacts property, 754 General properties, 44-45 Contacts, Retrieving All (code listing), 756 Imports properties, 46-47 Contacts, Retrieving list of All (code Reference Path properties, 47 listing), 764 CompactFlash (CF) cards Contacts, Retrieving Range of (code copying AutoRun.exe to, 832 listing), 757 copying Cab files to, 833 Contacts, Selecting Subset of (code listing), installing applications from, 831--833 767-768 as safety net, 515 Contacts, Working with (tutorial), 761-769 Compaq Ipaq, 828 adding a contact, 76~767 compilation controls, 196 displaying a contact, 765-766 compiler directives, 29-31 imports statement, adding. 763 components loading all contacts, 764-765 Components, Simple (code listing), 246 loading select contacts, 767-768 creating and starting. 245-246 module-level objects, declaring, 764 Configuration namespace, 513, 547 projects, opening. 762 Configuration properties, 49-51 references, adding. 763 Build properties, 50-51 testing applications, 768-769 Debugging properties, 49 user interface, 762-763 Deployment properties, 51 displaying, 758-759 Optimizations properties, 50 modifying, 760-761 Configuration Reader retrieving all, 75~757 ConfigReader class, creating, 565-567 retrieving range of, 757-758 Configuration Reader, Creating (tutorial), Contents Menu Item, Click Event Procedure 563-567 for (code listing), 805 ConfigReader class, creating, 565-567 context-sensitive menus controls, adding to form, 564-565 building, 265-272 project creation, 563 coding,269-270 XML file, adding, 564 ContextMenu control, adding, 2~268 conflicts and resolutions, 544-545 responding to, 271-272 connections target (responding) controls, accepting client's connection, 621 configuring. 268-269 asynchronous TCP, 605-606 Click Event Procedures for Context• closing, 622-623 Sensitive Menu Items (code listing), Connect method, 605-606 271 connecting to servers, 623-624 coding,292-294 Connection classes, 380-382 Context-Sensitive Menu, Creating (code SQL Server CE, opening connection to, 382 listing). 293 SQL Server, opening connection to, 381 Context-Sensitive Menus, Defining (code SqlCeConnection class, 381-382 listing), 269-270 SqlConnection class, 380 ContextMenu control, 144-146, 26~268 connection pooling, 484 Control class connection strings, 525 Control Class, Starting with (code listing), connectivity (HTTP protocol), 578-579 200 TCP Client Connections, Watching (code naming and inheriting, 308 listing), 608-609 properties and methods, 201 testing (SQL Server CE), 476-478 control order, common (Pocket PC), 78
982 Index controls events, adding, 218-219 adding to forms, 564-565 events, allowblg to fire through, 220 bbldingto,423-432 events,overriding,219-220 DataGrid, 428-430 methods, adding to controls, 216-217 listBox or ComboBox, 426-428 object properties, adding, 214-215 multiple fields to sblgle control, 425-426 properties, adding to controls, 203-205 PictureBox, 430-432 property values, restricting, 210-213 simple controls, 424-425 read-only properties, adding. 205-206 Bblding to Simple Controls (code listing), underlying methods, overriding. 217 424-425 underlying methods, shadowblg, Bblding 1\vo TextBox Controls (code 217-218 listing), 446-447 underlying properties, overriding, Bound Controls, Working with (tutorial), 215-216 443-450 write-only properties, adding. building. 966-970 206-207 ComboBox control, 144 owner-drawn control, creating. 235-237 compilation controls, 196 tutorial, Creating a Hybrid TextBox, ContextMenu control, 144-146 222-235 Control class class module, adding, 224-225 defined, 6 configurblg the control, 232 events, 202 InputPanel, assignblg to control, 234 inheriting, 240, 959 InputPanel functionality, adding, namblg,958-959 229-231 custom bl C#. See custom controls, bl C# InputPanel property, adding, 228-229 DateTimePicker control, 934 blstance of control, creating. 231 device-specific (SDE), 33 key-related counters, displaying, Dispose method for controls, 299 233-234 HTMLViewer control, 876, 934 Locked functionality, adding, 226-228 HTMLViewer Control, Displaying Reports Locked property, adding, 225-226 bl (code listing), 878 Locked property, togglblg. 232-233 IP*Works controls suite, 935 openblg project, 223 MainMenu control testing the control, 234-235 adding to forms, 251-253 user blterface, 223-224 Definition of (code listing), 259 tutorial, Creating an Owner-Drawn and Menu Items, Adding to Form (code Control, 238-245 listing), 260 class module, adding, 240 nonessential, 14-16 configuring project, 238 platform-specific controls (SDE), 35 configurblg the control, 243 provided with SDE, 53-54 control class, inheriting, 240 Ricklnk control, 934-935 blstance of control, creating, 243 StatusBar control, 281-282 blterface construction, 239 TextBox control, 153 Locked property, adding, 240-241 Toomar control, 277-280 Mode property, togglblg, 244 controls, creating, 195-248 OnPablt event, adding, 241-242 components, creating and starting, properties,setting,239 245-246 starting project, 238 custom controls, types of, 195-198 testing the control, 244 inherited, 197-198 controls, NETCE 137-194 owner-drawn, 198 Button control, 137-139 user, 196-197 CheckBox control, 139-141 design-time support, adding, 247 ComboBoxcontrol, 141-144 inherited controls, creating, 199-222 accessblg selected item bl, 144 base controls, definblg, 200-203 deleting item from, 143 class modules, adding, 199-200 loading from code, 143 collection properties, adding and ContextMenu control, 144-146 implementing, 207-210 DataGrid control, 146-149 construction process tips, 221-222 DomablUpDown control, 149-151 custom controls, usblg bl applications, HScrollBar control, 152-153 220-221 Imagelist control, 154-155 error handling withbl property InputPanel control, 155-157 procedures,213-214 Label control, 157-158
983 Index
UstBoxcontrol, 158-160 Custom Dialog Box, Building (tutorial}, accessing selected items in, 160 129-134 deleting items from, 160 application testing, 134 loading from code, 159-160 cancel button, configuring, 132 listed, 5 Customerlnfo class, defining, 132 listView control, 161-167 dialog box form, adding, 130 configuring in details view, 163 dialog box form, adding property images, using with, 165-166 procedure to, 132-133 loading data into, 163-164 dialog box form, configuring, 131 MainMenu control, 166-167 dialog box, showing, 133-134 NumericUpDown control, 167-168 main form, configuring, 130 OpenFileDialog control, 168-170 project configuration, 129 overview, 137 project creation, 129 Panel control, 170-171 Custom Drawing Buttons (code listing), PictureBox control, 172-174 960-961 ProgressBar control, 174-176 Customer Data, Retrieving from Database RadioButton control, 176-178 (code listing), 872-873 SaveFileDialog control, 178-180 Customerlnfo class, defining, 132 StatusBar control, 181-182 Cut, Copy, Paste Menu Items, Click Event TabControl control, 182-183 Procedure for (code listing), 294 TextBox control, 183-185 Timer control, 185-186 Tooffiar control, 186 D TrackBar control, 186-188 data TreeView control, 188-191 Adding Data to Tables (code listing), 519 VScrollBar control, 191-193 Customer Data, Retrieving from Database CopyFilesSection (code listing), 872-873 Example (code listing), 847 data access changes (eVB vs. VB .NET}, syntax (Defaultlnstall), 846-847 22-24 CreateDirectory method, 341 Data, Getting Back from Your Class (code CreateProcess Function, Declaration of (code listing), 704, 707-708 listing). 805 Data, None Is Returned (code listing), CreateProcess module, 876 492-493 CryptEncryptmethod, 710 data packets, processing (TCP servers), CryptoAPI class, 712 599 cryptography dataschemas,573-575 Cryptography API, Required Declarations Data, Sending to Server (code listing), to Use (code listing), 710 616-617 Cryptography class, 709-710 Data Sources, Moving About (code listing), System Crypto Methods, Calling (code 433 listing), 713-715 data storage, local using XML, 27 using on devices, 709-716 data synchronization, 454 making the call, 712-716 DataReader, Using to Recall Data (code setting up for call, 710-712 listing), 521 CSIDL numbers for special folders, DataSet, Using to Recall Data (code 334-335 listing), 521-522 custom controls device-based. See device-based data inC#, 957-972 hiding (SQL Server CE), 478-479 Custom Drawing Buttons (code listing), manipulating in databases, 518-522 960-961 New Class, Generating Data to Display tutorial, Creating a New Button, Using (code listing), 729-730 957-972 passing from XML Web services, 656-669 Custom Controls, Configuring (code arrays, 657-858 listing), 232,243 DataSets, 665-868 types of, 195-198 objects, 662-865 inherited controls, 197-198 structures,658-862 owner-drawn controls, 198 updates, returning to XML Web services, user controls, 196-197 668-869 using in applications, 220-221 PositionChanged Event, Saving Data Custom dialog box Within (code listing), 441 constructing, 124-128 processing client's data, 622
984 Index
Pushing Data Back to Server (code listing), Database Progranuning with VB .NET 527-528 (Apress), 499 Reading Data from DataSets (code listing), Databases, Creating (code listing), 501-502 512-513 reading data passed from clients, 621 limited support, 16-17 reading from elements, 553-554 manipulating data in, 518-522 saving permanently, 440--441 protecting, 517-518 server-based. See server-based data querying with SqlCommand object, writing to elements, 554-556 485-499 and XML classes, 6 ExecuteDataReader, 488-491 data binding, 423-451 ExecuteReader, overload of, 492-496 adding items, 434 SQL statements, passing parameters basics, 423 through, 487-488 BindingContext objects, 441-442 stored procedures, 496-499 controls, binding to, 423-432 single user, 480 DataGrid, 428-430 DataColumn class, 405-407 ListBox or ComboBox, 426-428 columns, adding to DataTables, 407 multiple fields to single control, 425-426 columns, listing within DataTables, 406 PictureBox, 430--432 DataGrids simple controls, 424-425 bindingto,428-430 deleting items, 434 DataGrid, Binding to a (code listing), edits in progress, canceling, 434-435 429-430 Master-Detail forms, creating, 436-440 DataGrid control, 146-149 moving between items, 432-433 DataGrid, Displaying Tables in (code saving ~ata permanently, 440-441 listing), 148 tutorial, Working with Bound Controls, properties, 147 443-450 Datalnterface class, 524-525 ApplicationLocation function, adding, DatalnterfaceDisconnected class, 515 447 DataReaders binding the controls, 446-447 classes, 387-392 database, adding, 444-445 SqlCeDataReader class, 388-389 edits, canceling, 449 SqlDataReader class, 387-388 module-level objects, declaring, 445 DataReader, Using to Recall Data (code project, opening, 443 listing). 521 records, adding new, 448-449 DataRow class, 404-405 records, deleting, 449 rows records, moving between, 448 modifying, 405 references, adding, 445 viewing contents of, 405 testing application, 449-450 tables, adding rows to, 404-405 user interface, 444 DataSets validating input, 435-436 and DataAdapters, 499-502 data providers, 376-379 DataSet class, 392-403 SQL Server CE provider, 377-379 clearing, 395 SQL Server provider, 376-377 populating, 393-395 data types refreshing, 395 Data Types, Using Enumerated (code saving, 396 listing), 211 DataSet Schema, Defining (code listing), NETCF,20 395 supported by SQL CE, 454-455 DataSet Updates, Saving from Client VB.NET,20 Application (code listing), 669 DataAdapters DataSet, Using to Recall Data (code DataAdapter classes, 389-392 listing), 521-522 SqlCeDataAdapter class, 391-392 DataSets, Filling (code listing), 500 SqlDataAdapter class, 390-391 DataSets, Filling from SQL Server CE DataAdapters, Populating DataTables Database (code listing), 391-392 Through (code listing), 400 DataSets, Filling from SQL Server Database populating DataSets from, 393-394 (code listing), 391 saving DataSets through, 396-397 DataSets, Massaging XML Data with (code databases listing), 571-573 adding, 444-445 DataSets, Obtaining List of DataTables in creating, 511-517 (code listing), 401
985 Index
DataSets, Reading Data from (code listing), demo help file 501-502 Demo Help File, Contents for Topics DataSets, Saving to SQL Server Database, Within (code listing), 801 (code listing), 396-397 Demo Help File Shell (code listing), 799 DataSets, Saving to XML Files (code testing, 802 listing), 419 demo system, help, 797 DataSets, Using Schemas with (code deployment listing). 57 4 automatic (SDE), 34 fundamentals, 24 deploying applications, 73-74 passing from XML Web services, 66!Hi68 design time typed, 644 building menus at, 251-258 usingwithXML, 571-573 MainMenu control, adding to forms, Web Method That Returns a DataSet (code 251-253 listing), 666-667 Menu Designer, configuring with, 254-256 DataTables menu item properties, configuring, Adding Columns to (code listing), 407 257-258 and DataSet class, 392 menu terminology, 253-254 DataTable class, 398-403 support, adding. 247 DataSets, obtaining list of DataTables in, updating code for, 965-966 400-401 Designer, Menu, 254-256 DataTable columns, obtaining list of, desktop 401 installing applications from, 833-835 DataTables, accessing data within, setup,building,835,864-865 402-403 DestinationDirs section (INF files), 851-852, DataTables, populating, 400 862 DataTables, searching, 403 Details Component of Forms, Configuring DataTable Select Method, Filtering Rows (code listing), 439 Using (code listing), 403 Details View, Configuring (code listing), 163 Displaying Contents of (code listing), development 402-403 environment, setting up, 907-910 Displaying Data from (code listing), ActiveSync, installing. 908 417-418 eMbedded tools, installing, 909-910 Loading ComboBox with Names of (code operating systems, installing, 907 listing), 416 SQL Server/SQL Server CE, installing. Loading from SQL Server CE (code listing), 908-909 415 VS .NET 2003, installing, 908 Loading from SQL Server (code listing), help development process, 791-792 413-414 information and tools, 926-928 Loading from XML Files (code listing), programs, 926 415-416 tools, 930-935 Obtaining list of Columns Within (code controls and components, 932-935 listing), 401 hardware tools, 930 Populating Through DataAdapters (code installing (SQL Server CE), 457 listing). 400 programming. testing. and deployment, DataViews 930-932 DataView class, 407-409 device-based data, 511-545 DataViews, Setting Up (code listing), database fundamentals, 511-522 408-409 databases,creating,511-517 DateTimePicker control, 934 databases, manipulating data in, debugging 518-522 applications,60-61 databases, protecting, 517-518 remote (SDE), 34 merge replication, 538-544 declarations, adding to help files, 804-805 RDA vs. replication, 544-545 Declare statements, 690 remote data access (RDA), 522-528 default class name, modifying, 648-649 authenticating with liS, 528 default properties (eVB), 21 fundamentals,522-523 DefaultButton argument values (Show pulling data in, 524-527 method), 122 pushing data back to server, 527-528 Defaultlnstall section, 844-849, 861 tutorial, Beyond Anonymous, 528-538 Delete method (directories), 343-344 directory security, setting, 529 demo application, help, 803-804 login account, creating, 529
986 Index
security, setting in liS, 530-532 DataGrid, Displaying Tables in (code security, setting in SQL Server, 532-535 listing), 148 SQL CE, working with, 535-537 DataTables, Displaying Contents of (code Transact-SQL (T-SQL), running on listing), 402-403 remote server, 537-538 Display method (POO~). 744 devices Display Report Button Click Event, commercial, 928--929 Contents of (code listing), 872, cryptography and. See cryptography, using 877-878 on devices Displaying Data from DataTables (code deploying to, 60 listing), 417-418 device development overview, 910 Displaying Images (code listing), 17 4 device power information, obtaining DisplayStructureListing Routine (code (example), 696-704 listing), 661-662 calling system, 700-704 Embedded Images, Displaying (code setting up to call API, 696-700 listing), 174 device-specific controls, SDE, 33 Exceptions, Displaying ~essage Property emulators, SDE, 33 of (code listing), 949 industrial, 929 forms, 114-115 manually installing applications on, 830 images in PictureBox, 173-174 profiles, defined, 33 ~essageBox, displaying with text and testing on, 60, 72-73 caption, 119-120 dialog boxes, 118--128 open file dialog box, 169-170 common,81 panels, displaying at startup, 101 Custom dialog box, 124-128 reports, 875-876 Custom Dialog Box, Building (tutorial), RTF Files, Displaying Contents of (code 129-134 listing), 897 Dialog Boxes, Defining the Structure (code save file dialog box, 180-181 listing), 127 SIP. 156 Dialog Boxes, Retrieving Values from (code SIP button, 80 listing), 128 tables, 417-418 Dialog Boxes, Returning the Values (code tables in DataGrid, 148 listing), 127-128 tasks, 751 disposing of, 128 Tasks, Displaying (code listing), 744 forms text on StatusBar, 182 adding, 130 wait cursor, 80 adding property procedures to, Dispose 132-133 r.nethod, 112,299,520 configuring, 131 procedure, forms, 110 Input dialog box, 122-124 distributors, setting up (SQL Server CE), ~essageBox, 118--122 466-470 showing, 133-134 Dlllmport, 690-691 digest authentication, 644 DlllmportsAttribute class, 690-691, 697 dimensioning variables, 68 DLLs (Dynamic Link Libraries) DirectCast method, 728 Unmanaged DLL, Creating (tutorial), directives, compiler, 29-31 727-733 directories. See also files and directories writing, 716-717 Directories, Adding Checks to ~oving of DNS names, 579 (code listing), 342-343 Document List component, 934 Directory, Creating with Error Handling document type definitions (DTDs), (code listing), 341 549-550 and files. See files and directories documents security, setting, 529 Attributes, Creating Documents Using DISCO File, Contents of Demo Web Service's (code listing), 560-561 (code listing), 637 Attributes, XML Document Using (code DiscoverDevices method, 624 listing), 556-557 DisplayCallback Routine (code listing), DO~. Writing to Documents with (code 672-673 listing), 570 displaying Elements and Attributes, Listing a appointments, 773-774,780-781 Document's (code listing), 557-558 contacts, 758--759, 765-766 reading attributes in, 557 data,416-417,416-418 writing attributes to, 560-563
987 Index
~1,547-551,556-563 edits, canceling, 434--435, 449 ~L Document, Standard (code listing), elements 548-549 of documents, 549 DOM (Document Object Model) Elements and Attributes, Listing a navigation of documents, 568-571 Document's (code listing), 557-558 reading elements with, 568-570 reading data from, 553-554 writing elements with, 570-571 reading with DOM, 568-570 Reading Files Using (code listing), 568-569 writing data to, 554-556 Writing to Documents with (code listing), writing with DOM, 570-571 570 ellipses, drawing. 302-303 DomainUpDown Embedded Images, Displaying (code listing), control, 149-151 174 Items, Defining from Code (code listing), 151 eMbedded tools, installing, 909-910 properties, 150 eMbedded Visual Basic (eVB) vs. VB .NET, drawing,300-306 19-28 Custom Drawing Buttons (code listing), data access changes, 22-24 960-961 data changes, 19-21 Draw methods, 886 error handling changes, 24-25 DrawButton method, creating files under VB .NET, 27-28 Button, Creating a New (tutorial), language structure changes, 21-22 960-961 eMbedded Visual C++ language, 34, 831, New Button, Creating (tutorial), 309-310 909 Drawlmage with Rectangles (code listing), eMbedded Visual Tools (Web site), 909 318-319 Empty Class Structure (code listing), 240 Drawing Ellipses (code listing), 302 Empty project, 42-43 DrawLine method, 305 Empty Property Procedure Structure (code DrawRectangle, Using (code listing), 301 listing), 203-204 DrawString method, 306 emulators, 911-923 ellipses, 302-303 configuring, 914-920 Images, Displaying Simple (tutorial), ActiveSync partnership, setting up, 322-323 918-919 lines, 305 hardware, defining, 915-917 rectangles, 301-302 resetting, 920 regions and polygons, 303-304 saving current state, 920 strings, 306 skins, changing, 919-920 DsDemo Web Method deploying to, 59 Calling Asynchronously (code listing), 671 Emulator Skin, Default (code listing), Calling Asynchronously with a Callback 919-920 (code listing), 672 launching,911-913 Calling (code listing), 667--668 from command prompt, 912-913 dummy scans from within VS .NET, 911-912 Dummy Scans, Code Used to Create (code moving files to, 920-923 listing), 614--615 files, adding to project, 921-922 generating, 614--615 files, copying from shares, 922-923 DWORDs (C++l. 694,700 network connection, running without, dynamic filtering, 543 913-914 Loop back adapter, configuring under Wmdows 2000, 914 E Loopback adapter, installing under e-mail, Inbox for, 80 Wmdows 2000, 913 edit menus Pocket PC RAM, 917 Edit Menu, Configuring (code listing), 261 testing in, 58-59, 70-71 Edit Menu, Configuring Items Comprising Enabled property (menu items), 257-258 (code listing), 261 encryption,478-479 Edit Menu Items, Definition of (code EncryptString method, 712-713 listing), 260 EndWrite and EndRead methods, 606 Edit Menu Items, Implementing (code English language macro strings, 852 listing), 291-292 Enter Key, Moving Between Fields with (code Edit Menus, Adding List of Recently listing), 90 Accessed Files to (code listing), Enumerated Data Types, Using (code listing), 264-265 211
988 Index enumerations, restricting property values ListView events, 162 through, 211-212 OnMouseDown event, 312 equipment, Pocket PC, 930 OnMouseUp event, 312 error handling. 941-956 OnPaint Event Procedure, Adding (code AuditTrail Class (code listing), 952-953 listing), 242 AuditTrail Class, Testing (code listing), 953 OnPaint events, 299-300 Catch Statements, Multiple (code listing), overriding (inherited controls), 219-220 947 Paintevents,299-300 catching exceptions, 94 7 PictureBox events, 173 causing exceptions to occur, 954-955 Popup events, 270-271 En object, triggering runtime errors PositionChanged Event, Saving Data using,954-955 Within (code listing), 441 Throw statements, triggering exceptions TextBox events, 185 with, 955 Tick event (Timer control), 186 changes (eVB vs. VB .NET), 24-25 TreeView events, 189 detailed error information, obtaining, 951 exceptions Error Handling, Creating Directory with catching. 947 (code listing), 341 causing to occur, 954-955 Exception Handler, Application-Wide En object, triggering runtime errors (code listing), 950 using. 954-955 exception safety nets, creating, 949-950 Throw statements, triggering exceptions Exceptions, Checking for Specific (code with,955 listing), 948 Exception class, 505-506 Exceptions, Displaying Message Property Exception Handler, Application-Wide of (code listing), 949 (code listing), 950 handling exceptions, 948-949 exception handling with Web requests, 584 within property procedures, 213-214 Exceptions, Checking for Specific (code Runtime Errors, Recovering from (code listing). 948 listing), 945 Exceptions, Displaying Message Property tracking exceptions, 951-953 of (code listing), 949 Try, Catch, Finally statements, 946 handling. 948-949 VB-Style Error Handling, Implementing safety nets, creating, 949-950 (code listing), 942-943 tracking,951-953 Visual Basic style, 941-946 ExecuteDataReader, 488-491 En object, 944 ExecuteDataReader method, 486 implementing,942-944 ExecuteNonQuery method, 486-488 runtime errors, recovery from, 945-946 ExecuteReader EUI.A (end-user licensing agreement) file, method,492 creating, 865 overload of, 492-496 events ExecuteScalar method, 486-487 adding (inherited controls), 218-219 ExecuteXInlReadermethod,486-487 allowing to fire through, 220 Exists method (File class), 348-349 ButtonClick event, 280-281, 294 explicit field names, 475 CheckBox, 140 EzSetup utility, 864-867,932 CheckBox Control CheckStateChanged Event, Coding (code listing), 141 Click Event Procedure for Cut, Copy, Paste F Menu Items (code listing), 294 field names, explicit, 475 context-sensitive events, responding to, FieldOffset attribute, 700 271-272 FieldSoftware.PrinterCE.NetCF, importing. control class events, 202 882 event procedures, accessing, 56 File Explorer, 790 Events, Adding (code listing), 218-219 file notifications, absence of, 17 Events, Allowing to Fire Through (code filenames listing), 220 configuring forforms, 113 . Form events, 105 Filenames, Iterating Through the Array of handling. 312, 962-963 (code listing), 346-347 KeyDown Event, Tracking (code listing), files 233 adding. 56-57 KeyPress Event, Tracking (code listing), 233 DOM, Reading Files Using (code listing), KeyUp Event, Tracking (code listing), 234 568-569
989 Index
Files, Comprehensive Routine for Copying FillRectangle, Using (code listing), 301 (code listing), 350-351 FillRegion method, 304 files under VB .NET, 27-28 filtering Files, Using BinaryWriter to Write to (code dynamic, 543 listing), 356 Filter dialog box, 902 Files, Using StreamWriter to Write to (code row, 539, 543-544 listing), 355, 359 find capabilities (help files), 801-802 FileStream class, 353 fixed keyword, 716, 724 help, 792 fixed-length strings, no support for, 20 moving to emulators, 920-923 Focus method (TextBox control), 185 Reports, Storing in Files (code listing), folders, special, 333-340 875 CSIDL numbers for, 334-335 under VB .NET, 27-28 Personal folder, defined, 335, 339 XmlTextReader, Reading Files with (code Pocket PC special folders, 333-334 listing), 551-552 Programs folder, defined, 335-336, 339 files and directories, 327-371 retrieving special folder information, directories, 332-347 337-340 creating, 341 SHGetSpecialFolderPath function, 334, deleting, 343-344 338-339 determining application directory, 34 7 Start Menu folder, defined, 336, 340 determining existence of, 340 StartUp folder, defined, 336, 340 determining files within, 345-347 \ Windows\Start Menu folder, defined, 336 determining subdirectories within, \Wmdows\StartUp folder, defined, 336 344-345 Forecast, Displaying for a Single Day (code Directory and Directorylnfo classes, listing), 682 332-333 forms directory-related functionality. 347 Bound Forms, Validating (code listing), moving,342-343 435-436 special folders. See folders, special closing and hiding, 115-116 files,348-359 code behind, 106-112 attributes, obtaining, 352 forms, creation of, 109-110 checking existence of, 348-349 forms, disposal of, 110 copying,349-350 form's interface, building, 110-112 creating and opening, 353-354 designing, 51-53 deleting, 351-352 displaying, 114-115 File and Filelnfo classes, 348 Form class properties, 104 moving, 350-351 Form events, 105 network files, 358-359 form-level variables, creating, 325 readers and writers, 354 Form methods, 105 reading from, 356-358 form-related classes, 4-6 writing to, 354-356 Forms class, properties of, 104-105 System.IO namespace, 330-332 Form's Click Event for Displaying First tutorial, Building a Binary File Demo, Panel (code listing), 101 366-371 Forms, Closing (code listing), 116 coding applications, 368-370 Forms, Closing from Another (code interface, building, 367-368 listing), 115-116 project configuration, 366 Forms, Configuring Details Component of project creation, 366 (code listing), 439 testing application, 370-371 Forms, Configuring Master Component of tutorial, Building a Text File Demo, (code listing), 437-438 360-365 Forms, Displaying (code listing), 115 coding applications, 362-364 MainMenu control, adding to, 251-253 interface, building, 361 MainMenu Control and Menu Items, project configuration, 361 Adding to Form (code listing), 260 project creation, 360 renaming, 113-114 properties, setting, 362 scrolling, 116-117 testing application, 364-365 usingVScrollBar to simulate, 193 filling startup form, configuring, 114 DataSets, Filling (code listing), 500 Wmdows. See Wmdows forms Fill method, 395 forward only data-reading objects, 486-487 FillPolygon method, 303 FromArgb method, 298
990 Index
G H GDI+ The Handbook for Reluctant Database GDI+ Progranuning inC# and VB .NET Administrators (Apress), 499 (Apress). 297 hard coding strings, 485, 513 GDI support, 7 hardware no support for, 19 keyboards, 92 GetBytes method, 603 tools, 930 GetCurrentCellBounds method (DataGrid Hello World.NET tutorial control), 147 code, adding, 68-70 GetCurrentlnput method, 723-724 deploying, 73-74 GetDirectories method, 344-345 interface, building, 66-67 GetFiles method, 346 project creation, 62 GetPrivateProfile methods, 810 project properties, setting, 62~5 GetSystemPowerStatus method, 699-702 testing, 70-73 Getting Started Menu Item, Click Event Hello World Method (code listing), 650 Procedure for (code listing), 806 Help access, 80-81 GotDotNet POOM sample, 736 Help File, Building a (tutorial), 796-802 graptucs,297-328 demo help file, testing, 802 basics, 297-300 find capabilities, adding, 801-802 drawing,300-306 help demo system overview, 797 ellipses,302-303 help file shell, constructing, 799 lines, 305 shortcut files rectangles, 301-302 creating, 798 regions and polygons, 303-304 placing, 798-799 strings, 306 table of contents, adding, 799-800 Graptucs class properties, 305 topics, adding, 800-801 images, 315-320 help systems, 785-808 tutorial, Creating a New Button, 306-315 construction of, 789-796 class-level variables, creating, 308-309 arctutecture, help system, 789-790 Control class, naming and inheriting, help development process, 791-792 308 help files, 792 DrawButton method, creating, HTML tags, supported, 795 309-310 images, adding, 794 events, handling, 312 PegHelp tags, 793-794 OnEnabledChanged event, adding, shortcut files, 792 311 tools, 790-791 OnPaint event, adding, 309 useful tips, 796 project configuration, 308 Contacting Us Menu Item, Click Event project creation, 307 Procedure for (code listing), 806-807 properties, adding, 312-313 Contents Menu Item, Click Event references, adding, 307 Procedure for (code listing), 805 stylus, moving off button, 313-314 CreateProcess Function, Declaration of testing application, 314-315 (code listing), 805 tutorial, Displaying a Simple Image, Demo Help File Shell (code listing), 799 320-323 Getting Started Menu Item, Click Event drawing image, 322-323 Procedure for (code listing), 806 images,adding,321 help files, implementing, 802-807 PictureBox, using, 322 applications, adding help to, 803 project configuration, 321 declarations, adding, 804-805 project creation, 320-321 help demo application, 803-804 references, adding, 321 help files, calling, 805-807 tutorial, Scrolling an Image, 323-328 help files, delivering, 807 form-level variables, creating, 325 Main Contents Definition for Calculator image, loading, 326 Help File (code listing), 793-794 project configuration, 324 Overview Menu Item, Click Event project creation, 324 Procedure for (code listing), 806 references, adding, 324 Pocket PC help system, 785-789 scrolling code, adding, 327-328 fiwndamentals, 785-787 scrolling, setting up timer for, 326 help topics, finding, 788 start button, adding, 325 help topics, viewing, 788-789
991 Index
Table of Contents, HTML Defining (code Hybrid TextBox, Creating (tutorial), 222-235 listing), BOO class module, adding, 224-225 tutorial, Building a Help File, 796--802 configuring the control, 232 demo help me, testing, 802 InputPanel find capabilities, adding, 801-802 assigning to control, 234 help demo system overview, 797 functionality, adding, 229-231 help me shell, constructing, 799 property, adding, 228-229 shortcut rues, creating, 798 instance of control, creating, 231 shortcut rues, placing, 798-799 key-related counters, displaying, 233-234 table of contents, adding, 799-800 Locked functionality, adding, 226-228 topics, adding, 800-801 Locked property HP Print Demo, 892-897 adding, 225-226 HPMobilePrintSDK DLL and module, toggling, 232-233 adding, 89~95 opening project, 223 HPMobilePrintSDKlnstaller, adding testing the control, 234-235 references to, 894 user interface, 223-224 HPMobilePrintSDKWrapper module, 896 invoices, displaying, 897 printing report, 895-896 I HPMobilePrintSDK DLL and module, adding, icons 89~95 adding, 63-65 HPMobilePrintSDKlnstaller, adding correctly configuring, 65 references to, 894 icon argument values (Show method), HPMobilePrintSDKWrapper Module (code 121 listing). 896 Identity component, 934 HScrollBar liS (Internet Information Server), 528,645 control, 152-153 images Linking to TextBox (code listing), 153 adding,321, 794 properties, 153 displaying in PictureBox, 173-174 HTML (HyperText Markup Language) Embedded Images, Displaying (code HTML Content of Reports, Generating listing), 174 (code listing), 873-874 Image Collection Editor, 276 HTML reporting sample, 870-876 Image, Scrolling (tutorial), 323-328 data gathering, 872-873 ImageList displaying reports, 875-876 control, 154-155, 273-277 report formatting, 873-874 loading, 289 saving reports, 87~75 properties, 154 HTML reports, producing, 870 Images, Displaying (code listing), 17 4 HTML tags, supported by help IDes, 795 Images, Displaying Simple (tutorial), HTMLViewer alternative approach, 320-323 876--879 drawing image, 322-323 displaying reports, 878 images, adding, 321 report view, configuring, 878-879 PictureBox, using, 322 summary, 879 project configuration, 321 HTMLViewer control, 876, 934 project creation, 320-321 HTMLViewer Control, Displaying Reports references, adding, 321 in (code listing), 878 Images, Scrolling (code listing), 327 HTTP (HyperText Transport Protocol), ListView Items, Defining Images for (code 578-592 listing), 165-166 asynchronous HTTP requests, 587-592 loading, 326 connectivity, 578-579 methods and overloads, 315 NetworkStream class, 581 using with ListView control, 165-166 SSL, HTTP requests with, 592 Implements keyword, 813 URis (Uniform Resource Identifiers), imports statement, adding, 749,763,778 579-580 Inbox for e-mail, 80 Web pages, retrieving, 581-584 include directives, 720 Web requests, exception handling with, industrial devices. See devices, industrial 584 INFIDes Web servers, sending data to, 585-586 building, 859-862 WebRequest and HTTPWebRequest creating, 840-842 classes, 580 Example (code listing), 839-840
992 Index
sections of, 840--841 minimize user input, 90 viewing generated, 855-858 SIP, avoiding. 92 inherited controls validating (data binding), 435-436 creating. 199-222 Installation, Building a Custom Cab base controls, defining, 200-203 (tutori&), 859-867 class modules, adding, 199-200 Application Manager INI ffie, creating, 863 collection properties, adding and Application Manager, monitoring, 864 implementing, 207-210 Cab ffies, generating, 862-863 construction process tips, 221-222 desktop setup, building, 864-865 custom controls, using in applications, INF ffie, building, 859-862 220-221 setup,running,866-867 error handling within property lnstallDir directive (INF ffie), 841-842 procedures,213-214 installing evenm,adding,218-219 applications. See applications, installing evenm, allowing to fire through, 220 SQL Server CE 2.0. See SQL Server CE, evenm,overriding,219-220 introduction to methods, adding to controls, 216-217 Instance of a Control, Defining (code listing), object properties, adding. 214-215 231,243 properties, adding to controls, 203-205 Integrated Security, Using (code listing), property values, restricting. 210-213 534-535 read-only properties, adding, 205-206 Integrated Wmdows authentication, 465-466, underlying methods, overriding. 217 532 underlying methods, shadowing, interfaces 217-218 basing classes on, 810 underlying properties, overriding. building,66-67,97-100,239,285,361, 215-216 367-368 write-only properties, adding, 206-207 constructing for custom controls, 236-237 fiwndament&s,197-198 creating with panels, 171 INiffies form's interface, building, 110-112 Application Manager, 833-834, 863 Interfaces, Drawing (code listing), 237 Application Manager INI ffie, Format of Report CE, 901 (code listing), 833-834 user, 410-412 Entries, Samples of (code listing), 815 interfaces, designing, 75-135 Getting Ready to Access (code listing), 814 di&og boxes, 118-128 IniSettings class, 812 Custom di&og box, 124-128 Reading and Searching (code listing), disposing of, 128 815-817 Input di&og box, 122-124 settings,812-818 MessageBox, 118-122 initializations forms, code behind, 106-112 Initializing Variables and Starting Timer forms, creation of, 109-110 (code listing), 69 form's interface, building. 110-112 perforrning,68-69 forms, working with, 113-117 input closing and hiding, 115-116 Input di&og box, 122-124 displaying, 114-115 Input Method Identifier, Getting the renaming. 113-114 Current (code listing), 721 scrolling, 116-117 lnputBox fiwnction arguments, 123 startup form, configuring, 114 lnputPanel input rules, 88-92 assigning to control, 234 dangerous buttons, positioning of, control, 155-157 90-92 fiwnctionality, adding. 229-231 large objecm, 88-89 Functionality. Adding (code listing), 230 minimize user input, 90 properties, 156 SIP, avoiding, 92 property, adding. 228-229 interface rules, 82-88 Property. Adding (code listing), 229 colors, using. 85-86 Property, Configuring (code listing), large interface componenm, 83-85 234 overcrowding, avoiding, 86-88 rules, 88-92 Pocket PC design standards, 75-82 dangerous buttons, positioning of, application shutdown, 81 90-92 application title, displaying, 76 large objecm, 88-89 closing applications, 79
993 Index
common dialog boxes, 81 objects, 619--624 Help access, 80-81 lrDA clients, developing, 623--624 lnbox for e-mail, 80 IrDA namespace, adding reference to, menus and buttons, order of, 78 620 multiple application instances, running, IrDA server, developing, 620--623 81 support, 7 NavBar, 76-77 lsolationLevel enumeration values, 504 New button, displaying, 77 lsSipVisible method, 723 pixel icons, 79 items Pocket Outlook data, 79 adding (data binding), 434 restoration, 82 deleting (data binding), 434 SIP button, displaying, 77-78, 80 moving between (data binding), 432-433 System help, 81 wait cursor, displaying, 80 porting rules, 95-96 K tutorial, Custom Dialog Box, Building, key-related counters, displaying, 233-234 129-134 KeyDown Event, Tracking (code listing), 233 applicationtesting,134 KeyPress Event, Tracking (code listing), 233 cancel button, configuring, 132 KeyUp Event, Tracking (code listing), 234 Customerlnfo class, defining, 132 keywords dialog box form, adding, 130 Find Keywords, Defining (code listing), 802 dialog box form, adding property Fixed keyword, 716, 724 procedure to, 132-133 Implements keyword, 813 dialog box form, configuring, 131 Shared keyword, 693--694 dialog box, showing, 133-134 Unsafe keyword, 716, 724 main form, configuring, 130 project configuration, 129 L project creation, 129 tutorial, Panel-Based Interface, 96-103 Label control, 157-158 adding code, 10~102 languages application testing, 102-103 language functionality, 94 interface, constructing, 97-100 structure changes (eVB vs. VB .NET), 21-22 new project, creating, 97 supported by SDE, 34 project configuration, 97 left-handed users, 193 usage rules, 93-95 library, class (NETCF). See class library, .NET· battery usage timing, 94 Compact Framework language functionality, 94 licensing SQL Server CE, 480-481 local language functionality, 95 lines,drawing,305 physical locations, accommodating, 94 UstBoxes testing on all devices, 94 Accessing Selected Items in (code listing), Wmdows Forms,103-105 160 Form events, 105 bindingto,426-428 Form methods, 105 Binding to (code listing), 426-427 Forms class, properties of, 104-105 control, 158--160 invoices, displaying, 897 accessing selected items in, 160 Invoke method, 733 deleting items from, 160 IP*Works controls suite, 935 loading from code, 159-160 IrDA (infrared data association) Deleting Items from (code listing), 160 IrDA Client, Implementing (code listing), Loading (code listing), 159-160 628-629 properties, 159 IrDA Server, Implementing (code listing), listings. See code listings 627--628 UstViews IrDA, Working with (tutorial), 624--630 controls, 161-167 client, creating, 628-629 configuring in details view, 163 project, opening, 625 images, using with, 165-166 server, creating, 626--628 Loading (code listing), 163-164 settings and configurations, defining, loading data into, 163-164 626 events, 162 testing applications, 630 UstView Items, Defining Images for (code user interface, 625--626 listing), 165-166 IrDAListener class, 620--621 properties, 162
994 Index loading menus all appoinnnents, 779-780 building all contacts, 764-765 from code, 256-262 all tasks, 749-751 overview, 250 list of select tasks, 752-753 tutorial, 286-288 Load Button, Coding (code listing), 363, building at design time, 251-258 366-369 MainMenu control, adding to forms, LoadAppoinnnents Procedure (code 251-253 listing)' 780 Menu Designer, configuring with, LoadContacts Procedure (code listing), 254-256 765 menu item properties, configuring, LoadTasks Procedure (code listing), 257-258 750-751 menu terminology, 253-254 select appoinnnents, 782-783 and buttons, order of, 78 select contacts, 767-768 coding,290-292 local connect strings, 536 context-sensitive menus, building, local data storage, using XML for, 27 265-272 Local Heap, Allocating Memory on (code coding,269-270 listing), 726-727 context-sensitive events, responding to, localhost, 4 77 271-272 localizing applications, 329 ContextMenu control, adding, 266-268 Locked functionality target (responding) controls, adding,226-228 configuring, 266-269 Locked Functionality, Adding (code defined, 253 listing), 227-228 generating, 264-265 Locked property menu Click events, responding to, 264 adding, 199,225-226,240-241 Menu Designer, configuring, 254-256 to~g,232-233 menu items To~g (code listing), 232 Checkmark Property of Menu Items, login account, creating, 529 To~g (code listing), 262 Loopback adapter checkmarks, to~g, 262-263 configuring underWmdows 2000, Click Event Procedure for Menu Items 914 (code listing), 264 installing under Wmdows 2000, 913 defined, 253 enabling and disabling, 263-264 Menu Items, Enabling (code listing), M 263-264 machinename\IUSER_machinename menu object names, 259 account, 466 New Menu, Implementing (code listing), macro strings, 852 291 Main Contents Definition for Calculator Help tutorial, Menus and Toolbars, 283-295 File (code listing), 793-794 context-sensitive menu, coding, main form, configuring, 130 292-294 Main_Contents attribute (help files), lmageList, loading, 289 793-794 interface, building, 285 MainMenu control menu, building, 286-288 Adding to Form (code listing), 262 menu, coding, 290-292 adding to forms, 251-253 new project, creating, 284 Definition of (code listing), 259 project configuration, 285 fundamentals, 166-167 properties,setting,286 and Menu Items, Adding to Form (code testing application, 295 listing), 260 Tooffiar buttons, defining, 289-290 managed code, defined, 3, 689 Tooffiar, coding, 294-295 Marquee, Changing Direction of (code wiring, 101-102 listing), 70 Merge Agent, 544-545 Marquee, Controlling (code listing), 69-70 mergereplication,536-544 Master Component of Forms, Configuring architecture,539 (code listing), 437-438 RDA vs. replication, 544-545 Master-Detail forms, creating, 436-440 SQL CE Replication (code listing), MaxConnections variable, 594 540-541 memory,568 SQL Server, 460-461
995 Index
Message Boxes GetPrivateProfile methods, 810 dialog box, 116-122 GetSystemPowerStatus method, 699-701 MessageBox Response, Handling (code HelloWorld Method (code listing), 650 listing), 122 Invoke method, 733 MessageBox with Text, Caption, Buttons, method overloads, 14 and Symbol (code listing), 120 Methods Called Asynchronously, messages Terminating (code listing), 67~74 Messages, Sending to Server (code listing), Move method (directories), 342 617~18 PostMessage method, 731 MessageWmdow class, 727-733 Pull method, 525-526 MessageWmdow, Deriving a Class from Raise method parameters, 214, 955 (code listing), 726-729 ReadToEnd method, 826 scrolling, 69-70 ReadXml method, 394,398, 574 sending,617~18 Remove method (ComboBox control), 143 methods Select method (DataTables), 403 AcceptSocket method, 598 SettingSupport.AppName method, Add method (ComboBox control}, 143 811-812 adding to controls (inherited controls}, Shadowing a Method (code listing), 218 216-217 Show method, 116-120 adding to XML Web service, 64~50 SqlCeCommand class method, 385 AddRow method, 404 SqlCeConnection class method, 381 Appointment object method, 770 SqlCommand class method, 383 App.Path method, 553 SqlConnection class method, 380 BeginWrite and Beginltead methods, 606 SqlDataAdapter and SqlCeDataAdapter CalledOnFormThread method, 732-733 methods,390 CancelCurrentEdit method, 434-435 StringtoHLocal method, 726-727 Clear method (DataSets), 395 SubmitSql method, 537-538 Close method, 556 Task object method, 741 Connect method, 60~06 TreeView methods, 190 Contact object method, 755 underlying methods Control class properties and methods, 201 overriding (inherited controls), 217 CreateDirectory method, 341 shadowing (inherited controls), 217-218 CryptEncryptmethod, 710 Update method DataReader method, 387 Adding to Web Service (code listing), 669 DataRow method, 404 of DataAdapter class, 396 DataSet method, 393 WriteSchema method, 573 DataTable object method, 399 WriteSettingString method, 812-813 DataView method, 407 WriteXml method, 397-398, 572-573 Delete method (directories), 343-344 XML Web service method, 656 DirectCast method, 728 XmlTextWriter method, 562 Directory class method, 333 Microsoft Access, 507 DiscoverDevices method, 624 Microsoft.VisualBasic namespace, 28 Display method (POOM), 744 Microsoft.Wm32.Registry namespace, 17 Dispose method, 112, 520 mobile applications, adding reports to, EncryptString method, 712-713 903-905 EndWrite and EndRead methods, 606 Mobile Explorer, 790 ExecuteDataReader method, 486 Mobile Internet Toolkit, 836 ExecuteNonQuery method, 486-488 mobile networking, 577~31 ExecuteReader method, 492 HTTP protocol, 576-592 ExecuteScalar method, 486-487 asynchronous HTTP requests, 587-592 ExecuteXIniReadermethod,486-487 connectivity, 576-579 Exists method (File class}, 346-349 NetworkStream class, 581 Fill method, 395 SSL, HTTP requests with, 592 Focus method (TextBox control), 185 URis (Uniform Resource Identifiers}, Form method, 105 579-580 GetBytes method, 603 Web pages, retrieving, 581-584 GetCurrentCellBounds method (DataGrid Web requests, exception handling with, control}, 147 584 GetCurrentlnput method, 723-724 Web servers, sending data to, 585-586 GetDirectories method, 344-345 WebRequest and HTTPWebRequest GetFiles method, 346 classes, 580
996 Index
IrDA objects, 619-624 System.Data.SqlServerCe namespace, IrDA clients, developing. 623-624 377-379,378-379,514 IrDA namespace, adding reference to, System.Drawing namespace, 7 620 System.IO namespace, 330-332 IrDA server, developing. 620-623 System.Net.lrDA namespace, 7, 620 TCP objects. SeeTCP objects System.Net.Sockets namespace, 594 tutorial, Working with IrDA, 62~30 System. Text namespace, 603-605 client, creating, 628-629 System. Web namespace, 6 project, opening. 625 System.Wmdows.Forms namespace, 40, settings and configurations, defining, 103 626 System.Xml namespace, 6, 547 testing application, 630 System.XmlJCPath namespace, 16 user interface, 62~26 naming tutorial, Working with TCP, 606-619 connections and objects, 525 clientconnections,addingcodeto practices,222,541 accept, 608-609 native code, defined, 3 client project, opening, 612-613 NavBar, 76-77 client requests, processing, 610-611 .NET Compact Framework (NETCF), 1-32 client user interface, 613 accessing POOM from, 736-740 dummy scans, generating, 61~15 APis, enhanced support for, 25 messages, sending. 617-618 compiler directives, 29-31 paclcets, processing. 611-612 controls (listed), 5 server listening process, 608 data providers, 376 server project, opening, 607 eMbedded Visual Basic (eVB) vs. VB .NET, server, sending data to, 616-617 19-28 server user interface, 607 data access changes, 22-24 settings and configurations, defining, data changes, 19-21 608,614 error handling changes, 24-25 testing application, 618-619 files under VB .NET, 27-28 Mobile Printing Toolkit language structure changes, 21-22 printing reports with, 891-899 installing, 828 HP Print Demo. See HP Print Demo .NET and .NETCF. working between, 28-29 summary,900 omitted from, 14-19 User interface, 897-899 binary serialization, 17 Mode property COM components, leveraging, 18 Adding (code listing), 241 database support, limited, 16-17 Toggling (code listing), 244 file notifications, absence of, 17 module-level objects, declaring, 445, 749, GDI+, no support for, 19 764,779 method overloads, 14 Move method (directories), 342 nonessential controls, 14-16 multiple application instances, running. 81 printing, no support for, 18-19 Multiple Catch Statements (code listing), 947 remoting, no support for, 19 multiple fields, binding to single control, security, 18 425-426 Web services, 18 multithreaded applications, 7 Wmdows registry, access to, 17 XML functionality, 16 overview, 2-13 N class library. See class library, .NET names, XML, 550 Compact Framework namespaces Common Language Runtime (CLR), Configuration namespace, 513, 547 features of, 3--4 IrDA namespace, 620 Web service limitations with, 644 Microsoft.VisualBasic namespace, 28 XML functionality in NETCF, 26-27 Microsoft.Wm32.Registry namespace, 17 networks PocketOutlook namespace, importing. 738 installing applications from, 836 referencing within projects, 10-13 network connections, running emulators System.Data namespace, 6, 22,374-376, without, 913-914 476 network files, 358-359 System.Data.OleDb namespace, 17 networking, mobile. See mobile System.Data.SqlClient namespace, 46-4 7, networking 376-377,483 NetworkStream class, 581
997 Index
New button, displaying, 77 control class, inheriting. 240 New Class, Generating Data to Display Using instance of control, creating, 243 (code listing), 729-730 interface construction, 239 New Menu, Implementing (code listing), Locked property, adding. 240-241 291 Mode property. toggling, 244 New Partnership WJ.Zard, 918-919 OnPaint event, adding. 241-242 New Project dialog box, 646 properties,setting,239 newsgroups,925-926 starting project, 238 nodes, defined, 188 testing the control, 244 Non-Graphical Application project, 41 nonessential controls, 14-16 p Northwind Mobile application, 885-891 Notification API PI Invoke (Platform Invoke) Calling (code listing), 725-726 Calls to Registry, Making (code listing), Setting Up for Call (code listing), 725 708-709 NumericUpDown defined, 689-691 control, 167-168 to Hide and Show the SIP (code listing), properties, 168 693 WIZard, 931 packets 0 building (TCP clients), 603 objects processing names, configuring for forms, 113-114 Packets, Processing (code listing), Object Properties, Working with (code 611-612 listing), 215 TCP, Working with (tutorial), 611-612 passing from XML Web services, 662-665 returning to client (TCP servers), 600 properties, adding (inherited controls), sending to server (TCP clients), 603 214-215 Pages, Retrieving from Web Servers (code OnEnabledChanged event, adding. 311, listing), 582-584 961-962 Paint events, 299-300 OnMouseDown/OnMouseUp events, 312 PaintEventArgs parameter, 299-300 OnPaint events panels adding.241-242,309,960 creating complex interfaces with, 171 OnPaint Event Procedure, Adding (code displaying at startup, 101 listing). 242 Panel-Based Interface tutorial, 96-103 OpenFileDialog control adding code, 100-102 ftwndamentals, 168-170 application testing. 102-103 OpenFileDialog Control, Working With interface. constructing. 97-100 (code listing), 169-170 new project, creating. 97 OpenFileDialog properties, 169 project configuration, 97 operating systems, installing, 907 Panelproperties,l71 operators, new assignment (VB .NET), 22 Panels, linking Scroll Bar to (code listing), OutlookApplication object, defining, 739 117 output, Cab file, 837-839 parameters output folder, defining. 63 through SQL statements, 487-488 overloads Using Stored Procedures with Parameters of ExecuteReader, 492-496 (code listing), 498 method,l4 parentheses, subroutines and ftwnctions Override file, 51 requiring. 21 Overriding Existing Properties (code listing), parsers, XML, 549 215-216 passing pointers, 4 Overview Menu Item, Click Event Procedure passwords for (code listing), 806 importance of remembering. 478 owner-drawn controls protecting databases with, 517-518 creating. 235-237 path identifiers, defined, 580 ftwndamentals, 198 PegHelp tags, 793-794 Owner-Drawn Control, Creating (tutorial), Pen class, 298-299 238-245 pending requests, checking (TCP servers), class module, adding, 240 596-597 configuring project, 238 Personal folder, defined, 335, 339 configuring the control, 243 Personal Information Manager (PlM), 79
998 Index
PictureBoxes PocketConsole, 932 bbldWngto,430-432 PocketOutlook narnespace, importlllg, 738 control, 172-174 pollDlg for asynchronous cmls, 670-671 events,173 pooling. connection, 484 PictureBox, BbldWng to a (code listblg), POOM (Pocket Outlook Object Model), 430-432 735-784 properties, 172 accessblg from NETCE 736-740 usblg,322 Pocket Outlook .NET component, pipe 999 Index testing application, 768-769 sample, 74 user interface, 762-763 types tutorial, Working with Tasks, 7 47-754 Class Library project, 40-41 adding a task, 751-752 Console Application project, 42 application testing, 753-754 Empty project, 42-43 displaying a task, 751 Non-graphical Application project, 41 imports statement, adding, 749 Pocket PC project types, 37-38 loading all tasks, 749-751 Wmdows Application project, 39-40 loading select tasks, 752-753 Wmdows CE project types, 38-39 module-level objects, declaring, 749 projects (tutorial examples) projects, opening, 747 configuring references, adding. 748-749 Building a Binary File Demo, 366 user interface, 748 Building a Text File Demo, 361 Popup events, 270-271 Button, Creating a New, 958 porting rules, 95-96 Custom Dialog Box, Building. 129 ports Images, Displaying Simple, 321 opening for listening (TCP servers), Menus and Toolbars, 285 595-596 New Button, Creating, 308 Ports, Opening and Starting to Listen Owner-Drawn Control, Creating. 238 (code listing), 595 Panel-Based Interface, 97 starting to listen (TCP servers), 596 Scrolling an Image, 324 PositionChanged Event, Saving Data Within creating (code listing), 441 Building a Binary File Demo, 366 PostMessage method, 731 Building a Text File Demo, 360 preconfigured settings, 412-413 Button, Creating a New, 957-958 predefined fragments, 92 Configuration Reader, Creating, 563 printing Contacts, Working with, 762 no support for, 18-19 Custom Dialog Box. Building. 129 printed reports, 879-884 Hello World.NET tutorial, 62 PrinterCE .NET demo, 881~84 Images, Displaying Simple, 320-321 PrinterCE object Menus and Toolbars, 284 configuring, 883 New Button, Creating, 307 creating instance of, 882 Owner-Drawn Control, Creating, 238 working with, 88~91 Panel-Based Interface, 97 PrinterCE variable, dimensioning. 882 Scrolling an Image, 324 PrinterCE.NetCF Component Example Unmanaged DLLs, Creating, 717-718 (code listing), 884 XML Web service, 645-648 PrinterCE.NetCF, printing with, 891 opening PrintJob Function, Calling (code listing), Appointments, Working with, 89~96 776-777 Processor licenses, 480 lrDA, Working with, 625 processor values, Wmdows CE, 832 Web Service Client, Building, 675 ProcessPacket WorkingwithADO.NET, 409-410 function,599-602,611-612 Working with Bound Controls, 443 ProcessPacket Function (code listing), properties, setting 601-602 Building a Text File Demo, 362 ProcessRequest routine, 597-598 Menus and Toolbars, 286 Programming the Web with Visual Basic .NET Owner-Drawn Control, Creating, 239 (Apress, 2002), 586 properties Programming VB .NET: Guide for adding to inherited controls, 203-205 Experienced Programmers (Apress). adding to projects, 312-313, 963-964 810 Build properties, 45-46, 50-51 Programs folder, defined, 335-336, 339 Checking Value of (code listing), 212-213 ProgressBars Common properties, 44-48 control. 17 4-176 Configuration properties, 49-51 properties, 175 Debugging properties, 49 Working With (code listing), 176 Deployment properties, 51 project references, viewing, 10 Device properties, 47-48 projects General properties, 44-45 adding files to, 921-922 Imports properties, 46-47 fundamentals for creating, 35-43 Optimizations properties, 50 1000 Index Properties, Overriding Existing (code ReadXml method, 394, 398, 574 listing), 215-216 records Properties, Saving and Returning (code adding new, 448-449 listing), 204 deleting, 449 Property Pages dialog box, 43-44 moving between, 448 Property Procedure, Defining (code rectangles listing), 132-133 drawing, 301-302 Property Procedure, Read-Only (code Rectangles, Drawing with Different Colors listing)' 206 (code listing), 301-302 Property Procedure, Write-Only (code reference material. See also resources listing), 206-207 Applied .NET Attributes (Apress, 2003), 690 property values, restricting (inherited Programming the Web with V'zsual Basic controls), 210-213 .NET(Apress, 2002), 586 Reference Path properties, 47 Programming VB .NET: Guide for protocols, Internet, 579 Experienced Programmers (Apress, Provider directive (INF file), 841 2001), 810 publications, creating (SQL Server CE), V'zsual Basic .NET and .NET Platform: 470-476 Advanced Guide (Apress, 2001), 810 pulls and pushes references defined, 522-523 adding to Pocket Outlook .NET, 737-738 Pull method, 525-526 adding to PrinterCE.NetCF component, 882 pulling data in RDA, 524-527 adding to tutorial projects Pushing Data Back to Server (code listing), Appointments, Working with, 778 527-528 Button, Creating a New, 958 pushing data in RDA, 527-528 Contacts, Working with, 763 Images, Displaying Simple, 321 New Button, Creating, 307 Q Scrolling an Image, 324 Query Analyzer (SQL Server CE) Tasks, Working with, 748-749 fiwndamentals,479-480 Working with Bound Controls, 445 with protected database, 518 viewing project, 10 querystrings,defined,580 referencing assemblies, 9-10 namespaces within projects, 10-13 R regions and polygons, drawing, 303-304 RadioButtons registry control, 176-178 adding debugging setting to, 835 properties, 177 entry syntax, 847 RadioButtons, Handling Multiple (code flag values, 848 listing), 178 Registry API Calls, Declarations for (code Raise method parameters, 214, 955 listing), 705-706 RDA (Remote Data Access), 522-528 Registry, Reading and Writing (code authenticating with liS, 528 listing)' 825-826 fiwndamentals,522-523 RegistrySettings pulling data in, 524-527 class, 824-825 pushing data back to server, 527-528 RegistrySettings Class, Constructing RDA vs. replication, 544-545 (code listing), 825 RdaBatchOption Enum, 528 root values, 848 RdaTrackOption Enum values, 526-527 settings,824-826 vs. replication, 544-545 Wmdows Simple RDA (code listing), 524 access to, 17 read-only properties setting up for call. See Wmdows registry adding (inherited controls), 205-206 remote data access (RDA). See RDA (Remote Read-Only Property Procedure (code Data Access) listing)' 206 remote debugging (SDE), 34 ReadElementString method of remoting, no support for, 19 XmlTextReader, Using (code listing), Remove method (ComboBox control), 143 553-554 renaming forms, 113-114 readers and writers, 354 replication readme file, creating, 865 arctrltecture,539 ReadToEnd method, 826 merge. See merge replication 1001 Index ReportCE newsgroups, 925-926 Pocket PC report generation with, 900-906 tralllll1g, 935 Report CE Demo, 900-905 Web sites, 926--930 summary, 906 developer information and tools, Printing Reports Through (code listing), 926--928 904-905 developer programs, 926 Report View, Controlling (code listing), 879 Pocket PC hardware and accessories, reports,producll1g,869-906 928-930 background and basics, 869-870 Pocket PC software, 928 Display Report Button Click Event, responses Contents of (code listing), 872, Asynchronous Responses, Processll1g 877-878 (code listing), 589-590 HPMobilePrintSDKWrapper Module (code convertll1g to strll1gs (TCP clients), 604-605 listing), 896 reading (TCP clients), 604 HTML reportlllg sample, 870-876 response packets, building (TCP servers). data gatherll1g. 872-873 600 displaying reports, 875-876 Responses, Reading (code listing), 590-592 report formattlllg, 873-874 from server, waiting for (TCP clients), 604 savingreports,874-875 restoration, Pocket PC ll1terface, 82 HTML reports, producll1g, 870 Result Sets, Retrieving Multiple (code listing), HTMLViewer alternative approach, 876-879 495-496 displaying reports, 878 Ricklnk control, 934-935 report view, configuring, 878-879 Roof, Larry (author Web site), 935 summary, 879 root element, defined, 549 HTMLViewer Control, Displaying Reports root nodes, 188 ll1 (code listing), 878 RoundButton class, 312 Mobile Printing Toolkit, prll1ting reports rows with, 891-899 adding to tables, 404-405 HP Print Demo. See HP Print Demo DataTable Select Method, Filtering Rows summary, 900 Usll1g (code listing), 403 user ll1terface, 897-899 defined,399 Pocket IE, Launching and Displaying the filtering, 539, 543-544 Report (code listing), 875 modifying,405 printed reports row-level tracking. 544-545 fundamentals, 879-880 Tables, Adding Rows to (code listing), PrinterCE .NET demo, 881-884 404-405 PrinterCE object, working with, 884-891 viewll1g contents of, 405 with PrinterCE.NetCF, 880-884 RTF Files, Displaying Contents of (code PrinterCE.NetCF Component Example listing), 897 (code listing), 884 ruggedized Pocket PCs, 454 PrinterCE.NetCF, printing with, 891 Runtime Errors, Recovering from (code PrintJob Function, Calling (code listing), listing), 945 895-896 Report CE, Pocket PC report generation with,900-906 s Report CE Demo, 900-905 sample projects, 7 4 summary, 906 Save Button, Coding (code listing), 364, Reports, Storing ll1 Files (code listing), 369-370 874-875 SaveFileDialog requests control, 178-180 Request State, Class Used to Store (code properties, 179 listing), 587-588 SaveFileDialog Control. Working With Requests, Initiating (code listing), 588-589 (code listing), 180 RequestState class, 587-588 schemas and responses (TCP servers), 600-602 data, 573-575 resources,925-935 DataSets, Usll1g Schemas with (code developer tools, 930-935 listing), 574 controls and components, 932-935 scheme identifiers, defined, 580 hardware tools, 930 scrolling programmll1g/testing/ deployment, direction, changll1g, 70 930-932 forms, 116--117, 193 1002 Index messages,69-70 server tools, installing (SQL Server CE), Scroll Bars, Linking to Panels, (code 457-465 listing), 117 server user interface, 607 Scrolling an Image (code listing), 327 Submitting Commands to Server (code Scrolling an Image (tutorial), 323-328 listing), 538 form-level variables, creating, 325 service packs, SQL CE, 456 image, loading, 326 settings project configuration, 324 application. See application settings project creation, 324 and configurations, defining references, adding. 324 Working with IrDA (tutorial), 626 scrolling code, adding. 327-328 Working with TCP (tutorial), 608, 614 scrolling, setting up timer for, 326 registry. See registry settings start button, adding, 325 SettingSupport Scrolling Forms, Using ScrollBar to Control class, 811 (code listing), 193 SettingSupport.AppName method, VSrollBars 811-812 control, 191-193 setups,creating,827-868 properties, 192 Cab files, building, 836-855 Secure Socket Layer (SSL). See SSL (Secure advanced Cab files, 839-855 Socket Layer) basic Cab files, 836-839 security, 18 fundamentals,827-836 Integrated Security, Using (code listing), .NET Compact Framework, installing. 828 534-535 applications, installing. See applications, setting directory, 529 installing setting in liS, 530-532 SQL Server CE, installing. 829 setting in SQL Server, 532-535 testing setups, 867-868 unmanaged code and, 18 tutorial, Building a Custom Cab Select method (DataTables), 403 Installation, 859-867 SELECT statements and explicit field names, Application Manager INI file, creating, 475 863 sends and receives, asynchronous TCP, 606 Application Manager, monitoring, 864 serialization.~.575-576 Cab files, generating, 862-863 Server Agent, SQL CE, 455-456 desktop setup, building, 864-865 server-based data, 483-509 INF file, building, 859-862 DataSets and DataAdapters, 499-502 setup,running,866-867 fundamentals, 483-485 tutorial, Examining a Basic Cab Build, SQL error handling, 505-508 855-859 SqlCommand object, querying databases batch file, viewing generated, 859 with,485-499 custom cabs, building, 859 ExecuteDataReader, 488-491 INF file, viewing generated, 855-858 ExecuteReader, overload of, 492-496 Shadowing a Method (code listing), 218 SQL statements, passing parameters Shared keyword, 693-694 through, 487-488 shares, copying files from, 922-923 stored procedures, 496-499 shell, help file, 799 transactions,502-505 SHGetSpecialFolderPath function servers arguments for, 334 connecting to, 623-624 GetSpecialFolderPath Wrapper Function connections, establishing (TCP clients), (code listing), 338-339 602-603 SHGetSpecialFolderPath Function, creating, 626-628 Declaring (code listing), 337-338 developing IrDA, 620-623 SHGetSpecialFolderPath, Values Used with developing TCP. See under TCP objects nFolder Argument of (code listing), 337 identifiers, defined, 580 shortcut files (help systems) listening process, 608 creating help, 798 Sending Data to Server (code listing), fundamentals, 792 616-617 placing help, 798-799 Sending Messages to Server (code listing), shortcut syntax, 849 617-618 Showmethod,118-120 Server-Side Code That Retrieves Values ShowPanel Routine to Handle Passed (code listing), 586 Hiding/Displaying Panels (code server side (mobile applications), 586 listing), 100-101 1003 Index SHSiplnfo for Visible State, Making a Call to Loading DataTables from (code listing), (code listing), 719 413-414 simple controls, binding to, 424-425 merge replication, 460-461 single user database, 480 opening connection to, 381 SIP (Soft Input Panel) provider, 376-377 avoiding, 92 retrieving data from, 413-414 displaying, 156 Server Agent, 468 Displaying SIP (code listing), 156 service packs, 908 Hiding SIP (code listing), 157 setting security in, 532-535 P/lnvoke to Hide and Show the SIP (code and SQL Server CE, installing, 908-909 listing), 693 SQL Server Database SHSiplnfo for Visible State, Making a Call Filling DataSets from (code listing), 391 to (code listing), 719 Saving DataSets to (code listing), SIP button, displaying, 77-78, 80 396-397 Siplnfo Unmanaged library, Function SQL Server, Executing Commands Against Declarations for (code listing), 723-724 (code listing), 384 SipOperation class, 693, 722-723 SQL Server CE unmanaged code example, 692-fi96 Books Online, 479 SizeMode property values, 173 component, testing, 420 skins,emulato~919-920 database classes, 516-517 smart device extensions (SDE), 33-74 executing commands against, 386-387 basics, 33-34 Executing Commands Against (code context-sensitive menus and, 266 listing), 384 languages supported by, 34 installing, 829 Smart Device Application WIZard, 36-37 Loading DataTables from (code listing), 415 tutorial, Hello World.NET, 61-74 opening connection to, 382 code, adding, 68-70 provider, 377-379 deploying, 73-74 retrieving data from, 414-415 interface, building, 66-67 SQL Server CE Database, Filling DataSets project creation, 62 from (code listing), 391-392 project properties, setting, 62-fi5 SqlCeCommand class, 385-386 testing, 70-73 SqlCeConnection class, 381-382 within VS .NET IDE, 34-fil SqlCeDataAdapter class, 391-392 applications, adding code to, 54-55 SqlCeDataReader applications, testing, 57.-fiO class, 388-389 debugging applications, 60-fil SqlCeDataReader, Creating (code eventprocedures,accessing,56 listing)' 537 files, adding, 56-57 SQL Server CE, introduction to, 453-481 forms, designing, 51-53 architecture,455-456 new project, creating, 35-43 connections, testing, 4 76-478 project properties, setting, 43-51 data, hiding, 478-479 SDE controls, 53-54 installing SQL Server CE 2.0, 456-476 Wmdows Forms, code behind, 55-56 authentication choices, 465-466 smart devices, defined, 2 development tools, installing, 457 Smartphone SDK, 2 distributors, setting up, 466-470 snapshot directory, 469 publications, creating, 470-476 snapshot folders, 462, 469-470 server tools, installing, 457-465 Socket class, 592 licensing,480-481 SolidBrush class, 298-299 potential uses for, 453-455 SourceDiskFiles section (INF files), 849-851, Query Analyzer, 479-480 862 SQL (Structured Query Language) SourceDiskNames section (INF files), 861 Client Errors, Handling Multiple (code special folders. See folders, special listing), 508 SQLCE error handling, 505-508 Dropping Tables in (code listing), 536 SqlClient Errors, Handling (code listing), Replication (code listing), 540-541 506-507 Web sites, 909 SqlCommand class, 383-384 working with, 535-537 SqlCommand object, querying databases SQLServer with,485-499 component, testing, 419-420 ExecuteDataReader, 488-491 executing commands against, 384-385 ExecuteReader, overload of, 492-496 1004 Index SQL statements, passing parameters Strings section (INF rues), 841-842 through, 487-488 StringtoHLocal method, 726-727 SqlCommand Object, Exploring (code structures listing), 486-487 DisplayStructurelisting Routine (code stored procedures, 496-499 listing), 661~62 SqlConnection class, 380, 485 passing from XML Web services, 65H62 SqlDataAdapter class, 390-391 StructureDemo Web Method (code listing), SqlDataReader 661 class, 387-388 Structures, Creating Web Methods That SqlDataReader Example (code listing), Return (code listing), 65~60 491 Structures, Defining for Use with Web SqlDataReader, Getting Data Back in Methods (code listing), 659 (code listing), 493-494 stylus, moving off button, 313-314 SqlDataReader Object, Looping Through subdirectories (code listing), 388 determining within directories, 344-345 ssceerror20en.dll, 507 Iterating Through the Array of (code SSL (Secure Socket Layer) listing)' 345 encryption, 532 submenus, 256 HTIP requests with, 592 SubmitSql method, 537-538 start button, adding, 325 Submitting Commands to Server (code Start Menu folder, defined, 336, 340 listing)' 538 StartUp folder, defined, 336, 340 Subprocedures, Implementing Simple startup form, configuring, 114 Method with (code listing), 216-217 status bars Subroutines, Using to Provide Common building, 281-283 Functionality (code listing), 519-520 StatusBar control, 181-182, 281-282 subscription types (SQL Server), 472-473 StatusBar Control, Setting Text Property of symbols, displaying MessageBox with, (code listing), 283 120-122 StatusBar properties, 181, 282-283 synchronization, data, 454 StatusBar, Updating a (code listing), 182 SyncLock block statements, 731 Stock Quotes Returned as XML (code listing), System Crypto Methods, Calling (code 684 listing), 713-715 Stock Service System help, 81 adding Web reference for, 685 System.ComponentModel.Component class, Calling (code listing), 685-686 245 viewing in browser, 682-683 System.Configuration class, 809 viewing XML returned from, 684 System.Data namespace, 6, 22, 374-376, Stoplistener variable, 594 476 stored procedures, 496-499 System.Data.OleDb namespace, 17 Stored Procedures, Using (code listing), System.Data.SqlClient namespace, 46-47, 497 376-377,483-484 Stored Procedures, Using with Parameters System.Data.SqlServerCe namespace, (code listing), 498 377-379,378-379,514 Stream.Write and Stream.Read classes, 581 System.Drawing class, 4 StreamWriter System.Drawing namespace, 7 and StreamReader classes, 353-356 System.IO namespace, 330-332 Writing to Files Using (code listing), 355, System.IO namespace classes, 330-331 359 System.Net classes, 581 strings System.Net.lrDA namespace, 7, 620 connection, 525 System.Net.Sockets namespace, 594 converting responses to, 604-605 SystemPowerStatus members, 702-703 drawing, 306 System.SR assembly, 8 EncryptString method, 712-713 System. Text namespace, 603 English language macro strings, 852 System. Web namespace, 6 hard coding, 485,513 System.Wmdows.Forrns class, 4 local connect strings, 536 System.Wmdows.Forrns namespace, 40, String class, 817 103 Strings Module System.Wmdows.Forrns.MessageBox class, Explicitly Referencing (code listing), 118 13 System.Xml namespace, 6, 547 Working with (code listing), 12-13 System.Xml.XPath namespace, 16 1005 Index T responses, reading, 604 server connection, establishing, 602-603 TabControl control, 182-183 TCP servers, developing, 593-602 table of contents basic server, 594 help, 799--800 client requests, accepting, 597-598 Table of Contents, HTML Defining (code clients, receiving data from, 598-599 listing}, 800 data packets, processing, 599 tables packets, returning to client, 600 Adding Rows to (code listing), 404-405 pending requests, checking for, 596-597 displaying, 148,417-418 ports, opening for listening, 595-596 Displaying Tables in DataGrid (code ports, starting to listen to, 596 listing), 148 requests and responses, 600-602 SQL CE, Dropping Tables in (code listing), response packets, building, 600 536 Working with TCP (tutorial), 606-619 Tables, Adding Data to (code listing), 519 client connections, adding code to tags accept, 608-609 HTML (help files), 795 client project, opening, 612-613 XML,549 client requests, processing, 610-611 taps, button, 280-281 client user interface, 613 target (responding} controls, configuring, dummy scans, generating, 614-615 268-269 messages, sending, 617-618 tasks, 740-746 packets, processing, 611-612 adding, 745-746, 751-752 server listening process, 608 Adding Tasks (code listing), 745, 752 server project, opening, 607 displaying, 7 44 server, sending data to, 616-617 Displaying Tasks (code listing), 744, 751 server user interface, 607 modifying, 746 settings and configurations, defining, Modifying Tasks (code listing}, 746 608,614 retrieving all tasks, 741-742 testing application, 618-619 retrieving select tasks, 7 43 templates Task object, 740-741 Class,34 Tasks property, 740 SDE,33 Tasks, Retrieving All (code listing), 742 testing Tasks, Retrieving List of All (code listing}, on all devices, 94 750 applications Tasks, Retrieving Select (code listing), 743 Appointments, Working with, 783-784 Tasks, Selecting Subset of (code listing), Building a Binary File Demo, 370-371 753 Building a Text File Demo, 364-365 Tasks, Working with (tutorial), 747-754 Button, Creating a New, 970-972 adding a task, 751-752 Contacts, Working with, 768-769 application testing, 753-754 Custom Dialog Box, Building, 134 displaying a task, 751 devices, deploying to, 60 imports statement, adding, 749 devices, testing on, 60, 72-73 loading all tasks, 749-751 emulators, deploying to, 59 loading select tasks, 752-753 emulators, testing in, 58--59, 70-71 module-level objects, declaring, 749 Hello World.NET, 70-73 projects, opening, 747 lrDA, Working with, 630 references, adding, 748-7 49 Menus and Toolbars, 295 user interface, 748 New Button, Creating, 314-315 TCP (Transmission Control Protocol) Panel-Based Interface, 102-103 asynchronous TCP communication, running a test, 58 605-606 TCP, Working with, 618-619 Client Connections, Watching (code Web Service Client, Building, 686-687 listing}' 608-609 Working with ADO.NET, 419-421 Socket class, 592 Working with Bound Controls, 449-450 TCP clients, developing, 602-605 controls, 234-235, 244 data packets, building, 603 setups, 867-868 data packets, sending to server, 603 XML Web service, 650-653 responses, converting to strings, text 604-605 displaying MessageBox with, 119-120 responses from server, waiting for, 604 Hybrid TextBox, Creating (tutorial), 222-235 1006 Index Text File Demo, Building (tutorial), transactions 360-365 fundamentals, 502-505 coding applications, 362-364 How to Code (code listing), 503 interface, building, 361 'Ii'eeViews project configuration, 361 control, 188-191 project creation, 360 events, 189 properties,setting,362 Loading (code listing), 190-191 testing applications, 364-365 methods, 190 Text File, Reading in All in One Read (code properties, 189 listing), 358 Try-Catch-Finally TextBox control, 183-185 Error Handling Structure (code listing), 25 Binding Two TextBox Controls (code Statement (code listing), 946 listing), 446--447 tutorial linking HScrollBar to TextBox (code contacts listing), 153 modifying, 760-761 Starting with (code listing), 202 tutorials TextBox events, 185 ADO.NET, Working with, 409-421 TextBox properties, 184 Appointments, Working with, 776-784 TextReader and TextWriter classes, 354, Beyond Anonymous, 528-538 356-357 Binary File Demo, Building, 366-371 Throw statements, triggering exceptions Bound Controls, Working with, 443-450 with, 955 Button, Creating a New, 957-972 Tick event (Timer control), 186, 596-597 Button, Creating New, 306-315 Timeout property (Request object), 584 Cab Build, Examining a Basic, 855-859 Timer control and properties, 185-186 Configuration Reader, Creating, 563-567 toolbars Contacts, Working with, 761-769 coding,294-295 Custom Dialog Box, Building a, 129-134 constructing,273-281 Custom Installation, Building a, 859-867 button taps, responding to, 280-281 Hello World.NET, 61-74 lmageUst control, 273-277 Help File, Building a, 796-802 Tooffiar control, 277-280 Hybrid TextBox, Creating a, 222-235 reasons for using, 272-273 Images, Displaying Simple, 320-323 Tooffiar buttons, defining, 289-290 lrDA, Working with, 624-630 Tooffiar control, 186, 277-280 Menus and Toolbars, 283-295 TooffiarButton Collection Editor, 279 Owner-Drawn Control, Creating an, Toolbars and Menus tutorial, 283-295 238-245. context-sensitive menu, coding, Panel-Based Interface, 96-103 292-294 Scrolling an Image, 323-328 lmageUst, loading, 289 Tasks, Working with, 747-754 interface, building, 285 TCP, Working with, 606-619 menu, building, 286-288 Text File Demo, Building, 360-365 menu,coding,290-292 Unmanaged DLL, Creating an, new project, creating, 284 717-733 project configuration, 285 Web Service Client, Building a, properties,setting,286 674-687 testing application, 295 typed DataSets, 644 Tooffiar buttons, defining, 289-290 Tooffiar,coding,294-295 tools u development, 930-935 UDDI (Universal Description, Discovery and help system, 790-791 Integration), 635 topics underlying methods adding help, 800-801 overriding (inherited controls), 217 finding help, 788 shadowing (inherited controls), 217-218 viewing help, 788-789 underlying properties, overriding (inherited 'Ii'ackBars controls), 215-216 control, 186-188 unmanaged code, 689-734 properties, 187 cryptography, using on devices, 709-716 training, development, 935 making the call, 712-716 'Ii'ansact-SQL (T-SQL), running on remote setting up for call, 710-712 server, 537-538 defined, 3 1007 Index device power information, obtaining v (example), 696-704 vanilla calling system, 700-704 systems, defined, 867 variables setting up to call API, 696-700 declaring v&ues while dimensioning, Dlllmport, 690-691 20 Dlls, writing, 716-717 dimensioning, 68 Variant data type, 19-20 ~dament&s,689-690 reasons for using, 691-692 VB.NET Soft Input Panel (SIP) example, 692-696 assignment operators, 22 data types, 20 tutori&, Creating an Unmanaged DLL, Programming 717-733 the Web with VISual Basic .NET(Apress, 2002), 586 build type, setting, 722 code to query current SIP, adding, Programming VB .NET: Guide for Experienced Programmers (Apress), 720-721 810 ~ctions to export, adding, 718-720 VISual Basic .NET and .NET Platform: include directives, adding, 720 Advanced Guide (Apress, 2001), 810 library, building and deploying, 722 Version section (INF files), 841, 860 link libraries, adding, 718 versioning, handling, managed code option, 724-727 222 viewing project references, 10 MessageWmdow class, 727-733 views, report, 878-879 project creation, 717-718 Directory Creation unmanaged library, calling, 722-724 VJ.rtu& WIZard, 458-465 Visu& Basic error handling, 941-946 Wmdows registry, working with, Err object, 944 704-709 implementing, making the call, 707-709 942-944 runtime errors, recovery from, 945-946 setting up for call, 705-707 VB-Style Error Handling, Implementing Unsafe keyword, 716, 724 (code listing), 942-943 updates Visu& Basic support, returning to XML Web services, 668-669 7 VS.NET Update method home page and support, Adding to Web Service (code listing), 908 IDE, smart device extensions within. See 669 smart device extensions (SDE) DataAdapters and, 396 launching emulators from within, 911-912 UriFormatException, 584 URis (Uniform Resource Identifiers), role of, version 2003, installing, 908 VSrollBars 579-580 control, 191-193 usage rules, 93-95 properties, 192 battery usage timing, 94 language ~ctionality, 94 loc& language ~ctionality, 95 w physic& locations, accommodating, 94 wait cursor, displaying, 80 testing on all devices, 94 Weather Service users adding Web reference for, 680 controls, 196-197 Calling (code listing), 680-682 left-handed users, 193 viewing in browser, 676-677 response to MessageBox, 122 viewing XML returned from, 677-680 user input, minimizing, 90 Web methods. See also XML Web services user interfaces Arrays, Returning from Web Methods Appointments, Working with, 777-778 (code listing), 657 Contacts, Working with, 762-763 ClassDemo Web Method, Calling (code lrDA, Working with, 625-626 listing), 665 Mobile Printing Toolkit, printing reports DsDemo Web Method with,897-899 Calling Asynchronously (code listing), Tasks, Working with, 7 48 671 Web Service Client, Building, 675-676 Calling Asynchronously with a Callback Working with Bound Controls, 444 (code listing), 672 user permissions, setting, 462-465 Calling (code listing), 667-668 UserSettings class, 809 UTF (Unicode Transformation Format), structures Creating Web Methods That Return 706 (code listing), 659-660 1008 Index Defining for Use with Web Methods OpenNETCF.org, 734 (code listing), 659 PllnvokeWJZard, 931 StructureDemo Web Method (code Pocket Outlook .NET, 736, 933 listing), 661 Pocket PC Web Method, Creating One That Returns hardware and accessories, 928-930 an Object (code listing), 663~64 software, 928 Web Method, Defining the Class That Will PocketConsole, 932 Be Used with (code listing), 663 PrinterCE.NetCF component, 879 Web Method That Returns a DataSet (code Report CE, 879, 900 listing), 66~67 Ricklnk control, 934-935 WebMethod Attributes, Adding (code Roof, Larry (author), 910, 935 listing), 649 SQLCE, 909 Web pages, retrieving, 581-584 SQL Server CE Web requests, exception handling with, 584 service packs, 456 Web servers version 2.0 download, 457 Retrieving Pages from (code listing), SQL Server service packs, 908 582-584 training, 935 sending data to, 585-586 UDDI Web site, 635 Web Service Client, Building (tutorial), Unicode, 706 67~87 unmanaged code articles, 734 project, opening, 675 VS .NET home page and support, 908 Stock service WmZip,937 adding Web reference for, 685 Wise Solutions installation software, 835 calling, 68~86 WebRequest and H'ITPWebRequest classes, viewing in browser, 682~3 580 viewing XML returned from, 684 Wmdows2000 testing application, 68~87 configuring Loopback adapter under, user interface, 67~76 914 Weather service installing Loopback adapter under, 913 adding Web reference for, 680 Wmdows Application project, 39-40 calling,68~82 WmdowsCE viewing in browser, 67~77 processor values, 832 viewing XML returned from, 677~80 project types, 38-39 Web services Wmdows Forms, 103-105 basics, 6 code behind, 55-56 cookies unsupported in, 18 Form events, 105 populating DataSets from, 394 Form methods, 105 saving DataSets to, 398 Forms class, properties of, 104-105 working with, 26 Wmdows Form Designer, 55-56, 106-107 XML. See XML Web services Wmdows registry, 704-709 Web sites, 926-930 access to, 17 ActiveSync download, 908 making the call, 707-709 ADOCE .NET Wrapper, 453 P/lnvoke Calls to Registry, Making (code codehound, 551 listing), 708-709 Concurrency Control and Recovery in setting up for call, 705-707 Database Systems (download), 505 \ Wmdows \Start Menu folder, defined, 336 DateTimePicker control, 934 \Wmdows\StartUp folder, defined, 336 developer information and tools, 926-928 WM_HELP message, 80 developer programs, 926 write-only properties, adding (inherited device development overview, 910 controls), 206-207 Document List component, 934 Write-Only Property Procedure (code listing), eMbedded Visual Tools, 696, 909 206-207 EzSetup utility download, 864 Write Xml method, 397-398, 556, 572-573 GotDotNet POOM sample, 736 writers and readers, 354 HTMLViewer control, 876, 934 WriteSchema method, 573 Identity component, 934 WriteSettingString method, 812-813 InstallShield installation software, 835 WSDL (Web Services Description IP*Works controls suite, 935 Language) Javaworld, 551 Contents of Demo Web Service's WSDL File licensing, 480 (code listing), 638-643 Mobile Printing Toolkit, 879 defined, 638 1009 Index X XmlTextWriter, Writing XML Through (code listing), 555 XML (eXtensible Markup Language) XMLWriteMode argument, 398 Application XML config File (code listing), XML Web services, 633-688 818 9-Day Forecast Returned as XML (code basics of, 547-563 listing),677-680 attributes, using in XML documents, Arrays, Returning from Web Methods 556-563 (code listing), 657 XML documents, 547-551 ASP.NETWeb Service Template, Starter XmlTextReader, 551-556 Code Provided with (code listing), 648 data schemas, 573-575 asynchronouscallsto,670-674 DataSets, Massaging XML Data with (code aborting asynchronous calls, 673-674 listing), 571-573 callbacks,672-673 DOM (Document Object Model) polling. 670-671 navigation of documents ClassDemo Web Method, Calling (code reading elements with, 568-570 listing), 665 writing elements with, 570-571 creating. 644-653 saving DataSets as, 397-398 default class name, modifying. serialization,575-576 648-649 methods, adding. 649-650 testing Load component, 421 project creation, 645-648 testing Save component, 420-421 testing. 650-653 tutorial, Creating a Configuration Reader, DataSet Updates, Saving from Client 563-567 Application (code listing), 669 ConfigReader class, creating, 565-567 Demo Web Service's DISCO File, Contents controls, adding to form, 564-565 of (code listing), 637 project creation, 563 Demo Web Service's WSDL File, Contents XML me, adding. 564 of (code listing), 638-643 using for local data storage, 27 DisplayCallback Routine (code listing), XML Config File, Reading Values from 672-673 (code listing), 819-a20 DisplayStructureListing Routine (code XML Document, 26 listing), 661-662 XML Document, Standard (code listing), DsDemo Web Method 548-549 Calling Asynchronously (code listing), XML Document Using Attributes (code 671 listing), 549 Calling Asynchronously with a Callback XML me settings, 81H23 (code listing), 672 reading from, 819-a21 Calling (code listing), 667-668 writingto,821-a23 Forecast, Displaying for a Single Day (code XMLmes listing),682 adding,564 fundamentals, 633-644 Loading DataTables from (code listing), determining services offered, 638-644 415-416 finding XML Web services, 635-636 populating DataSets from, 394 obtaining descriptions of services, retrieving data from, 415-416 637-638 saving data to, 418-419 limitations with NETCF, 644 Saving DataSets to (code listing), 419 Methods Called Asynchronously, XML functionality. 16, 26-27 Terminating (code listing), 673-674 XML Reader, 26 passing data from, 656-669 XML Writer, 26 arrays, 657-658 XmlDocument class, 821-a22 DataSets, 665-668 XmlTextReader objects, 662-665 class, 558, 823 structures,658-662 ReadElementString method of updates, returning to XML Web services, XmlTextReader, Using (code listing), 668-669 553-554 Stock Quotes Returned as XML (code XmlTextReader, Reading Files with (code listing), 684 listing),551-552 Stock Service, Calling (code listing), XmlTextWriter 685-686 class, 554-555 StructureDemo Web Method (code listing), methods, 562 661 1010 Index Structures, Creating Web Methods That Update Method, Adding to Web Service Return (code listing), 659-660 (code listing), 669 Structures, Defining for Use with Web Weather Service, Calling (code listing), Methods (code listing), 659 68~82 tutorial, Building a Web Service Client, Web Method 674-687 Calling One That Returns an Array (code project, opening, 675 listing). 658 Stock service, adding Web reference for, Defining the Class That Will Be Used 685 with (code listing), 663 Stockservice,calling,685-686 That Returns a DataSet (code listing), Stock service, viewing in browser, 66~67 682~83 WebMethod Attributes, Adding (code Stock service, viewing XML returned listing). 649 from, 684 Web service clients, creating, 653~56 testing application, 68~87 Web references, adding. 65~55 user interface, 675-676 Web service class instance, creating. Weather service, adding Web reference 655-656 for, 680 Web service methods, 656 Weather service, calling. 68~82 XPath, 569 Weather service, viewing in browser, 67~77 Weather service, viewing XML returned z from, 677~80 zero-bound arrays, 21 lOll JOIN THE APRESS FORUMS AND BE PART OF OUR COMMUNITY. You'll find discussions that cover topics of interest to IT professionals, programmers, and enthusiasts just like you. If you post a query to one of our forums, you can expect that some of the best minds in the business-especially Apress authors, who all write with The Expert's Voice™-will chime in to help you. Wrry not aim to become one of our most valuable partic• ipants {MVPs) and win cool stuff? Here's a sampling of what you'll find: DATABASES PROGRAMMING/BUSINESS Data drives everything. Unfortunately, It Is. Share informa~on, exchange ideas, and discuss any database Talk about the Apress line of books that cover software programming or administra~on issues. methodology, best pra~ces. and how programmers interact with the 'suits.' INTERNET TECHNOLOGIES AND NETWORKING WEB DEVELOPMENT/DESIGN Try living without plumbing (and eventually 1Pv6). Ugly doesn't cut It anymore, and CGIIs absurd. Talk about networking topics including protocols, design, Help is in sight for your site. Rnd design sol~ons for your administra~on, wireless, wired, storage, backup, certifica~ons, projects and get ideas for building an interactve Web s~e. trends, and new technologies. JAVA SECURITY We've come a long way from the old Oak tree. Lots of bad guys out there--the good guys need help. Hang out and discuss Java in whatever flavor you choose: Discuss computer and network security issues here. Just don't let J2SE, J2EE, J2ME, Jakarta, and so on. anyone else know the answers! MAC OS X TECHNOLOGY IN ACTION All about the Zen of OS X. Cool things. Fun things. OS Xis both the present and the future for Mac apps. Make lfs after hours. It's ~me to play. Whether you're into LEGQ® sugg~ons, offer up ideas, or boast about your new hardware. MINDSTORMSTM or turning an old PC into a DVR, this is where technology turns into fun. OPEN SOURCE WINDOWS Source code Is good; understanding (open) source Is better. No defenestratlon here. Discuss open source technologies and related topics such as Ask qu~ons about all aspects of Windows programming, get PHP. MySQL, Linux, Pe~. Apache, Python, and more. help on Microsoft technologies covered in Apress books, or provide feedback on any Apress Windows book. HOW TO PARTICIPATE: Go to the Apress Forums site at http://forums.apress.com/. Click the New User link.