Possible Causes of Dialog Box Creation FailureLast reviewed: July 23, 1997Article ID: Q80843 |
3.00 3.10
WINDOWS
kbprg
The information in this article applies to:
SUMMARYThe dialog box creation routines (CreateDialog(), CreateDialogParam(), CreateDialogIndirect(), CreateDialogIndirectParam(), DialogBox(), DialogBoxParam(), DialogBoxIndirect(), and DialogBoxIndirectParam()) can fail for several reasons. When one of these functions fails, the dialog box is not displayed on the screen. Of the causes for dialog box creation failure, this article discusses nine, which are listed below, and provides a resolution or explanation:
MORE INFORMATIONThe order in which the causes are listed below does not provide any indication of how often each cause occurs.
Cause 1Application runs out of file handles.
Resolution 1Use the SetHandleCount() function to open more file handles. For more information on this procedure, query this Knowledge Base on the words:
resources and SetHandleCount Explanation 1Windows requires a file handle to load a resource. Because each dialog box creation routine loads dialog resources, an application must have at least one file handle available for that purpose.
Cause 2One or more text strings in a dialog resource start with the character represented by the value 255 (0xFF).
Resolution 2For an explanation of two methods to work around this cause, query this Knowledge base on the words:
string and resource and 255 Explanation 2Windows uses the number 255 to indicate that a resource is represented by an ordinal value instead of by a string name. During the process of parsing the resource that contains one of these characters, Windows incorrectly skips the next two bytes and treats the new position in the resource as the next piece of data.
Cause 3Several small compiled resource (RES) files are combined using the MS-DOS command "COPY /b".
Resolution 3Use the #include directive to combine the files at the source level. If the Windows Resource Compiler cannot handle the large RC file, consider storing the resources in a resource-only DLL. For more information, query this knowledge base on the words:
combined and res Explanation 3The Resource Compiler shipped with version 3.0 of the Windows Software Development Kit (SDK) has been enhanced to handle resource files much larger than its Windows 2.x counterpart. The format of the compiled resource files in Windows 3.0 does not support concatenation of RES files.
Cause 4A dialog box with an edit control cannot be created when at least ten dialog boxes, each with one or more edit controls, are open simultaneously.
Resolution 4Specify the DS_LOCALEDIT style in the dialog box template, or create the edit control explicitly with the CreateWindow() function.
Explanation 4For more information, query this Knowledge Base on the words:
dialog and GlobalAlloc and fails Cause 5The dialog resource is not included in the RC file.
Resolution 5Use RCINCLUDE to include the dialog resource in the RC file.
Explanation 5Include the DLG file created by the Dialog Editor into the RC file so the Resource Compiler can add the dialog resource to the executable file.
Cause 6Insufficient system resources.
Resolution 6Verify that system resources are not lost because an application does not delete objects that it creates. For more information, query this Knowledge Base on the words:
lost and heapwalkThe article "Careful Windows Resource Allocation and Cleanup Improves Application Hygiene," in the September 1991 issue of the "Microsoft Systems Journal" discusses this issue further.
Explanation 6Unless each application frees all the resources that it allocates, eventually Windows does not have enough memory to create the controls and/or the dialog box itself.
Cause 7In a dialog registered with a private dialog class, the dialog procedure does not return the value returned from DefDlgProc() as its return value.
Resolution 7Whenever the private-class dialog procedure passes an unprocessed message to DefDlgProc(), the dialog procedure must propagate the value returned by DefDlgProc().
Explanation 7When a private-class dialog procedure passes an unprocessed message to DefDlgProc(), it must return the value returned from DefDlgProc(). This behavior differs from that of a default-class dialog procedure, which usually returns FALSE outside the message switch when it does not process a message. If a private-class dialog procedure is implemented in this way, and the procedure does not process the WM_NCCREATE message, it will return FALSE. The CreateWindow() function sends the WM_NCCREATE message to create the non- client area of the dialog window. CreateWindow() treats a response of FALSE from the dialog procedure as failure and returns a NULL handle to the application.
Cause 8Wrong HINSTANCE value used.
Resolution 8Specify the application's instance handle.
Explanation 8The dialog box creation routine must specify the application's instance because the dialog template is stored in the application instance.
Cause 9A dialog box with an edit control or a combo box with an edit control must have a HEAPSIZE statement with a value > 0 in the .DEF file.
Resolution 9Set the value of HEAPSIZE to > 0 in your .DEF file.
Explanation 9Windows allocates memory for edit controls out of your local heap. If you do not have a HEAPSIZE statement, it cannot create the edit control.
|
Additional reference words: fails modal modeless 3.00 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |