Dialog Box Creation Fails If Text Starts w/ Character 255

Last reviewed: July 22, 1997
Article ID: Q66926
3.00 3.10 WINDOWS kbprg The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

Text strings in a dialog box resource cannot start with the character represented by the value 255 (0xFF). In the ANSI character set, this character is the letter "y" with a diaeresis mark, which is used primarily in Nordic languages. If Windows encounters this situation, a call to DialogBox() or CreateDialog() will fail.

The following are two possible solutions:

  • Create the control with some "dummy" text. Then, use the SetDlgItemText() function during the processing of the WM_INITDIALOG message to manually set the text of the control to its proper value. This is the preferred method.

    -or-

  • Instead of starting the text with the 255 character, use a space, followed by a backspace character and the 255 character. For example, the text in the dialog box script can be " \0008x", where "x" is the 255 character. The embedded backspace erases the space, leaving only the 255 character.

MORE INFORMATION

Windows uses the number 255 to indicate that a resource is represented by ordinal value instead of by a string name. For example, when a dialog box is declared as follows

   AboutBox    DIALOG  ...

the text "AboutBox" appears in the .RES file. However, using the following

   1           DIALOG  ...

places the bytes 0xFF 0x01 0x00 into the .RES file. The 0xFF is used to indicate that the next two bytes are the ordinal value for this resource.

When creating a dialog box, the Windows Dialog Manager scans through each string in the dialog box template to find the null terminator. However, when a string that starts with 255 is encountered, it is interpreted as an ordinal value. In this situation, Windows incorrectly skips the next 2 bytes and treats the new position as the next piece of data in the dialog box template.

Whenever this occurs, the remainder of the dialog box template is interpreted incorrectly, and Windows tries to create controls of unknown classes, with unknown styles, in unknown locations. This causes the dialog box creation to fail.

For additional information about dialog box creation failure reasons, query on the following words in the Microsoft Knowledge Base:

   createdialog and createdialogindirect and dialogbox and creation


Additional reference words: 3.00 3.10 dialog box ANSI
KBCategory: kbprg
KBSubcategory: UsrDlgs
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.