Windows CE 2 Programming for Dummies


Whether you're new to Windows programming or are an experienced developer, you can begin writing and building great Windows CE 2 applications quickly and easily with Windows CE 2 Programming For Dummies as your guide. Windows CE 2 Programming For Dummies puts the complex, 32-bit computing power of CE 2 at your fingertips with clear, concise explanations and step-by-step procedures for building a variety of CE-based applications, from palmtop and hand-held PCs to non-computer ...
See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (9) from $1.99   
  • New (1) from $50.50   
  • Used (8) from $1.99   
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any coupons and promotions
Seller since 2015

Feedback rating:



New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

Brand New Item.

Ships from: Chatham, NJ

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Page 1 of 1
Showing All
Sort by
Sending request ...


Whether you're new to Windows programming or are an experienced developer, you can begin writing and building great Windows CE 2 applications quickly and easily with Windows CE 2 Programming For Dummies as your guide. Windows CE 2 Programming For Dummies puts the complex, 32-bit computing power of CE 2 at your fingertips with clear, concise explanations and step-by-step procedures for building a variety of CE-based applications, from palmtop and hand-held PCs to non-computer devices, such as VCRs, cars, and even washing machines!

CE 2 comes without all the baggage and heavy overhead of Windows 95 or Windows NT, making it fun and enjoyable to use. By choosing the right CE 2 building blocks (modules) and tapping into the sample source code that's on the bonus CD-ROM included with Windows CE 2 Programming For Dummies, you'll be able to build your own dynamic applications in CE 2 and install them on a Windows CE device from your desktop computer instantly and successfully.

Read More Show Less

Product Details

  • ISBN-13: 9780764503047
  • Publisher: Wiley, John & Sons, Incorporated
  • Publication date: 2/15/1998
  • Series: For Dummies Series
  • Pages: 350
  • Product dimensions: 7.41 (w) x 9.23 (h) x 1.08 (d)

Table of Contents


About This Book
System Requirements
And What About You?
How to Use This Book
How This Book Is Organized
Part I: Building a Windows CE Application
Part II: Discovering the Unique Features of Windows CE
Part III: Peeking Behind the Scenes
Part IV: Working with the Shell and the Object Store
Part V: Improving Desktop Connectivity and Communications
Part VI: The Part of Tens
About the CD Appendix
Icons Used in This Book
So, Now What?

Part I: Building a Windows CE Application

