November 26, 2014
Hot Topics:

Moving Dialogs from the Desktop to Windows CE

  • November 21, 2002
  • By Nancy Nicolaisen
  • Send Email »
  • More Articles »

Dialogs are a less superficial porting issue than most of the other items you find in the resource file, for a couple of reasons. First, dialogs invariably include a lot of text items, all of which must be handled as Unicode strings under CE. Second, many desktop application dialogs will be too large to display properly on a CE-size screen. We've looked a bit at handling Unicode strings, and we'll expand that discussion in the articles ahead. Now let's look at what to do with dialogs that are too big for the Windows CE screen.

Here's the simplest strategy for porting dialogs:

  • Examine the resource file and find dialogs that are too big to display on CE screens.
  • Subdivide their controls into groups based on function and redesign the groups as pages of a tabbed dialog.

We are going to do just exactly this. For purposes of illustration, we'll port the user interface of the dialog-based application pictured in Figure 1.



Click here for a larger image.

Figure 1: DataDlg is a Win32 application that uses this dialog box as its main user interface.

Win 32 Source Files for the DataDlg Example

All we really need to observe about the code for the UFO dialog is that it's modeless, so we can't use EndDialog() to dismiss it and that we've conveniently omitted all the code that processes and stores dialog input. From the screenshot in Figure 1, we can easily determine that this dialog is much too large to display on a CE screen. You may not have the luxury of screen shots of all your application's dialogs, so a good place to look to assess the dimensions of a dialog that's a candidate for porting is (you knew it) the resource file.

Here's an excerpt from DataDlg.rc that gives the dimensions of the UFO dialog.

UFODLGBOX DIALOGEX 0, 0, 422, 237
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "UFO Data Management Form X"
FONT 8, "MS Sans Serif"
BEGIN
    LTEXT           "&Name",IDC_STATIC,5,5,20,8
    EDITTEXT        IDC_NAME,35,5,70,15,ES_AUTOHSCROLL
    LTEXT           "&Badge Number",IDC_STATIC,5,30,48,8
    EDITTEXT        IDC_BADGE,65,30,40,15,ES_AUTOHSCROLL
    LTEXT           "&Description of Encounter",
                        IDC_STATIC,5,55,90,8
    EDITTEXT        IDC_DESC,30,65,75,40,ES_MULTILINE |
                                         ES_AUTOVSCROLL
    GROUPBOX        "&Category",IDC_STATIC,25,115,80,50
    CONTROL         "Sighting",IDC_CAT,"Button",
                               BS_AUTORADIOBUTTON |
                               WS_GROUP |
                               WS_TABSTOP,30,130,65,10
    CONTROL         "Contact",IDC_RADIO2,"Button",
                               BS_AUTORADIOBUTTON |
                               WS_TABSTOP,30,145,70,10
    GROUPBOX        "&Mode of Travel",IDC_STATIC,25,165,80,65,
                               WS_GROUP
    CONTROL         "Space Ship",IDC_SPACESHIP,"Button",
                               BS_AUTOCHECKBOX |
                               WS_TABSTOP,30,180,70,10
    CONTROL         "Levitation",IDC_LEVITATION,"Button",
                               BS_AUTOCHECKBOX |
                               WS_TABSTOP,30,195,65,10
    CONTROL         "Bicycle",IDC_BICYCLE,"Button",
                               BS_AUTOCHECKBOX |
                               WS_TABSTOP,30,210,70,10
    LTEXT                "Where Seen (simple combo)",
                               IDC_STATIC,140,5,90,8
    COMBOBOX        IDC_WHERE_SEEN,140,20,90,45,CBS_SIMPLE |
                                                CBS_SORT |
                               WS_VSCROLL | WS_TABSTOP
    LTEXT                "&Physical Evidence",
                               IDC_STATIC,145,75,59,8
    LTEXT                "(dropdown combo)",IDC_STATIC,145,85,65,8
    COMBOBOX        IDC_PHYS_EVIDENCE,140,100,85,50,
                                      CBS_DROPDOWN | CBS_SORT |
                                      WS_VSCROLL | WS_TABSTOP
    SCROLLBAR       IDC_FRIENDLY,120,145,105,11
    LTEXT                 "Friendliness",IDC_STATIC,160,160,38,8
    SCROLLBAR       IDC_TALKATIVE,120,185,105,11
    LTEXT                 "Willingness to Communicate",
                               IDC_STATIC,130,200,89,8
    LTEXT                "&Home Office (list box)",
                               IDC_STATIC,255,5,68,8,0,0,
                               HIDC_STATIC
    LISTBOX         IDC_OFFICE,245,20,85,40,LBS_SORT |
                               LBS_NOINTEGRALHEIGHT |
                               WS_VSCROLL | WS_TABSTOP
    LTEXT           "&Abductions",IDC_STATIC,297,75,36,8
    LTEXT           "droplist combo",IDC_STATIC,290,87,50,8
    COMBOBOX  IDC_ABDUCTIONS,245,99,140,50,CBS_DROPDOWNLIST |
                               CBS_SORT | WS_VSCROLL | WS_TABSTOP
    GROUPBOX    "Appearance - Check All That Apply",
                               IDC_STATIC,250,130,150,105
    CONTROL         "Scary",IDC_SCARY,"Button",
                               BS_AUTOCHECKBOX |
                               WS_TABSTOP,265,150,34,10
    CONTROL         "Cute",IDC_CUTE,"Button",BS_AUTOCHECKBOX |
                               WS_TABSTOP, 265,165,31,10
    CONTROL         "Dressed like Leonard Nemoy",
                               IDC_SPOCK,"Button",
                               BS_AUTOCHECKBOX |
                               WS_TABSTOP,265,180,107,10
    CONTROL         "Not Dressed",IDC_THINKER,"Button",
                               BS_AUTOCHECKBOX |
                               WS_TABSTOP,265,195,55,10
    CONTROL         "Can't Recall",IDC_WHOOPS,"Button",
                               BS_AUTOCHECKBOX |
                               WS_TABSTOP,265,210,54,10
    PUSHBUTTON      "OK",IDOK,345,5,70,14
    PUSHBUTTON      "Cancel",IDCANCEL,345,30,70,14
    PUSHBUTTON      "&Clear Form",IDC_CLEARCTRLS,345,55,70,14,
                               BS_NOTIFY
END

Here's what we learn from this excerpt. First, the dialog size is 422 x 237 screen units. It might fit on the screen of a PC Pro Windows CE device, but on anything else it would be too large. Windows CE supports the same set of predefined controls as Win 32 (buttons, listboxes, and so forth), so we really only have one concern about the individual controls at this point—their size. We'll make the edit controls smaller, but because they can be set to scroll both horizontally and vertically, shrinking them has no impact on their functionality.





Page 1 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel