PRB: Cannot Center Explorer-Style FileOpen Common Dialog Box (140722)
The information in this article applies to:
- Microsoft Platform Software Development Kit (SDK) 1.0
This article was previously published under Q140722 SYMPTOMS
Generally, an application that attempts to alter the default behavior of
a dialog box before it even comes up on the screen, would process the
WM_INITDIALOG message. For common dialogs, this message is processed in the
common dialog's hook procedure. However, attempting to center the new
Explorer-Style FileOpen Common Dialog in Windows 95 in the hook procedure's
WM_INITDIALOG case will result in an off-center dialog box.
CAUSE
This problem arises with the new Explorer-Style common dialog only when the
OFN_ENABLETEMPLATE flag is set in the OPENFILENAME structure, and a dialog
template is specified in lpTemplateName that includes the new controls that
you want to add to the dialog box.
Typically, the code to center a dialog box would first get the dimensions
of the dialog box by using GetWindowRect so it could be centered on the
screen appropriately. At WM_INITDIALOG time, the FileOpen dialog has not
been resized to accomodate the new controls specified in the lpTemplateName
member of the OPENFILENAME struct; therefore, GetWindowRect() returns the
dimensions of the original FileOpen dialog, not that of the actual
customized dialog that comes up on the screen. This then causes the dialog
box to come up a few pixels off-center.
RESOLUTION
Call GetWindowRect() and the rest of the code to center the dialog box, in
the hook procedure's WM_NOTIFY case, with code set to CDN_INITDONE, a new
common dialog notification code for Windows 95. By this time, all the
controls have been added in, and the dialog has been resized accordingly.
STATUS
This behavior is by design.
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbCmnDlg kbCmnDlgFileO kbCmnDlgSave kbprb KB140722 |
---|
|