Chapter 1: Selecting and Testing Windows CE Development Tools
The Three Configurations of Windows CE
Handheld PC (H/PC or Mercury)
Windows CE Version 2.0, 1.01, or 1.0?
Tooling Up
Testing Your Installation
Running Applications in Emulation or on Windows CE Devices
Building Your Application
Running Your Application
Chapter 2: Understanding Emulation
Starting and Stopping
Substituting Emulation for Testing
Resolving Screen Resolution
Storing in the Object Store
Chapter 3: Building Your First API Application
Creating a Developer Studio Workspace and Project
Making a C/C++ Source File
Adding the Code
Building and Testing Your Code
Changing to Unicode Strings
Declaring Unicode strings
Replacing standard string functions
Converting string constants
Understanding How the Code Works
Starting with the declarations
Running applications, windows, and WinMain
Registering windows
Creating windows
Coding the window message loop
Declaring message-handling functions
Quitting the application using WM_DESTROY
Adding an Application Icon
Designing an icon
Displaying an icon in the taskbar
Chapter 4: Building Your First MFC Application
What Is the MFC?
Building an MFC Project with the AppWizard
Creating the project
Using the AppWizard
Step 1 -- setting the application type
Step 2 -- selecting application options
Step 3 -- selecting miscellaneous options
Step 4 -- setting class names
Building the application
Exploring the MFC Classes
CMFCFirstApp (CWinApp)
CMFCFirstDoc (CDocument)
CMFCFirstView (CView)
CMainFrame (CFrameWnd)
CAboutDlg (CDialog)
Working with Documents and Views
Storing the coordinates
Tracking the stylus
Drawing in a view
Keeping up to date
À La Carte Menus with MFC
Adding the menu item
Creating the menu handler
Implementing OnNewDocument
Chapter 5: Using the Command Bar
Creating Command Bars
Adding Adornments
Adding a Menu with the API
Designing the menu
Adding the menu to the command bar
Responding to menu item selections
Adding Standard and View Buttons
Standard buttons
View buttons
Loading bitmaps
Displaying buttons
Declaring a separator
Specifying buttons
Adding the buttons
Using multiple bitmaps
Adding Your Own Button Images
Creating the bitmap
Loading your bitmap
Using your toolbar buttons
Adding Combo Boxes
Adding Tooltips
Using Command Bars with MFC
Chapter 6: Creating Dialog Boxes
Style Guide for Dialog Boxes
Creating Dialog Boxes Using the API
Designing the dialog box
Creating the dialog box message function
Initializing dialog box controls
Getting control notifications
Responding to the dialog box closing
Displaying the dialog box
A few more odds and ends
Creating Dialog Box Forms with the MFC
Chapter 7: Drawing Using the MGDI
Drawing Using the API
Understanding device contexts
Drawing on the fly
WM_PAINT messages
Understanding the Client Area
Drawing Using the MFC
Drawing Text
What Else Is Missing in the MGDI?
Chapter 8: Exploring Other Development Environments
Windows CE Toolkit for Visual Basic 5.0
What's in the box?
Building Pocket VB applications
Creating a project
Developing an application
Running the application
What's missing in Pocket VB?
Windows CE 2.0 Toolkit for Visual J++

Part II: Discovering the Unique Features of Windows CE

Chapter 9: Creating a Setup Program
Four Easy Steps to Create a Setup Program
Creating the setup application
The load script
Calling the load functions
Naming the files
Uninstall Scripts
Installing Shared Libraries
Creating Registry Items
Chapter 10: Building Help Files
Structure of a Windows CE Help System
Creating HTML Files
Formatting the Content File
Formatting the Section Files
Using Windows CE with the API
Using Windows CE Help with MFC
Chapter 11: Using Databases
Not Your Average Desktop Database
Getting Databases to Work
Creating a database
Opening a database
Opening a new database
Opening an existing database
Closing a database
Deleting a database
Database Properties
Specifying a property
Specifying the data for a property
Writing Records
The structure of records
Time to write
Indexing for Speed
Creating indexes
Specifying an index when opening the database
Seeking records
Seeking a value
Reading Records
Reading all properties
Reading specific property values
Accessing property values
Finding the property identifier
Freeing memory -- don't forget!
Deleting Properties and Records
Deleting properties
Deleting records
Using the MFC CE Database Classes
Using the CCeDBProp class
Using the CCeDBDatabase class
Creating and opening databases
Navigating through records
Seeking records
Using the CCeDBRecord class
Chapter 12: Accessing the Contacts Database
Address Book Essentials
Address book fields
Getting ready to call address book functions
Opening the address book
Closing the address book
The AddressCard Structure
Searching and Opening Records
Getting a property's long name
Performing a search
Opening a record

Part III: Peeking Behind the Scenes

Chapter 13: Memory Management, Process Control, and Thread Control
Using Memory Efficiently
Understanding how your applications use memory
Application code
Application stack
Application data
Allocating dynamic memory
Determining free program memory
Monitoring memory usage
Hibernating when it gets cold
Dealing with the lowest of the low memory situations
What's In a Process?
Creating a process
Handling kernel object handles with care
Understanding why CreateProcess failed
Finishing early
Weaving Threads
Creating a thread
Making the thread do something
Pulling a thread
Signaling danger ahead -- global data and threads
Going critical
Avoiding deadlocks
Prioritizing threads
Chapter 14: Managing Power
Assuming Power
Understanding Power-Management States
Changing from On to Idle State
Changing from Idle to Suspend State
Monitoring Battery Status
Chapter 15: Dynamic Link Libraries
Defining Dynamic Link Libraries
Realizing the Benefits of DLLs
Writing DLLs
Designing the DLL interface
Creating a DLL project
Writing the DllMain function
Writing interface functions
Building the DLL
Calling a DLL function
Building the application

