PRB: CreateDialogIndirect() Fails Under Windows 95 (137618)
The information in this article applies to:
- Microsoft Platform Software Development Kit (SDK) 1.0, when used with:
- the operating system: Microsoft Windows 2000
This article was previously published under Q137618 SYMPTOMS
Programs that use CreateDialogIndirect() to create their dialog boxes at
run time in Windows 95 may have trouble if the program has been ported
from Windows NT or Windows 3.1.
CAUSE
The dialog resource for Windows 95 is the same as Windows NT; that is, all
strings must be in Unicode, and all structures must be DWORD aligned.
Programs ported from Windows NT may find that when they insert strings into
the dialog template resource, they used lstrcpyW() to force the string to
be Unicode or the program itself was called compiled for Unicode. However,
lstrcpyW() is not implemented in Windows 95, so it returns
ERROR_NOT_IMPLEMENTED. To generate Unicode strings in Windows 95, the
program must use MultiByteToWideChar().
Programs ported from 16-bit Windows 3.1 will probably have problems with
the Unicode strings mentioned above and also with the structure alignment.
In 16-bit Windows, dialog box resource structures are aligned on byte
boundaries, so there's no work for the programmer to do. However, in
Win32, all structures must be aligned on DWORD (four-byte) boundaries.
AlignPtr() is a simple helper routine that takes a pointer and returns the
nearest pointer aligned on a DWORD boundary. The program should call this
between all the dialog resource structures.
RESOLUTION
Use MultiByteToWideChar() to generate Unicode strings in Windows 95, and
call AlignPtr(), which takes a pointer and returns the nearest pointer
aligned on a DWORD boundary, between all the dialog resource structures to
align all structures on DWORD boundries.
STATUS
This behavior is by design.
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbDlg kbprb kbResource KB137618 |
---|
|