Part IV: Working with the Shell and the Object Store

Chapter 16: Using the Shell Features
Getting to Know the Shortcuts
Creating a shortcut
Finding your own identity
Checking where the shortcut cuts to
Shortcutting documents
Adding to the Document menu
Performing an action on a file
Using the shell to run an application
Adding Icons to the Taskbar Status Area
Adding the icon
Loading the icon
Setting the icon in the taskbar status area
Notifying in the taskbar status area
Removing a taskbar status area icon
Modifying a taskbar status area icon
Saving Time by Using Common Dialog Boxes
The File Open common dialog box
Specifying the file and path string buffer
Setting file filters
Using other initializations
Putting all the code together
The File Save As common dialog box
Controlling Future Events with Notification Functions
Starting applications at a specified time
Writing applications with no user interface
Starting an application on an event
Notifying the user
Setting a sound notification
Setting a dialog box notification
Removing the annunciator icon
Remembering user notification preferences
Chapter 17: The Object Store
Entering the Object Store
Choosing a Storage Technique
Determining the Amount of Space in the Object Store
Organizing Files and Folders
Understanding Object Identifiers
Listing Databases
Using the ObjStr application to produce a list of databases
Breaking down the CEDBASEINFO structure
Getting to Know the Windows CE Registry
Understanding the elements of the Registry
Viewing and editing the Registry
Obtaining handles to keys
Creating a Registry key
Saving and updating values in a key
Retrieving values from keys
Deleting keys
Chapter 18: The File System API
Examining the Windows CE File System API
Opening and creating files
Checking for errors
Writing to a file
Reading from a file
Performing random file I/O
Using file I/O with the MFC
Archiving with the MFC
Writing or reading with serialization
Finding errors when archiving

Part V: Improving Desktop Connectivity and Communications

Chapter 19: Serial Communications Programming
Understanding Serial Communications Basics
Making the connection
Configuring a port
Programming Serial Communications
Opening the port
Closing the port
Configuring the port
The DCB structure
Getting and setting DCB settings
Getting and setting COMMTIMEOUTS settings
Writing to the port
Reading from the port
Communications events
Reading data from the port
Testing serial communications
Closing the RAS connection
Testing a Windows CE application's serial communications
Reopening the RAS connection
Using the Infrared Port
Chapter 20: Programming Windows Sockets
What's a Socket, Anyway?
Using Client and Server Sockets
Writing Socket Applications
Understanding the MFC Socket Classes
CSocket and CCeSocket
CArchive and CSocketFile
Using the sockcli Application
Where to put the socket code
Creating a socket class
CCliSocket constructor
OnReceive override
The CSockCliDoc class
The CSockCliDoc constructor
CString CSockCliDoc::GetLine
Using the socksrv Application
The listening socket
Creating the listening socket
Responding to a connection request
Chapter 21: RAS and Network Support
Managing RAS Connections
Using the RAS phone book
Making a RAS connection
Monitoring a RAS connection
Disconnecting a RAS connection
Network support
Making and Breaking a Connection

Part VI: The Part of Tens

Chapter 22: Ten Important Features of Windows CE Applications
Focusing on Memory Usage
Understanding the User Interface
Including a Setup Program
Working with Desktop Communications
Adding Help Files
Saving Data and State Information
Using the Address Book
Including Shell Support
Supporting Long Filenames
Using the Windows CE Logo Program
Chapter 23: Ten (Or so) Tips for Porting Existing Windows 95/NT Applications
Select Appropriate Features
Design the User Interface
Sharing Code
Adding Communications
Unicode Issues
Missing Functions
Limiting Emulation Differences
Chapter 24: Ten (Or so) Important Windows CE Resources
Microsoft Windows CE Web Site
The Windows CE Webring
Software Paths Web Site
Handheld PC Web Site
Sample Applications
Other ...For Dummies® Books
Microsoft Developers Network CD
Appendix: About the CD
System Requirements
Cool Stuff on the CD
CE Install Demo
The Expense Tracker Sample Form
Sample Source Code


License Agreement

Installation Instructions

Book Registration Information

Read More Show Less

First Chapter

Chapter 6
Creating Dialog Boxes

In This Chapter

  • Designing dialog boxes for Windows CE
  • Using the correct styles for a Windows CE dialog box
  • Creating dialog box message functions
  • Responding to notification messages

In this chapter, I show you the important differences between Windows CE dialog boxes and those developed for Windows 95 and NT. The most important difference is that Windows CE dialog boxes do not have the typical OK and Cancel buttons. Instead, the dialog box caption bar displays the OK and X icons, which represent these buttons (see Figure 6-1).

Style Guide for Dialog Boxes

Many of the same design rules for Windows NT and 95 dialog boxes apply to Windows CE. Dialog boxes in Windows CE, however, are much smaller, and they have fewer controls and less-complex user interactions. Remember that a Windows CE dialog box is probably more difficult to use because of the smaller keyboard. Furthermore, interactions involving the stylus are more difficult than interactions with a mouse.

Remember that Windows CE devices do not have a mouse. Instead, a stylus is used to tap items on the screen to select or otherwise interact with them.

Try to follow these general guidelines when designing dialog boxes for Windows CE:

  • Create simple dialog boxes with only a few, large controls.

    Controls should be at least 23 pixels high and 23 pixels wide, or 38 x 38 pixels if you expect the user to interact with the stylus.

  • Use a non-boldface font for all labels and text in controls.

    Your best bet is to use the default MS Sans Serif 8-point font.

  • If the dialog box contains OK and Cancel (X) buttons, place them both in the caption and not in the dialog box itself.

    If the dialog box has OK and Cancel button functions that perform the same task, add an OK button to the caption and disable the caption's Cancel button.

Creating Dialog Boxes Using the API

Creating a dialog box involves designing the layout of the controls (such as edit boxes and radio buttons), and then writing code that responds to the user carrying out actions (for example, tapping a radio button).

The\samples\DlgDisplay.dsw workspace on the enclosed CD-ROM contains source code and dialog box designs that show you how to add dialog boxes to your applications. You can copy the source code directly into your own application and use it as a starting point to develop your own dialog boxes.

Use the following general steps to create a dialog box:

  1. Design the dialog box (which defines the layout of the controls) in the Developer Studio Resource Editor.

    This is the fun bit! The Resource Editor is a graphical tool that allows you to place the controls in a dialog box and to arrange them exactly the way you want. The dialog box is called IDD_DLGSAMP in the DlgDisplay.dsw workspace on the CD-ROM.

  2. Create a message-processing function to handle messages and interactions from the dialog box.

    The message processing function is very similar to the window message processing function (WndProc) described in the section "Declaring message-handling functions" in Chapter 3. This function is called OptionsDlgProc in the file DlgDisplay.cpp on the CD-ROM.

  3. Make a call to display the dialog box from a menu item, button, or other user-interface component.

    Dialog boxes are most frequently displayed in response to the user selecting a menu command. The dialog box IDD_DLGSAMP appears when the user selects the menu item IDM_FILE_OPTIONS in DlgDisplay on the sample CD-ROM.

Designing the dialog box

You create dialog boxes by using the Resource Editor in the Developer Studio. Use the following steps to create a new dialog box in an application:

  1. Select the Resource View tab in the Workspace window.

    The resource view tab displays a list of all the resources, including dialog boxes, in your project. You can also add new dialog boxes from the resource view.

  2. Choose Insert-->Resource menu, select Dialog from the Resource Type list, and then select New.

    This menu displays the Insert Resource dialog box, which contains a Resource Type list containing a list of all the different types of resources that can be added to a project. You should choose Dialog from the Resource Type list.

    This creates a standard Windows NT/95 dialog box. You now need to make the following changes for Windows CE.

  3. Delete the OK and Cancel buttons that are created by default in the dialog box.

    Select the OK button in the dialog box that you just created; then press Delete. Repeat for the Cancel button.

  4. Right-click anywhere in the dialog box you've created and choose Properties from the pop-up menu that appears.

    The Dialog Properties dialog box appears.

  5. Change the X Pos and Y Pos edit boxes to 20 and 20, respectively.

    The X Pos and Y Pos values specify the position of the upper-left corner of the dialog box when the dialog box is displayed.

  6. While still in the Properties window for the dialog box, click the Extended Styles tab.
  7. Check the Caption Bar OK (WCE Only) style.

    After you change this style, the dialog box appears with the OK button in the caption bar.

You can choose Layout-->Test in Developer Studio to review the dialog box's design. Note that this does not show the OK button in the caption bar because Windows NT does not support this feature.

If you're adding a dialog box to your API application, be sure that you add a resource (RC) file to your project. This is described in the section "Designing the menu" in Chapter 5.

You can now design the dialog box by using the standard Developer Studio techniques. I show the layout of the controls for the sample dialog box in DlgDisplay.dsw in Figure 6-1. Use the following steps to create the dialog box design:

  1. Display the dialog box's property window by right-clicking the dialog box and choosing Properties.

    This displays the Dialog Properties dialog box.

  2. Set the dialog box's identifier to IDD_DLGSAMP and the caption to Sample Dialog box.

    The General tab in the Dialog Properties dialog box contains the Identifier combo box for setting the dialog box's identifier and the Caption edit box for setting the text for your dialog box's caption.

  3. Add a static text control, and set the caption to Options: in the static text control's property window.

    You display this window by right-clicking the static text control and choosing Properties from the pop-up menu that appears. This displays the Text properties dialog box.

  4. Add a drop-down list box to the dialog box, right-click the combo box, and select Properties from the pop-up menu that appears.

    This displays the Combo Box Properties dialog box. Set the identifier for the combo box to IDC_OPTIONS in the combo box's property window.

    Keep in mind that a combo box is a dialog box that includes a drop-down list.

The drop-down list box works differently in Windows CE than it does in Windows NT or Windows 95. Unless the drop-down list box is deeper than about five lines, the vertical scrollbar does not appear. It is important to use the following steps whenever you add a combo box in Windows CE:

  1. Select the combo box with a single click.

    Note that sizing boxes are displayed around it (as shown in Figure 6-2).

    All the sizing boxes for the combo box (except the left and right box, which are used for changing the width of the combo box), are disabled.

  2. Click the gray down-arrow button in the combo box itself.

    The sizing box at the bottom center is now enabled and is shown as a blue box. You can now use this sizing box to change the depth of the drop-down list box (see Figure 6-3).

  3. Use the blue sizing box to increase the depth of the drop-down list box so that it is more than five lines deep.

Creating the dialog box message function

Each dialog box must have a function that manages the messages sent to the dialog box by Windows CE. This function is called a dialog box message function. You can add code to this function to respond to actions taken by the user. The following code sample is the function declaration for the dialog box function from DlgDisplay.dsw:

int CALLBACK OptionsDlgProc(HWND hDlg, UINT uMsg,  
WPARAM wParam, LPARAM lParam)

You call this function whenever a message is generated for the dialog box, including notification messages.

Windows CE must provide information about what the user has done in the dialog box, so that the code you add to the function can respond appropriately. This information is passed to the function by using the following paramaters:

  • hDlg: The handle (unique reference value) to the dialog box.
  • uMsg: The message ID. This is WM_COMMAND for messages being sent from a control in the dialog box.
  • wParam and lParam: Data that is specific to each type of message.

The function returns TRUE if it handles the message or FALSE if it does not.

Code Listing 6-1 shows the code used as a starting point for a dialog box message function. This dialog box message function has code that handles the following two messages:

  • The WM_INITDIALOG message. You send this just before the dialog box is displayed to the user. You should add code to initialize the controls (for example, by adding strings to a combo box) in response to this message.
  • The WM_COMMAND message. You send this when a control needs to notify the dialog box of some event. The LOWORD of wParam contains the identifier of the control that is sending the message. In this case, the code calls EndDialog if either the OK button or Cancel button sends a notification message. This message is sent to the dialog box when the user clicks one of the buttons.

Code Listing 6-1

int CALLBACK OptionsDlgProc(HWND hDlg, UINT uMsg,  
WPARAM wParam,
LPARAM lParam)
return (TRUE);
switch (LOWORD(wParam))
case IDOK:
EndDialog(hDlg, IDOK);
EndDialog(hDlg, IDCANCEL);
return (TRUE);
return (FALSE);

You call the EndDialog function when either the OK button or the Cancel button is tapped. This function closes the dialog box whose handle is specified in the first argument (hDlg). You use the second argument (IDOK or IDCANCEL) to specify which button was tapped to close the dialog box.

Initializing dialog box controls

You often need to initialize controls with specific values or give them a particular appearance before the dialog box is displayed to the user. You can add this initialization code in response to the WM_INITDIALOG message being received. For example, in DlgDisplay.cpp, you load the combo box with some strings.

You make controls do things by sending them messages. To send these messages, you need the window handle of the control. You must obtain this handle at runtime by using the GetDlgItem function, passing the dialog box's window handle and the identifier of the control (which you set in the dialog box editor), as follows:

HWND hCombo; 
hCombo = GetDlgItem(hDlg, IDC_OPTIONS);

After you obtain a handle of the control (hCombo), you can send messages to the control (such as CB_ADDSTRING) using the SendMessage function. You need to provide additional information for the message, such as, which string to add to the dialog box. The SendMessage function requires you to pass the following data to provide this additional information:

  • hCombo: The window handle of the control to which the message is to be sent.
  • CB_ADDSTRING: The message to be sent.
  • wParam and lParam: Two 4-byte values that contain additional information about the message being sent.

The data that you pass to SendMessage depends on the message being sent. In the case of CB_ADDSTRING, you pass a pointer to the string in the last argument and cast it to an LPARAM. You can use Code Listing 6-2 in DlgDisplay.cpp to add strings to the dailog box, as follows.

Code Listing 6-2

HWND hCombo; 
hCombo = GetDlgItem(hDlg, IDC_OPTIONS);
SendMessage(hCombo, CB_ADDSTRING, 0,
(LPARAM)TEXT("Option 1"));
SendMessage(hCombo, CB_ADDSTRING, 0,
(LPARAM)TEXT("Option 2"));

Getting control notifications

Controls can send the dialog box message function notification messages in a WM_COMMAND message when some event occurs. You've already seen an example of this when the OK button notifies the dialog box that it's been tapped. This is a simple case, because the OK button can only notify the dialog box of one event (it has been tapped), so you don't need to further investigate the type of event.

Controls can send the dialog box message function notification messages in a WM_COMMAND message when some event occurs. For example, the OK button sends the message WM_COMMAND to the dialog box message function whenever it is tapped. The dialog box message function responds by closing the dialog box.

The OK button is a simple case, because the button only sends one notification message (called the button has been clicked notification). Other controls can sends many different notification messages. For example, a dialog box may send a notification, such as "user selected a string from the list box" or "user has typed text into the combo box." In this case, you need to further investigate which type of notification event is being sent by the control.

Combo boxes (drop-down list boxes) have a number of different notification messages that all begin with CBN (which stands for combo box notification). For example, the combo box sends CBN_CLOSEUP when the user closes the list box part of the control.

The control passes the notification message in the top two bytes of the message's wParam value. You can use the HIWORD macro to extract the notification code. Use Code Listing 6-3 to display a message box when the user double-taps the combo box.

Code Listing 6-3

switch (LOWORD(wParam))
MessageBox(hDlg, TEXT("Listbox Closed!"),
szTitle, MB_OK);
case IDOK:

Responding to the dialog box closing

You need to write code that does something with the data that the user enters when the user taps the OK button. For example, in Code Listing 6-4, the string that's currently selected in the combo box is displayed to the user in a message box using the GetWindowText function to retrieve the text that's associated with a control. In your application, you probably take the data from the controls and store the data in variables to allow the data from the controls to be used after the dialog box has been closed.

Code Listing 6-4

case IDOK: 
TCHAR szBuffer[20];
hCombo = GetDlgItem(hDlg, IDC_OPTIONS);
GetWindowText(hCombo, szBuffer, 10);
MessageBox(hDlg, szBuffer, szTitle, MB_OK);
EndDialog(hDlg, IDOK);

Notice how you call the GetDlgItem function whenever the handle to the dialog box is required. This is necessary because each new message results in a new call to the OptionsDlgProc function being made by Windows CE, and you must reinitialize hCombo.

Displaying the dialog box

In the DlgDisplay.cpp sample source code, the dialog box is displayed in response to the user choosing File-->Options. You use the DialogBox function to display the dialog box, and this requires the following information:

  • hInst: The application's instance handle.
  • IDD_DLGSAMP: The dialog box's identifier. Note that you must use the MAKEINTRESOURCE macro to convert this integer identifier to a string value, because DialogBox expects a string.
  • hWnd: The window handle that is to be the parent window of the dialog box. This is the application window in this case.
  • OptionsDlgProc: The function that is to handle the messages from the dialog box. I describe this function in the previous section.

This information tells Windows CE which dialog box to display and which dialog message function handles messages from the dialog box.

The code in Code Listing 6-5 displays the dialog box. The return value from DialogBox is the second argument that's passed to EndDialog when the user closes the dialog box. This allows the caller of DialogBox to determine if the OK button or Cancel button was tapped.

Code Listing 6-5

hWnd, OptionsDlgProc) == IDOK)
MessageBox(hWnd, TEXT("OK pressed"), szTitle, MB_OK);

A few more odds and ends

To program dialog boxes, you need to understand the following items further:

  • The messages to send to controls to make them do something: These messages are documented under the names of the controls to which they apply. For example, you can search the online help for Combo Box Messages to find a list of the other messages that you can send to a combo box.
  • The notification messages that a control can send you: Search the online documentation under the name of the control, for example, Combo Box Notifications.
  • Window functions that can be used on controls: For example, GetWindowText can retrieve the text in text boxes, static text boxes, and combo boxes, and you can call GetWindowTextLength to find the number of characters in the window's text.

Creating Dialog Box Forms with the MFC

Programming dialog boxes by using MFC in Windows CE is almost identical to performing this task in Windows 95 and NT. You should, however, follow the user interface style guidelines that are detailed in "Style Guide for Dialog Boxes," near the beginning of this chapter. You can then follow the steps in "Designing the dialog box" to build Windows CE style dialog boxes in MFC applications.

The \samples\DlgMFC.dsw workspace contains the source code for an MFC application that displays a dialog box from the File-->Options menu command. The code in this section is taken from this application. The dialog box created in this application is the same as that in Figure 6-1.

When designing a Windows CE dialog box, you generally delete the OK and Cancel buttons that are created by the Resource Editor because they are displayed as icons in the dialog box's caption bar. You should create the dialog box's class and add the message handlers for the OK and Cancel buttons before deleting the buttons in the dialog box editor. If you don't do this, you may not see IDOK and IDCANCEL in the dialog box's list of controls, and you won't be able to add message handlers for them.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)