Windows Win32 API Dlgbox
Windows Win32 API Dlgbox
Dialog Boxes
Article03/13/2023
commdlg.h
Dialog Boxes
Functions
AddRef
AddRef
CDSIZEOF_STRUCT
ChooseColorA
ChooseColorW
ChooseFontA
ChooseFontW
CommDlg_OpenSave_GetFilePathW
CommDlg_OpenSave_GetFolderIDList
Retrieves the address of the item identifier list corresponding to the folder that an Explorer-style
Open or Save As dialog box currently has open.
CommDlg_OpenSave_GetFolderPathA
CommDlg_OpenSave_GetFolderPathW
CommDlg_OpenSave_GetSpecA
CommDlg_OpenSave_GetSpecW
CommDlg_OpenSave_HideControl
CommDlg_OpenSave_SetControlText
Sets the text for the specified control in an Explorer-style Open or Save As dialog box.
CommDlg_OpenSave_SetDefExt
Sets the default file name extension for an Explorer-style Open or Save As dialog box.
CommDlgExtendedError
The CommDlgExtendedError function (commdlg.h) returns a common dialog box error code.
CreateDialogA
Creates a modeless dialog box from a dialog box template resource. The CreateDialog macro uses
the CreateDialogParam function. (ANSI)
CreateDialogIndirectA
Creates a modeless dialog box from a dialog box template in memory. The CreateDialogIndirect
macro uses the CreateDialogIndirectParam function. (ANSI)
CreateDialogIndirectParamA
Creates a modeless dialog box from a dialog box template in memory. (ANSI)
CreateDialogIndirectParamW
Creates a modeless dialog box from a dialog box template in memory. (Unicode)
CreateDialogIndirectW
Creates a modeless dialog box from a dialog box template in memory. The CreateDialogIndirect
macro uses the CreateDialogIndirectParam function. (Unicode)
CreateDialogParamA
Creates a modeless dialog box from a dialog box template resource. (ANSI)
CreateDialogParamW
Creates a modeless dialog box from a dialog box template resource. (Unicode)
CreateDialogW
Creates a modeless dialog box from a dialog box template resource. The CreateDialog macro uses
the CreateDialogParam function. (Unicode)
DefDlgProcA
Calls the default dialog box window procedure to provide default processing for any window
messages that a dialog box with a private window class does not process. (ANSI)
DefDlgProcW
Calls the default dialog box window procedure to provide default processing for any window
messages that a dialog box with a private window class does not process. (Unicode)
DialogBoxA
Creates a modal dialog box from a dialog box template resource. DialogBox does not return
control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (ANSI)
DialogBoxIndirectA
Creates a modal dialog box from a dialog box template in memory. DialogBoxIndirect does not
return control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (ANSI)
DialogBoxIndirectParamA
Creates a modal dialog box from a dialog box template in memory. (ANSI)
DialogBoxIndirectParamW
Creates a modal dialog box from a dialog box template in memory. (Unicode)
DialogBoxIndirectW
Creates a modal dialog box from a dialog box template in memory. DialogBoxIndirect does not
return control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (Unicode)
DialogBoxParamA
Creates a modal dialog box from a dialog box template resource. (ANSI)
DialogBoxParamW
Creates a modal dialog box from a dialog box template resource. (Unicode)
DialogBoxW
Creates a modal dialog box from a dialog box template resource. DialogBox does not return
control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (Unicode)
DLGPROC
Application-defined callback function used with the CreateDialog and DialogBox families of
functions.
EndDialog
Destroys a modal dialog box, causing the system to end any processing for the dialog box.
FindTextA
Creates a system-defined modeless Find dialog box that lets the user specify a string to search for
and options to use when searching for text in a document. (ANSI)
FindTextW
Creates a system-defined modeless Find dialog box that lets the user specify a string to search for
and options to use when searching for text in a document. (Unicode)
GetCurrentDevMode
Fills a DEVMODE structure with information about the currently selected printer for use with
PrintDlgEx.
GetCurrentPortName
Retrieves the name of the current port for use with PrintDlgEx.
GetCurrentPrinterName
Retrieves the name of the currently selected printer, for use with PrintDlgEx.
GetDialogBaseUnits
Retrieves the system's dialog base units, which are the average width and height of characters in
the system font.
GetDlgCtrlID
GetDlgItem
GetDlgItemInt
Translates the text of a specified control in a dialog box into an integer value.
GetDlgItemTextA
Retrieves the title or text associated with a control in a dialog box. (ANSI)
GetDlgItemTextW
Retrieves the title or text associated with a control in a dialog box. (Unicode)
GetFileTitleA
GetFileTitleW
Retrieves a handle to the first control in a group of controls that precedes (or follows) the
specified control in a dialog box.
GetNextDlgTabItem
Retrieves a handle to the first control that has the WS_TABSTOP style that precedes (or follows)
the specified control.
GetOpenFileNameA
Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or
set of files to be opened. (ANSI)
GetOpenFileNameW
Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or
set of files to be opened. (Unicode)
GetSaveFileNameA
Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save.
(ANSI)
GetSaveFileNameW
Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save.
(Unicode)
HandleMessage
Called by PrintDlgEx to give your application an opportunity to handle messages sent to the child
dialog box in the lower portion of the General page of the Print Property Sheet.
InitDone
Called by PrintDlgEx when the system has finished initializing the General page of the Print
Property Sheet.
IsDialogMessageA
Determines whether a message is intended for the specified dialog box and, if it is, processes the
message. (ANSI)
IsDialogMessageW
Determines whether a message is intended for the specified dialog box and, if it is, processes the
message. (Unicode)
LPCCHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Color
dialog box. This is an application-defined or library-defined callback function that is used with the
ChooseColor function.
LPCFHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Font
dialog box. This is an application-defined or library-defined callback procedure that is used with
the ChooseFont function.
LPFRHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Find or
Replace dialog box.
LPOFNHOOKPROC
LPPAGEPAINTHOOK
Receives messages that allow you to customize drawing of the sample page in the Page Setup
dialog box. The PagePaintHook hook procedure is an application-defined or library-defined
callback function used with the PageSetupDlg function.
LPPAGESETUPHOOK
Receives messages or notifications intended for the default dialog box procedure of the Page
Setup dialog box. The PageSetupHook hook procedure is an application-defined or library-
defined callback function used with the PageSetupDlg function.
LPPRINTHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Print
dialog box. This is an application-defined or library-defined callback function that is used with the
PrintDlg function.
LPSETUPHOOKPROC
An application-defined or library-defined callback function used with the PrintDlg function. The
hook procedure receives messages or notifications intended for the default dialog box procedure
of the Print Setup dialog box.
MapDialogRect
The MessageBox function displays a modal dialog box that contains a system icon, a set of
buttons, and a brief application-specific message.
MessageBoxA
Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-
specific message, such as status or error information. The message box returns an integer value
that indicates which button the user clicked. (MessageBoxA)
MessageBoxExA
MessageBoxExW
MessageBoxIndirectA
Creates, displays, and operates a message box. The message box contains application-defined
message text and title, any icon, and any combination of predefined push buttons. (ANSI)
MessageBoxIndirectW
Creates, displays, and operates a message box. The message box contains application-defined
message text and title, any icon, and any combination of predefined push buttons. (Unicode)
MessageBoxW
The MessageBoxW (Unicode) function displays a modal dialog box that contains a system icon, a
set of buttons, and a brief application-specific message.
MSGBOXCALLBACK
A callback function, which you define in your application, that processes help events for the
message box.
PageSetupDlgA
PageSetupDlgW
PrintDlgA
ASCII version of PrintDlg
PrintDlgExA
PrintDlgExW
PrintDlgW
QueryInterface
QueryInterface
Release
Release
ReplaceTextA
Creates a system-defined modeless dialog box that lets the user specify a string to search for and
a replacement string, as well as options to control the find and replace operations. (ANSI)
ReplaceTextW
Creates a system-defined modeless dialog box that lets the user specify a string to search for and
a replacement string, as well as options to control the find and replace operations. (Unicode)
SelectionChange
Called by PrintDlgEx when the user selects a different printer from the list of installed printers on
the General page of the Print Property Sheet.
SendDlgItemMessageA
SendDlgItemMessageW
SetDlgItemInt
Sets the text of a control in a dialog box to the string representation of a specified integer value.
SetDlgItemTextA
SetDlgItemTextW
Interfaces
IPrintDialogCallback
Provides methods that enable an application to receive notifications and messages from the
PrintDlgEx function while the Print Property Sheet is displayed.
IPrintDialogServices
Provides methods that enable an application using the PrintDlgEx function to retrieve information
about the currently selected printer.
Structures
CHOOSEFONTA
Contains information that the ChooseFont function uses to initialize the Font dialog box. After the
user closes the dialog box, the system returns information about the user's selection in this
structure. (ANSI)
CHOOSEFONTW
Contains information that the ChooseFont function uses to initialize the Font dialog box. After the
user closes the dialog box, the system returns information about the user's selection in this
structure. (Unicode)
DEVNAMES
Contains strings that identify the driver, device, and output port names for a printer.
DLGITEMTEMPLATE
Defines the dimensions and style of a control in a dialog box. One or more of these structures are
combined with a DLGTEMPLATE structure to form a standard template for a dialog box.
DLGTEMPLATE
FINDREPLACEA
Contains information that the FindText and ReplaceText functions use to initialize the Find and
Replace dialog boxes. (ANSI)
FINDREPLACEW
Contains information that the FindText and ReplaceText functions use to initialize the Find and
Replace dialog boxes. (Unicode)
MSGBOXPARAMSA
Contains information used to display a message box. The MessageBoxIndirect function uses this
structure. (ANSI)
MSGBOXPARAMSW
Contains information used to display a message box. The MessageBoxIndirect function uses this
structure. (Unicode)
OFNOTIFYA
Contains information about a WM_NOTIFY message sent to an OFNHookProc hook procedure for
an Open or Save As dialog box. The lParam parameter of the WM_NOTIFY message is a pointer to
an OFNOTIFY structure. (ANSI)
OFNOTIFYEXA
OFNOTIFYW
Contains information about a WM_NOTIFY message sent to an OFNHookProc hook procedure for
an Open or Save As dialog box. The lParam parameter of the WM_NOTIFY message is a pointer to
an OFNOTIFY structure. (Unicode)
OPENFILENAME_NT4A
OPENFILENAME_NT4W
OPENFILENAMEA
Contains information that the GetOpenFileName and GetSaveFileName functions use to initialize
an Open or Save As dialog box. After the user closes the dialog box, the system returns
information about the user's selection in this structure. (ANSI)
OPENFILENAMEW
Contains information that the GetOpenFileName and GetSaveFileName functions use to initialize
an Open or Save As dialog box. After the user closes the dialog box, the system returns
information about the user's selection in this structure. (Unicode)
PAGESETUPDLGA
Contains information the PageSetupDlg function uses to initialize the Page Setup dialog box. After
the user closes the dialog box, the system returns information about the user-defined page
parameters in this structure. (ANSI)
PAGESETUPDLGW
Contains information the PageSetupDlg function uses to initialize the Page Setup dialog box. After
the user closes the dialog box, the system returns information about the user-defined page
parameters in this structure. (Unicode)
PRINTDLGA
Contains information that the PrintDlg function uses to initialize the Print Dialog Box. After the
user closes the dialog box, the system uses this structure to return information about the user's
selections. (ANSI)
PRINTDLGEXA
Contains information that the PrintDlgEx function uses to initialize the Print property sheet. After
the user closes the property sheet, the system uses this structure to return information about the
user's selections. (ANSI)
PRINTDLGEXW
Contains information that the PrintDlgEx function uses to initialize the Print property sheet. After
the user closes the property sheet, the system uses this structure to return information about the
user's selections. (Unicode)
PRINTDLGW
Contains information that the PrintDlg function uses to initialize the Print Dialog Box. After the
user closes the dialog box, the system uses this structure to return information about the user's
selections. (Unicode)
PRINTPAGERANGE
Represents a range of pages in a print job. A print job can have more than one page range. This
information is supplied in the PRINTDLGEX structure when calling the PrintDlgEx function.
Feedback
Was this page helpful? ツ Yes ト No
Dialog Boxes
Interfaces
IPrintDialogCallback
Provides methods that enable an application to receive notifications and messages from the
PrintDlgEx function while the Print Property Sheet is displayed.
IPrintDialogServices
Provides methods that enable an application using the PrintDlgEx function to retrieve information
about the currently selected printer.
Functions
CDSIZEOF_STRUCT
CommDlg_OpenSave_GetFilePathA
CommDlg_OpenSave_GetFilePathW
CommDlg_OpenSave_GetFolderIDList
Retrieves the address of the item identifier list corresponding to the folder that an Explorer-style
Open or Save As dialog box currently has open.
CommDlg_OpenSave_GetFolderPathA
CommDlg_OpenSave_GetFolderPathW
CommDlg_OpenSave_GetSpecA
CommDlg_OpenSave_GetSpecW
CommDlg_OpenSave_HideControl
CommDlg_OpenSave_SetControlText
Sets the text for the specified control in an Explorer-style Open or Save As dialog box.
CommDlg_OpenSave_SetDefExt
Sets the default file name extension for an Explorer-style Open or Save As dialog box.
CommDlgExtendedError
The CommDlgExtendedError function (commdlg.h) returns a common dialog box error code.
FindTextA
Creates a system-defined modeless Find dialog box that lets the user specify a string to search for
and options to use when searching for text in a document. (ANSI)
FindTextW
Creates a system-defined modeless Find dialog box that lets the user specify a string to search for
and options to use when searching for text in a document. (Unicode)
GetFileTitleA
GetFileTitleW
Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or
set of files to be opened. (ANSI)
GetOpenFileNameW
Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or
set of files to be opened. (Unicode)
GetSaveFileNameA
Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save.
(ANSI)
GetSaveFileNameW
Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save.
(Unicode)
ReplaceTextA
Creates a system-defined modeless dialog box that lets the user specify a string to search for and
a replacement string, as well as options to control the find and replace operations. (ANSI)
ReplaceTextW
Creates a system-defined modeless dialog box that lets the user specify a string to search for and
a replacement string, as well as options to control the find and replace operations. (Unicode)
Callback functions
ChooseColorA
ChooseColorW
ChooseFontA
LPCCHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Color
dialog box. This is an application-defined or library-defined callback function that is used with the
ChooseColor function.
LPCFHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Font
dialog box. This is an application-defined or library-defined callback procedure that is used with
the ChooseFont function.
LPFRHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Find or
Replace dialog box.
LPOFNHOOKPROC
LPPAGEPAINTHOOK
Receives messages that allow you to customize drawing of the sample page in the Page Setup
dialog box. The PagePaintHook hook procedure is an application-defined or library-defined
callback function used with the PageSetupDlg function.
LPPAGESETUPHOOK
Receives messages or notifications intended for the default dialog box procedure of the Page
Setup dialog box. The PageSetupHook hook procedure is an application-defined or library-
defined callback function used with the PageSetupDlg function.
LPPRINTHOOKPROC
Receives messages or notifications intended for the default dialog box procedure of the Print
dialog box. This is an application-defined or library-defined callback function that is used with the
PrintDlg function.
LPSETUPHOOKPROC
An application-defined or library-defined callback function used with the PrintDlg function. The
hook procedure receives messages or notifications intended for the default dialog box procedure
of the Print Setup dialog box.
PageSetupDlgA
PageSetupDlgW
PrintDlgA
PrintDlgExA
PrintDlgExW
PrintDlgW
Structures
CHOOSECOLORA
CHOOSECOLORA
CHOOSECOLORW
CHOOSECOLORW
Contains information that the ChooseFont function uses to initialize the Font dialog box. After the
user closes the dialog box, the system returns information about the user's selection in this
structure. (ANSI)
CHOOSEFONTW
Contains information that the ChooseFont function uses to initialize the Font dialog box. After the
user closes the dialog box, the system returns information about the user's selection in this
structure. (Unicode)
DEVNAMES
Contains strings that identify the driver, device, and output port names for a printer.
FINDREPLACEA
Contains information that the FindText and ReplaceText functions use to initialize the Find and
Replace dialog boxes. (ANSI)
FINDREPLACEW
Contains information that the FindText and ReplaceText functions use to initialize the Find and
Replace dialog boxes. (Unicode)
OFNOTIFYA
Contains information about a WM_NOTIFY message sent to an OFNHookProc hook procedure for
an Open or Save As dialog box. The lParam parameter of the WM_NOTIFY message is a pointer to
an OFNOTIFY structure. (ANSI)
OFNOTIFYEXA
OFNOTIFYEXW
OFNOTIFYW
Contains information about a WM_NOTIFY message sent to an OFNHookProc hook procedure for
an Open or Save As dialog box. The lParam parameter of the WM_NOTIFY message is a pointer to
an OFNOTIFY structure. (Unicode)
OPENFILENAME_NT4A
The OPENFILENAME_NT4 structure is identical to OPENFILENAME with _WIN32_WINNT set to
0x0400. (ANSI)
OPENFILENAME_NT4W
OPENFILENAMEA
Contains information that the GetOpenFileName and GetSaveFileName functions use to initialize
an Open or Save As dialog box. After the user closes the dialog box, the system returns
information about the user's selection in this structure. (ANSI)
OPENFILENAMEW
Contains information that the GetOpenFileName and GetSaveFileName functions use to initialize
an Open or Save As dialog box. After the user closes the dialog box, the system returns
information about the user's selection in this structure. (Unicode)
PAGESETUPDLGA
Contains information the PageSetupDlg function uses to initialize the Page Setup dialog box. After
the user closes the dialog box, the system returns information about the user-defined page
parameters in this structure. (ANSI)
PAGESETUPDLGW
Contains information the PageSetupDlg function uses to initialize the Page Setup dialog box. After
the user closes the dialog box, the system returns information about the user-defined page
parameters in this structure. (Unicode)
PRINTDLGA
Contains information that the PrintDlg function uses to initialize the Print Dialog Box. After the
user closes the dialog box, the system uses this structure to return information about the user's
selections. (ANSI)
PRINTDLGEXA
Contains information that the PrintDlgEx function uses to initialize the Print property sheet. After
the user closes the property sheet, the system uses this structure to return information about the
user's selections. (ANSI)
PRINTDLGEXW
Contains information that the PrintDlgEx function uses to initialize the Print property sheet. After
the user closes the property sheet, the system uses this structure to return information about the
user's selections. (Unicode)
PRINTDLGW
Contains information that the PrintDlg function uses to initialize the Print Dialog Box. After the
user closes the dialog box, the system uses this structure to return information about the user's
selections. (Unicode)
PRINTPAGERANGE
Represents a range of pages in a print job. A print job can have more than one page range. This
information is supplied in the PRINTDLGEX structure when calling the PrintDlgEx function.
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
void CDSIZEOF_STRUCT(
structname,
member
);
Parameters
structname
member
Return value
None
Requirements
Header commdlg.h
Feedback
Was this page helpful? ツ Yes ト No
Get help at Microsoft Q&A
ChooseColorA callback function
(commdlg.h)
Article08/14/2023
2 Warning
Apps should generally call ChooseColor instead of calling this method directly.
Syntax
C++
ChooseColorA Choosecolora;
BOOL Choosecolora(
LPCHOOSECOLORA unnamedParam1
)
{...}
Parameters
unnamedParam1
Requirements
Header commdlg.h
See also
ChooseColor
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call ChooseColor instead of calling this method directly.
Syntax
C++
ChooseColorW Choosecolorw;
BOOL Choosecolorw(
LPCHOOSECOLORW unnamedParam1
)
{...}
Parameters
unnamedParam1
Requirements
Header commdlg.h
See also
ChooseColor
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call ChooseFont instead of calling this method directly.
Syntax
C++
ChooseFontA Choosefonta;
BOOL Choosefonta(
LPCHOOSEFONTA unnamedParam1
)
{...}
Parameters
unnamedParam1
Requirements
Header commdlg.h
See also
ChooseFont
Feedback
Was this page helpful? ツ Yes ト No
Contains information that the ChooseFont function uses to initialize the Font dialog box.
After the user closes the dialog box, the system returns information about the user's
selection in this structure.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hDC
Type: HDC
Windows Vista and Windows XP/2000: A handle to the device context or information
context of the printer whose fonts will be listed in the dialog box. This member is used
only if the Flags member specifies the CF_PRINTERFONTS or CF_BOTH flag; otherwise,
this member is ignored.
lpLogFont
Type: LPLOGFONT
iPointSize
Type: INT
The size of the selected font, in units of 1/10 of a point. The ChooseFont function sets
this value after the user closes the dialog box.
Flags
Type: DWORD
A set of bit flags that you can use to initialize the Font dialog box. When the dialog box
returns, it sets these flags to indicate the user input. This member can be one or more of
the following values.
Value Meaning
CF_APPLY Causes the dialog box to display the Apply button. You
0x00000200L should provide a hook procedure to process
WM_COMMAND messages for the Apply button. The
hook procedure can send the
WM_CHOOSEFONT_GETLOGFONT message to the dialog
box to retrieve the address of the structure that contains
the current selections for the font.
CF_EFFECTS Causes the dialog box to display the controls that allow
0x00000100L the user to specify strikeout, underline, and text color
options. If this flag is set, you can use the rgbColors
member to specify the initial text color. You can use the
lfStrikeOut and lfUnderline members of the structure
pointed to by lpLogFont to specify the initial settings of
the strikeout and underline check boxes. ChooseFont can
use these members to return the user's selections.
CF_LIMITSIZE ChooseFont should select only font sizes within the range
0x00002000L specified by the nSizeMin and nSizeMax members.
CF_NOSCRIPTSEL Disables the Script combo box. When this flag is set, the
0x00800000L lfCharSet member of the LOGFONT structure is set to
DEFAULT_CHARSET when ChooseFont returns. This flag is
used only to initialize the dialog box.
CF_SELECTSCRIPT When specified on input, only fonts with the character set
0x00400000L identified in the lfCharSet member of the LOGFONT
structure are displayed. The user will not be allowed to
change the character set specified in the Scripts combo
box.
CF_SHOWHELP Causes the dialog box to display the Help button. The
0x00000004L hwndOwner member must specify the window to receive
the HELPMSGSTRING registered messages that the dialog
box sends when the user clicks the Help button.
rgbColors
Type: COLORREF
If the CF_EFFECTS flag is set, rgbColors specifies the initial text color. When ChooseFont
returns successfully, this member contains the RGB value of the text color that the user
selected. To create a COLORREF color value, use the RGB macro.
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnHook member. When the system sends the WM_INITDIALOG message to the hook
procedure, the message's lParam parameter is a pointer to the CHOOSEFONT structure
specified when the dialog was created. The hook procedure can use this pointer to get
the lCustData value.
lpfnHook
Type: LPCFHOOKPROC
A pointer to a CFHookProc hook procedure that can process messages intended for the
dialog box. This member is ignored unless the CF_ENABLEHOOK flag is set in the Flags
member.
lpTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template is substituted for the standard dialog box template. For
numbered dialog box resources, lpTemplateName can be a value returned by the
MAKEINTRESOURCE macro. This member is ignored unless the CF_ENABLETEMPLATE
flag is set in the Flags member.
hInstance
Type: HINSTANCE
lpszStyle
Type: LPTSTR
The style data. If the CF_USESTYLE flag is specified, ChooseFont uses the data in this
buffer to initialize the Font Style combo box. When the user closes the dialog box,
ChooseFont copies the string in the Font Style combo box into this buffer.
nFontType
Type: WORD
The type of the selected font when ChooseFont returns. This member can be one or
more of the following values.
Value Meaning
___MISSING_ALIGNMENT__
nSizeMin
Type: INT
The minimum point size a user can select. ChooseFont recognizes this member only if
the CF_LIMITSIZE flag is specified.
nSizeMax
Type: INT
The maximum point size a user can select. ChooseFont recognizes this member only if
the CF_LIMITSIZE flag is specified.
Remarks
7 Note
Requirements
Header commdlg.h
See also
ChooseFont
Conceptual
MAKEINTRESOURCE
Reference
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call ChooseFont instead of calling this method directly.
Syntax
C++
ChooseFontW Choosefontw;
BOOL Choosefontw(
LPCHOOSEFONTW unnamedParam1
)
{...}
Parameters
unnamedParam1
Requirements
Header commdlg.h
See also
ChooseFont
Feedback
Was this page helpful? ツ Yes ト No
Contains information that the ChooseFont function uses to initialize the Font dialog box.
After the user closes the dialog box, the system returns information about the user's
selection in this structure.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hDC
Type: HDC
Windows Vista and Windows XP/2000: A handle to the device context or information
context of the printer whose fonts will be listed in the dialog box. This member is used
only if the Flags member specifies the CF_PRINTERFONTS or CF_BOTH flag; otherwise,
this member is ignored.
lpLogFont
Type: LPLOGFONT
iPointSize
Type: INT
The size of the selected font, in units of 1/10 of a point. The ChooseFont function sets
this value after the user closes the dialog box.
Flags
Type: DWORD
A set of bit flags that you can use to initialize the Font dialog box. When the dialog box
returns, it sets these flags to indicate the user input. This member can be one or more of
the following values.
Value Meaning
CF_APPLY Causes the dialog box to display the Apply button. You
0x00000200L should provide a hook procedure to process
WM_COMMAND messages for the Apply button. The
hook procedure can send the
WM_CHOOSEFONT_GETLOGFONT message to the dialog
box to retrieve the address of the structure that contains
the current selections for the font.
CF_EFFECTS Causes the dialog box to display the controls that allow
0x00000100L the user to specify strikeout, underline, and text color
options. If this flag is set, you can use the rgbColors
member to specify the initial text color. You can use the
lfStrikeOut and lfUnderline members of the structure
pointed to by lpLogFont to specify the initial settings of
the strikeout and underline check boxes. ChooseFont can
use these members to return the user's selections.
CF_LIMITSIZE ChooseFont should select only font sizes within the range
0x00002000L specified by the nSizeMin and nSizeMax members.
CF_NOSCRIPTSEL Disables the Script combo box. When this flag is set, the
0x00800000L lfCharSet member of the LOGFONT structure is set to
DEFAULT_CHARSET when ChooseFont returns. This flag is
used only to initialize the dialog box.
CF_SELECTSCRIPT When specified on input, only fonts with the character set
0x00400000L identified in the lfCharSet member of the LOGFONT
structure are displayed. The user will not be allowed to
change the character set specified in the Scripts combo
box.
CF_SHOWHELP Causes the dialog box to display the Help button. The
0x00000004L hwndOwner member must specify the window to receive
the HELPMSGSTRING registered messages that the dialog
box sends when the user clicks the Help button.
rgbColors
Type: COLORREF
If the CF_EFFECTS flag is set, rgbColors specifies the initial text color. When ChooseFont
returns successfully, this member contains the RGB value of the text color that the user
selected. To create a COLORREF color value, use the RGB macro.
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnHook member. When the system sends the WM_INITDIALOG message to the hook
procedure, the message's lParam parameter is a pointer to the CHOOSEFONT structure
specified when the dialog was created. The hook procedure can use this pointer to get
the lCustData value.
lpfnHook
Type: LPCFHOOKPROC
A pointer to a CFHookProc hook procedure that can process messages intended for the
dialog box. This member is ignored unless the CF_ENABLEHOOK flag is set in the Flags
member.
lpTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template is substituted for the standard dialog box template. For
numbered dialog box resources, lpTemplateName can be a value returned by the
MAKEINTRESOURCE macro. This member is ignored unless the CF_ENABLETEMPLATE
flag is set in the Flags member.
hInstance
Type: HINSTANCE
lpszStyle
Type: LPTSTR
The style data. If the CF_USESTYLE flag is specified, ChooseFont uses the data in this
buffer to initialize the Font Style combo box. When the user closes the dialog box,
ChooseFont copies the string in the Font Style combo box into this buffer.
nFontType
Type: WORD
The type of the selected font when ChooseFont returns. This member can be one or
more of the following values.
Value Meaning
___MISSING_ALIGNMENT__
nSizeMin
Type: INT
The minimum point size a user can select. ChooseFont recognizes this member only if
the CF_LIMITSIZE flag is specified.
nSizeMax
Type: INT
The maximum point size a user can select. ChooseFont recognizes this member only if
the CF_LIMITSIZE flag is specified.
Remarks
7 Note
Requirements
Header commdlg.h
See also
ChooseFont
Conceptual
MAKEINTRESOURCE
Reference
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Syntax
C++
void CommDlg_OpenSave_GetFilePathA(
_hdlg,
_psz,
_cbmax
);
Parameters
_hdlg
_psz
_cbmax
Requirements
Header commdlg.h
See also
CommDlg_OpenSave_GetFilePath
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Syntax
C++
void CommDlg_OpenSave_GetFilePathW(
_hdlg,
_psz,
_cbmax
);
Parameters
_hdlg
_psz
_cbmax
Requirements
Header commdlg.h
See also
CommDlg_OpenSave_GetFilePath
Feedback
Was this page helpful? ツ Yes ト No
Retrieves the address of the item identifier list corresponding to the folder that an
Explorer-style Open or Save As dialog box currently has open.
Syntax
C++
void CommDlg_OpenSave_GetFolderIDList(
_hdlg,
_pidl,
_cbmax
);
Parameters
_hdlg
_pidl
_cbmax
Requirements
Header commdlg.h
See also
CDM_GETFOLDERIDLIST
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Syntax
C++
void CommDlg_OpenSave_GetFolderPathA(
_hdlg,
_psz,
_cbmax
);
Parameters
_hdlg
_psz
_cbmax
Requirements
Header commdlg.h
See also
CommDlg_OpenSave_GetFolderPath
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Syntax
C++
void CommDlg_OpenSave_GetFolderPathW(
_hdlg,
_psz,
_cbmax
);
Parameters
_hdlg
_psz
_cbmax
Requirements
Header commdlg.h
See also
CommDlg_OpenSave_GetFolderPath
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Syntax
C++
void CommDlg_OpenSave_GetSpecA(
_hdlg,
_psz,
_cbmax
);
Parameters
_hdlg
_psz
_cbmax
Requirements
Header commdlg.h
See also
CommDlg_OpenSave_GetSpec
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Syntax
C++
void CommDlg_OpenSave_GetSpecW(
_hdlg,
_psz,
_cbmax
);
Parameters
_hdlg
_psz
_cbmax
Requirements
Header commdlg.h
See also
CommDlg_OpenSave_GetSpec
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
void CommDlg_OpenSave_HideControl(
_hdlg,
_id
);
Parameters
_hdlg
_id
Return value
None
Requirements
Header commdlg.h
See also
CDM_HIDECONTROL
Feedback
Was this page helpful? ツ Yes ト No
Sets the text for the specified control in an Explorer-style Open or Save As dialog box.
Syntax
C++
void CommDlg_OpenSave_SetControlText(
_hdlg,
_id,
_text
);
Parameters
_hdlg
_id
_text
Return value
None
Requirements
Header commdlg.h
See also
CDM_SETCONTROLTEXT
Feedback
Was this page helpful? ツ Yes ト No
Sets the default file name extension for an Explorer-style Open or Save As dialog box.
Syntax
C++
void CommDlg_OpenSave_SetDefExt(
_hdlg,
_pszext
);
Parameters
_hdlg
_pszext
Return value
None
Requirements
Header commdlg.h
See also
CDM_SETDEFEXT
Feedback
Was this page helpful? ツ Yes ト No
Returns a common dialog box error code. This code indicates the most recent error to
occur during the execution of one of the common dialog box functions.
Syntax
C++
DWORD CommDlgExtendedError();
Return value
Type: DWORD
If the most recent call to a common dialog box function succeeded, the return value is
undefined. If the common dialog box function returned FALSE because the user closed
or canceled the dialog box, the return value is zero. Otherwise, the return value is a
nonzero error code.
The CommDlgExtendedError function can return general error codes for any of the
common dialog box functions. In addition, there are error codes that are returned only
for a specific common dialog box. All of these error codes are defined in Cderr.h. The
following general error codes can be returned for any of the common dialog box
functions.
CDERR_DIALOGFAILURE The dialog box could not be created. The common dialog
0xFFFF box function's call to the DialogBox function failed. For
example, this error occurs if the common dialog box call
specifies an invalid window handle.
CDERR_MEMLOCKFAILURE The common dialog box function was unable to lock the
0x000A memory associated with a handle.
The following error codes can be returned for the PrintDlg function.
PDERR_LOADDRVFAILURE The PrintDlg function failed to load the device driver for
0x1004 the specified printer.
PDERR_PRINTERNOTFOUND The [devices] section of the WIN.INI file did not contain
0x100B an entry for the requested printer.
The following error codes can be returned for the ChooseFont function.
The following error codes can be returned for the GetOpenFileName and
GetSaveFileName functions.
The following error code can be returned for the FindText and ReplaceText functions.
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
API set ext-ms-win-shell-comdlg32-l1-1-0 (introduced in Windows 10, version
10.0.10240)
See also
CHOOSECOLOR
CHOOSEFONT
ChooseColor
ChooseFont
Conceptual
DEVNAMES
DialogBox
FINDREPLACE
FindText
GetOpenFileName
GetSaveFileName
OPENFILENAME
PAGESETUPDLG
PRINTDLG
PageSetupDlg
PrintDlg
Reference
RegisterWindowMessage
ReplaceText
Feedback
Was this page helpful? ツ Yes ト No
Contains strings that identify the driver, device, and output port names for a printer.
These strings must be ANSI strings when the ANSI version of PrintDlg or PrintDlgEx is
used, and must be Unicode strings when the Unicode version of PrintDlg or PrintDlgEx
is used. The PrintDlgEx and PrintDlg functions use these strings to initialize the system-
defined Print Property Sheet or Print Dialog Box. When the user closes the property
sheet or dialog box, information about the selected printer is returned in this structure.
Syntax
C++
Members
wDriverOffset
Type: WORD
The offset, in characters, from the beginning of this structure to a null-terminated string
that contains the file name (without the extension) of the device driver. On input, this
string is used to determine the printer to display initially in the dialog box.
wDeviceOffset
Type: WORD
The offset, in characters, from the beginning of this structure to the null-terminated
string that contains the name of the device.
wOutputOffset
Type: WORD
The offset, in characters, from the beginning of this structure to the null-terminated
string that contains the device name for the physical output medium (output port).
wDefault
Type: WORD
Indicates whether the strings contained in the DEVNAMES structure identify the default
printer. This string is used to verify that the default printer has not changed since the
last print operation. If any of the strings do not match, a warning message is displayed
informing the user that the document may need to be reformatted. On output, the
wDefault member is changed only if the Print Setup dialog box was displayed and the
user chose the OK button. The DN_DEFAULTPRN flag is used if the default printer was
selected. If a specific printer is selected, the flag is not used. All other flags in this
member are reserved for internal use by the dialog box procedure for the Print property
sheet or Print dialog box.
Requirements
See also
Common Dialog Box Library
Conceptual
PrintDlg
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Get help at Microsoft Q&A
FINDREPLACEA structure (commdlg.h)
Article07/27/2022
Contains information that the FindText and ReplaceText functions use to initialize the
Find and Replace dialog boxes. The FINDMSGSTRING registered message uses this
structure to pass the user's search or replacement input to the owner window of a Find
or Replace dialog box.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. The window procedure of the
specified window receives FINDMSGSTRING messages from the dialog box. This
member can be any valid window handle, but it must not be NULL.
hInstance
Type: HINSTANCE
Flags
Type: DWORD
A set of bit flags that you can use to initialize the dialog box. The dialog box sets these
flags when it sends the FINDMSGSTRING registered message to indicate the user's
input. This member can be one or more of the following values.
Value Meaning
FR_HIDEUPDOWN If set when initializing a Find dialog box, hides the search
0x00004000 direction radio buttons.
FR_SHOWHELP Causes the dialog box to display the Help button. The
0x00000080 hwndOwner member must specify the window to receive
the HELPMSGSTRING registered messages that the dialog
box sends when the user clicks the Help button.
FR_WHOLEWORD If set, the Match Whole Word Only check box is selected
0x00000002 indicating that you should search only for whole words
that match the search string. If not set, the check box is
unselected so you should also search for word fragments
that match the search string. You can set this flag to
initialize the dialog box. If set in a FINDMSGSTRING
message, indicates the user's selection.
lpstrFindWhat
Type: LPTSTR
The search string that the user typed in the Find What edit control. You must
dynamically allocate the buffer or use a global or static array so it does not go out of
scope before the dialog box closes. The buffer should be at least 80 characters long. If
the buffer contains a string when you initialize the dialog box, the string is displayed in
the Find What edit control. If a FINDMSGSTRING message specifies the FR_FINDNEXT
flag, lpstrFindWhat contains the string to search for. The FR_DOWN, FR_WHOLEWORD,
and FR_MATCHCASE flags indicate the direction and type of search. If a
FINDMSGSTRING message specifies the FR_REPLACE or FR_REPLACE flags,
lpstrFindWhat contains the string to be replaced.
lpstrReplaceWith
Type: LPTSTR
The replacement string that the user typed in the Replace With edit control. You must
dynamically allocate the buffer or use a global or static array so it does not go out of
scope before the dialog box closes. If the buffer contains a string when you initialize the
dialog box, the string is displayed in the Replace With edit control.
wFindWhatLen
Type: WORD
wReplaceWithLen
Type: WORD
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnHook member. When the system sends the WM_INITDIALOG message to the hook
procedure, the message's lParam parameter is a pointer to the FINDREPLACE structure
specified when the dialog was created. The hook procedure can use this pointer to get
the lCustData value.
lpfnHook
Type: LPFRHOOKPROC
A pointer to an FRHookProc hook procedure that can process messages intended for
the dialog box. This member is ignored unless the FR_ENABLEHOOK flag is set in the
Flags member. If the hook procedure returns FALSE in response to the WM_INITDIALOG
message, the hook procedure must display the dialog box or else the dialog box will not
be shown. To do this, first perform any other paint operations, and then call the
ShowWindow and UpdateWindow functions.
lpTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template is substituted for the standard dialog box template. For
numbered dialog box resources, this can be a value returned by the MAKEINTRESOURCE
macro. This member is ignored unless the FR_ENABLETEMPLATE flag is set in the Flags
member.
Remarks
7 Note
Requirements
See also
Common Dialog Box Library
Conceptual
FRHookProc
FindText
MAKEINTRESOURCE
Reference
ReplaceText
ShowWindow
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Contains information that the FindText and ReplaceText functions use to initialize the
Find and Replace dialog boxes. The FINDMSGSTRING registered message uses this
structure to pass the user's search or replacement input to the owner window of a Find
or Replace dialog box.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. The window procedure of the
specified window receives FINDMSGSTRING messages from the dialog box. This
member can be any valid window handle, but it must not be NULL.
hInstance
Type: HINSTANCE
Flags
Type: DWORD
A set of bit flags that you can use to initialize the dialog box. The dialog box sets these
flags when it sends the FINDMSGSTRING registered message to indicate the user's
input. This member can be one or more of the following values.
Value Meaning
FR_HIDEUPDOWN If set when initializing a Find dialog box, hides the search
0x00004000 direction radio buttons.
FR_SHOWHELP Causes the dialog box to display the Help button. The
0x00000080 hwndOwner member must specify the window to receive
the HELPMSGSTRING registered messages that the dialog
box sends when the user clicks the Help button.
FR_WHOLEWORD If set, the Match Whole Word Only check box is selected
0x00000002 indicating that you should search only for whole words
that match the search string. If not set, the check box is
unselected so you should also search for word fragments
that match the search string. You can set this flag to
initialize the dialog box. If set in a FINDMSGSTRING
message, indicates the user's selection.
lpstrFindWhat
Type: LPTSTR
The search string that the user typed in the Find What edit control. You must
dynamically allocate the buffer or use a global or static array so it does not go out of
scope before the dialog box closes. The buffer should be at least 80 characters long. If
the buffer contains a string when you initialize the dialog box, the string is displayed in
the Find What edit control. If a FINDMSGSTRING message specifies the FR_FINDNEXT
flag, lpstrFindWhat contains the string to search for. The FR_DOWN, FR_WHOLEWORD,
and FR_MATCHCASE flags indicate the direction and type of search. If a
FINDMSGSTRING message specifies the FR_REPLACE or FR_REPLACE flags,
lpstrFindWhat contains the string to be replaced.
lpstrReplaceWith
Type: LPTSTR
The replacement string that the user typed in the Replace With edit control. You must
dynamically allocate the buffer or use a global or static array so it does not go out of
scope before the dialog box closes. If the buffer contains a string when you initialize the
dialog box, the string is displayed in the Replace With edit control.
wFindWhatLen
Type: WORD
wReplaceWithLen
Type: WORD
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnHook member. When the system sends the WM_INITDIALOG message to the hook
procedure, the message's lParam parameter is a pointer to the FINDREPLACE structure
specified when the dialog was created. The hook procedure can use this pointer to get
the lCustData value.
lpfnHook
Type: LPFRHOOKPROC
A pointer to an FRHookProc hook procedure that can process messages intended for
the dialog box. This member is ignored unless the FR_ENABLEHOOK flag is set in the
Flags member. If the hook procedure returns FALSE in response to the WM_INITDIALOG
message, the hook procedure must display the dialog box or else the dialog box will not
be shown. To do this, first perform any other paint operations, and then call the
ShowWindow and UpdateWindow functions.
lpTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template is substituted for the standard dialog box template. For
numbered dialog box resources, this can be a value returned by the MAKEINTRESOURCE
macro. This member is ignored unless the FR_ENABLETEMPLATE flag is set in the Flags
member.
Remarks
7 Note
Requirements
See also
Common Dialog Box Library
Conceptual
FRHookProc
FindText
MAKEINTRESOURCE
Reference
ReplaceText
ShowWindow
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Creates a system-defined modeless Find dialog box that lets the user specify a string to
search for and options to use when searching for text in a document.
Syntax
C++
HWND FindTextA(
[in] LPFINDREPLACEA unnamedParam1
);
Parameters
[in] unnamedParam1
Type: LPFINDREPLACE
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box. You
can use the window handle to communicate with or to close the dialog box.
If the function fails, the return value is NULL. To get extended error information, call the
CommDlgExtendedError function. CommDlgExtendedError may return one of the
following error codes:
Remarks
The FindText function does not perform a search operation. Instead, the dialog box
sends FINDMSGSTRING registered messages to the window procedure of the owner
window of the dialog box. When you create the dialog box, the hwndOwner member of
the FINDREPLACE structure is a handle to the owner window.
Before calling FindText, you must call the RegisterWindowMessage function to get the
identifier for the FINDMSGSTRING message. The dialog box procedure uses this
identifier to send messages when the user clicks the Find Next button, or when the
dialog box is closing. The lParam parameter of the FINDMSGSTRING message contains
a pointer to a FINDREPLACE structure. The Flags member of this structure indicates the
event that caused the message. Other members of the structure indicate the user's
input.
If you create a Find dialog box, you must also use the IsDialogMessage function in the
main message loop of your application to ensure that the dialog box correctly processes
keyboard input, such as the TAB and ESC keys. IsDialogMessage returns a value that
indicates whether the Find dialog box processed the message.
You can provide an FRHookProc hook procedure for a Find dialog box. The hook
procedure can process messages sent to the dialog box. To enable a hook procedure,
set the FR_ENABLEHOOK flag in the Flags member of the FINDREPLACE structure and
specify the address of the hook procedure in the lpfnHook member.
Examples
7 Note
The commdlg.h header defines FindText as an alias which automatically selects the
ANSI or Unicode version of this function based on the definition of the UNICODE
preprocessor constant. Mixing usage of the encoding-neutral alias with code that
not encoding-neutral can lead to mismatches that result in compilation or runtime
errors. For more information, see Conventions for Function Prototypes.
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
See also
CommDlgExtendedError
Conceptual
FINDMSGSTRING
FINDREPLACE
FRHookProc
IsDialogMessage
Reference
RegisterWindowMessage
ReplaceText
Feedback
Was this page helpful? ツ Yes ト No
Creates a system-defined modeless Find dialog box that lets the user specify a string to
search for and options to use when searching for text in a document.
Syntax
C++
HWND FindTextW(
[in] LPFINDREPLACEW unnamedParam1
);
Parameters
[in] unnamedParam1
Type: LPFINDREPLACE
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box. You
can use the window handle to communicate with or to close the dialog box.
If the function fails, the return value is NULL. To get extended error information, call the
CommDlgExtendedError function. CommDlgExtendedError may return one of the
following error codes:
Remarks
The FindText function does not perform a search operation. Instead, the dialog box
sends FINDMSGSTRING registered messages to the window procedure of the owner
window of the dialog box. When you create the dialog box, the hwndOwner member of
the FINDREPLACE structure is a handle to the owner window.
Before calling FindText, you must call the RegisterWindowMessage function to get the
identifier for the FINDMSGSTRING message. The dialog box procedure uses this
identifier to send messages when the user clicks the Find Next button, or when the
dialog box is closing. The lParam parameter of the FINDMSGSTRING message contains
a pointer to a FINDREPLACE structure. The Flags member of this structure indicates the
event that caused the message. Other members of the structure indicate the user's
input.
If you create a Find dialog box, you must also use the IsDialogMessage function in the
main message loop of your application to ensure that the dialog box correctly processes
keyboard input, such as the TAB and ESC keys. IsDialogMessage returns a value that
indicates whether the Find dialog box processed the message.
You can provide an FRHookProc hook procedure for a Find dialog box. The hook
procedure can process messages sent to the dialog box. To enable a hook procedure,
set the FR_ENABLEHOOK flag in the Flags member of the FINDREPLACE structure and
specify the address of the hook procedure in the lpfnHook member.
Examples
7 Note
The commdlg.h header defines FindText as an alias which automatically selects the
ANSI or Unicode version of this function based on the definition of the UNICODE
preprocessor constant. Mixing usage of the encoding-neutral alias with code that
not encoding-neutral can lead to mismatches that result in compilation or runtime
errors. For more information, see Conventions for Function Prototypes.
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
See also
CommDlgExtendedError
Conceptual
FINDMSGSTRING
FINDREPLACE
FRHookProc
IsDialogMessage
Reference
RegisterWindowMessage
ReplaceText
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
short GetFileTitleA(
[in] LPCSTR unnamedParam1,
[out] LPSTR Buf,
[in] WORD cchSize
);
Parameters
[in] unnamedParam1
Type: LPCTSTR
[out] Buf
Type: LPTSTR
[in] cchSize
Type: WORD
Return value
Type: short
If the file name is invalid, the return value is unknown. If there is an error, the return
value is a negative number.
If the buffer pointed to by the lpszTitle parameter is too small, the return value is a
positive integer that specifies the required buffer size, in characters. The required buffer
size includes the terminating null character.
Remarks
GetFileTitle should only be called with legal file names; using an illegal file name has an
undefined result.
To get the buffer size needed for the name of a file, call the function with lpszTitle set to
NULL and cchSize set to zero. The function returns the required size.
GetFileTitle returns the string that the system would use to display the file name to the
user. The display name includes an extension only if that is the user's preference for
displaying file names. This means that the returned string may not accurately identify
the file if it is used in calls to file system functions.
If the lpszTitle buffer is too small, GetFileTitle returns the size required to hold the
display name. However, there is no guaranteed relationship between the required size
and the characters originally specified in the lpszFile buffer. For example, do not call
GetFileTitle with lpszTitle set to NULL and cchSize set to zero, and then try to use the
return value as an index into the lpszFile string. You can usually achieve similar results
(and superior performance) with C run-time library functions such as strrchr, wcsrchr,
and _mbsrchr.
7 Note
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
GetOpenFileName
GetSaveFileName
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
short GetFileTitleW(
[in] LPCWSTR unnamedParam1,
[out] LPWSTR Buf,
[in] WORD cchSize
);
Parameters
[in] unnamedParam1
Type: LPCTSTR
[out] Buf
Type: LPTSTR
[in] cchSize
Type: WORD
Return value
Type: short
If the file name is invalid, the return value is unknown. If there is an error, the return
value is a negative number.
If the buffer pointed to by the lpszTitle parameter is too small, the return value is a
positive integer that specifies the required buffer size, in characters. The required buffer
size includes the terminating null character.
Remarks
GetFileTitle should only be called with legal file names; using an illegal file name has an
undefined result.
To get the buffer size needed for the name of a file, call the function with lpszTitle set to
NULL and cchSize set to zero. The function returns the required size.
GetFileTitle returns the string that the system would use to display the file name to the
user. The display name includes an extension only if that is the user's preference for
displaying file names. This means that the returned string may not accurately identify
the file if it is used in calls to file system functions.
If the lpszTitle buffer is too small, GetFileTitle returns the size required to hold the
display name. However, there is no guaranteed relationship between the required size
and the characters originally specified in the lpszFile buffer. For example, do not call
GetFileTitle with lpszTitle set to NULL and cchSize set to zero, and then try to use the
return value as an index into the lpszFile string. You can usually achieve similar results
(and superior performance) with C run-time library functions such as strrchr, wcsrchr,
and _mbsrchr.
7 Note
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
GetOpenFileName
GetSaveFileName
Reference
Feedback
Was this page helpful? ツ Yes ト No
[Starting with Windows Vista, the Open and Save As common dialog boxes have been
superseded by the Common Item Dialog. We recommended that you use the Common
Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
Creates an Open dialog box that lets the user specify the drive, directory, and the name
of a file or set of files to be opened.
Syntax
C++
BOOL GetOpenFileNameA(
[in, out] LPOPENFILENAMEA unnamedParam1
);
Parameters
[in, out] unnamedParam1
Type: LPOPENFILENAME
Return value
Type: BOOL
If the user specifies a file name and clicks the OK button, the return value is nonzero.
The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains
the full path and file name specified by the user.
If the user cancels or closes the Open dialog box or an error occurs, the return value is
zero. To get extended error information, call the CommDlgExtendedError function, which
can return one of the following values.
Remarks
The Explorer-style Open dialog box provides user-interface features that are similar to
the Windows Explorer. You can provide an OFNHookProc hook procedure for an
Explorer-style Open dialog box. To enable the hook procedure, set the OFN_EXPLORER
and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and
specify the address of the hook procedure in the lpfnHook member.
Windows continues to support the old-style Open dialog box for applications that want
to maintain a user-interface consistent with the old-style user-interface. To display the
old-style Open dialog box, enable an OFNHookProcOldStyle hook procedure and
ensure that the OFN_EXPLORER flag is not set.
To display a dialog box that allows the user to select a directory instead of a file, call the
SHBrowseForFolder function.
Note, when selecting multiple files, the total character limit for the file names depends
on the version of the function.
Examples
7 Note
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
See also
CommDlgExtendedError
Conceptual
GetSaveFileName
OFNHookProc
OFNHookProcOldStyle
OPENFILENAME
Other Resources
Reference
SHBrowseForFolder
Feedback
Was this page helpful? ツ Yes ト No
[Starting with Windows Vista, the Open and Save As common dialog boxes have been
superseded by the Common Item Dialog. We recommended that you use the Common
Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
Creates an Open dialog box that lets the user specify the drive, directory, and the name
of a file or set of files to be opened.
Syntax
C++
BOOL GetOpenFileNameW(
[in, out] LPOPENFILENAMEW unnamedParam1
);
Parameters
[in, out] unnamedParam1
Type: LPOPENFILENAME
Return value
Type: BOOL
If the user specifies a file name and clicks the OK button, the return value is nonzero.
The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains
the full path and file name specified by the user.
If the user cancels or closes the Open dialog box or an error occurs, the return value is
zero. To get extended error information, call the CommDlgExtendedError function, which
can return one of the following values.
Remarks
The Explorer-style Open dialog box provides user-interface features that are similar to
the Windows Explorer. You can provide an OFNHookProc hook procedure for an
Explorer-style Open dialog box. To enable the hook procedure, set the OFN_EXPLORER
and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and
specify the address of the hook procedure in the lpfnHook member.
Windows continues to support the old-style Open dialog box for applications that want
to maintain a user-interface consistent with the old-style user-interface. To display the
old-style Open dialog box, enable an OFNHookProcOldStyle hook procedure and
ensure that the OFN_EXPLORER flag is not set.
To display a dialog box that allows the user to select a directory instead of a file, call the
SHBrowseForFolder function.
Note, when selecting multiple files, the total character limit for the file names depends
on the version of the function.
Examples
7 Note
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
See also
CommDlgExtendedError
Conceptual
GetSaveFileName
OFNHookProc
OFNHookProcOldStyle
OPENFILENAME
Other Resources
Reference
SHBrowseForFolder
Feedback
Was this page helpful? ツ Yes ト No
[Starting with Windows Vista, the Open and Save As common dialog boxes have been
superseded by the Common Item Dialog. We recommended that you use the Common
Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
Creates a Save dialog box that lets the user specify the drive, directory, and name of a
file to save.
Syntax
C++
BOOL GetSaveFileNameA(
[in, out] LPOPENFILENAMEA unnamedParam1
);
Parameters
[in, out] unnamedParam1
Type: LPOPENFILENAME
Return value
Type: BOOL
If the user specifies a file name and clicks the OK button and the function is successful,
the return value is nonzero. The buffer pointed to by the lpstrFile member of the
OPENFILENAME structure contains the full path and file name specified by the user.
If the user cancels or closes the Save dialog box or an error such as the file name buffer
being too small occurs, the return value is zero. To get extended error information, call
the CommDlgExtendedError function, which can return one of the following values:
Remarks
The Explorer-style Save dialog box that provides user-interface features that are similar
to the Windows Explorer. You can provide an OFNHookProc hook procedure for an
Explorer-style Save dialog box. To enable the hook procedure, set the OFN_EXPLORER
and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and
specify the address of the hook procedure in the lpfnHook member.
Windows continues to support old-style Save dialog boxes for applications that want to
maintain a user-interface consistent with the old-style user-interface. To display the old-
style Save dialog box, enable an OFNHookProcOldStyle hook procedure and ensure that
the OFN_EXPLORER flag is not set.
Examples
For an example, see Creating an Enhanced Metafile.
7 Note
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
API set ext-ms-win-shell-comdlg32-l1-1-1 (introduced in Windows 10, version
10.0.14393)
See also
CommDlgExtendedError
Conceptual
GetOpenFileName
OFNHookProc
OFNHookProcOldStyle
OPENFILENAME
Reference
Feedback
Was this page helpful? ツ Yes ト No
[Starting with Windows Vista, the Open and Save As common dialog boxes have been
superseded by the Common Item Dialog. We recommended that you use the Common
Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
Creates a Save dialog box that lets the user specify the drive, directory, and name of a
file to save.
Syntax
C++
BOOL GetSaveFileNameW(
[in, out] LPOPENFILENAMEW unnamedParam1
);
Parameters
[in, out] unnamedParam1
Type: LPOPENFILENAME
Return value
Type: BOOL
If the user specifies a file name and clicks the OK button and the function is successful,
the return value is nonzero. The buffer pointed to by the lpstrFile member of the
OPENFILENAME structure contains the full path and file name specified by the user.
If the user cancels or closes the Save dialog box or an error such as the file name buffer
being too small occurs, the return value is zero. To get extended error information, call
the CommDlgExtendedError function, which can return one of the following values:
Remarks
The Explorer-style Save dialog box that provides user-interface features that are similar
to the Windows Explorer. You can provide an OFNHookProc hook procedure for an
Explorer-style Save dialog box. To enable the hook procedure, set the OFN_EXPLORER
and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and
specify the address of the hook procedure in the lpfnHook member.
Windows continues to support old-style Save dialog boxes for applications that want to
maintain a user-interface consistent with the old-style user-interface. To display the old-
style Save dialog box, enable an OFNHookProcOldStyle hook procedure and ensure that
the OFN_EXPLORER flag is not set.
Examples
For an example, see Creating an Enhanced Metafile.
7 Note
Requirements
Library Comdlg32.lib
DLL Comdlg32.dll
API set ext-ms-win-shell-comdlg32-l1-1-1 (introduced in Windows 10, version
10.0.14393)
See also
CommDlgExtendedError
Conceptual
GetOpenFileName
OFNHookProc
OFNHookProcOldStyle
OPENFILENAME
Reference
Feedback
Was this page helpful? ツ Yes ト No
Provides methods that enable an application to receive notifications and messages from
the PrintDlgEx function while the Print Property Sheet is displayed.
Inheritance
The IPrintDialogCallback interface inherits from the IUnknown interface.
IPrintDialogCallback also has these types of members:
Methods
The IPrintDialogCallback interface has these methods.
IPrintDialogCallback::AddRef
IPrintDialogCallback::HandleMessage
Called by PrintDlgEx to give your application an opportunity to handle messages sent to the child
dialog box in the lower portion of the General page of the Print Property Sheet.
IPrintDialogCallback::InitDone
Called by PrintDlgEx when the system has finished initializing the General page of the Print
Property Sheet.
IPrintDialogCallback::QueryInterface
IPrintDialogCallback::Release
Called by PrintDlgEx when the user selects a different printer from the list of installed printers on
the General page of the Print Property Sheet.
Requirements
See also
IPrintDialogServices
PRINTDLGEX
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
ULONG AddRef();
Requirements
Header commdlg.h
See also
IUnknown::AddRef
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
HRESULT HandleMessage(
HWND hDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
LRESULT *pResult
);
Parameters
hDlg
Type: HWND
A handle to the child dialog box in the lower portion of the General page.
uMsg
Type: UINT
wParam
Type: WPARAM
Additional information about the message. The exact meaning depends on the value of
the uMsg parameter.
lParam
Type: LPARAM
Additional information about the message. The exact meaning depends on the value of
the uMsg parameter.
pResult
Type: LRESULT*
Indicates the result to be returned by the dialog box procedure for the message. The
value pointed to should be TRUE if you process the message, otherwise it should be
FALSE or whatever is an appropriate value according to the message type.
Return value
Type: HRESULT
Return S_FALSE if you want PrintDlgEx to perform its default message handling.
Remarks
For notification messages passed by the WM_NOTIFY message, you must use the
SetWindowLong function with the DWL_MSGRESULT value to set a return value. When
you call SetWindowLong, use GetParent(hDlg) to set the DWL_MSGRESULT value of the
General page, which is the parent of the child window.
The default dialog box procedure for the child window in the lower portion of the
General page processes the WM_INITDIALOG message before passing it to the
HandleMessage method. For all other messages sent to the child window,
HandleMessage receives the message first. Then the HandleMessage return value
determines whether the default dialog procedure processes the message or ignores it.
Do not call the EndDialog function from the HandleMessage method. Instead,
HandleMessage can call the PostMessage function to post a WM_COMMAND message
with the IDABORT value to the dialog box procedure. Posting IDABORT closes the Print
Property Sheet and causes PrintDlgEx to return PD_RESULT_CANCEL in the
dwResultAction member of the PRINTDLGEX structure. If you need to know why
HandleMessage closed the dialog box, you must provide your own communication
mechanism between the HandleMessage method and your application.
You can subclass the standard controls of the child dialog box in the lower portion of
the General page. These standard controls are similar to those found in the Print dialog
box. However, the default dialog box procedure may also subclass the controls. Because
of this, you should subclass controls when HandleMessage processes the
WM_INITDIALOG message. This ensures that your subclass procedure receives control-
specific messages before the subclass procedure set by the dialog box procedure.
Requirements
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
EndDialog
IPrintDialogCallback
Other Resources
PRINTDLGEX
PostMessage
PrintDlgEx
Reference
SetWindowLong
WM_COMMAND
WM_CTLCOLORDLG
WM_INITDIALOG
WM_NOTIFY
Feedback
Was this page helpful? ツ Yes ト No
Called by PrintDlgEx when the system has finished initializing the General page of the
Print Property Sheet.
Syntax
C++
HRESULT InitDone();
Return value
Type: HRESULT
Return S_OK to prevent the PrintDlgEx function from performing its default actions.
Return S_FALSE to allow PrintDlgEx to perform its default actions. Currently, PrintDlgEx
does not perform any default processing after the InitDone call.
Remarks
If your callback object implements the IObjectWithSite interface, the PrintDlgEx function
calls the IObjectWithSite::SetSite method to pass an IPrintDialogServices pointer to the
callback object. The PrintDlgEx function calls the IObjectWithSite::SetSite method
before calling the InitDone method. This enables your InitDone implementation to use
the IPrintDialogServices methods to retrieve information about the currently selected
printer.
Requirements
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
IPrintDialogCallback
IPrintDialogServices
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
HRESULT QueryInterface(
REFIID riid,
void **ppvObj
);
Parameters
riid
ppvObj
Requirements
Header commdlg.h
See also
IUnknown::QueryInterface
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
ULONG Release();
Requirements
Header commdlg.h
See also
IUnknown::Release
Feedback
Was this page helpful? ツ Yes ト No
Called by PrintDlgEx when the user selects a different printer from the list of installed
printers on the General page of the Print Property Sheet.
Syntax
C++
HRESULT SelectionChange();
Return value
Type: HRESULT
Return S_OK to prevent the PrintDlgEx function from performing its default actions.
Return S_FALSE to allow PrintDlgEx to perform its default actions, which include
adjustments to the Copies, Collate, and Print Range items.
Requirements
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
IPrintDialogCallback
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Provides methods that enable an application using the PrintDlgEx function to retrieve
information about the currently selected printer.
Inheritance
The IPrintDialogServices interface inherits from the IUnknown interface.
IPrintDialogServices also has these types of members:
Methods
The IPrintDialogServices interface has these methods.
IPrintDialogServices::AddRef
IPrintDialogServices::GetCurrentDevMode
Fills a DEVMODE structure with information about the currently selected printer for use with
PrintDlgEx.
IPrintDialogServices::GetCurrentPortName
Retrieves the name of the current port for use with PrintDlgEx.
IPrintDialogServices::GetCurrentPrinterName
Retrieves the name of the currently selected printer, for use with PrintDlgEx.
IPrintDialogServices::QueryInterface
Remarks
This printer is indicated on the list of installed printers on the General page of the Print
Property Sheet.
Requirements
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
ULONG AddRef();
Requirements
Header commdlg.h
See also
IUnknown::AddRef
Feedback
Was this page helpful? ツ Yes ト No
Fills a DEVMODE structure with information about the currently selected printer for use
with PrintDlgEx.
Syntax
C++
HRESULT GetCurrentDevMode(
LPDEVMODE pDevMode,
UINT *pcbSize
);
Parameters
pDevMode
Type: LPDEVMODE
pcbSize
Type: UINT*
On input, the variable specifies the size, in bytes, of the buffer pointed to by the
lpDevMode parameter. On output, the variable contains the number of bytes written to
lpDevMode.
If the size is zero on input, the function returns the required buffer size (in bytes) in
pcbSize and does not use the lpDevMode buffer.
Return value
Type: HRESULT
If the method is successful, the return value is S_OK. If no printer is currently selected,
the return value is S_OK, the value returned in pcbSize is zero, and the lpDevMode buffer
is unchanged.
If an error occurs, the return value is a COM error code. For more information, see Error
Handling.
Requirements
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
DEVMODE
IPrintDialogServices
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Retrieves the name of the current port for use with PrintDlgEx.
Syntax
C++
HRESULT GetCurrentPortName(
LPWSTR pPortName,
UINT *pcchSize
);
Parameters
pPortName
Type: LPTSTR
pcchSize
Type: UINT*
On input, the variable specifies the size, in characters, of the buffer pointed to by the
lpPortName parameter. On output, the variable contains the number of bytes (ANSI) or
characters (Unicode), including the terminating null character, written to the buffer.
If the size is zero on input, the function returns the required buffer size (in bytes or
characters) in pcchSize and does not use the lpPortName buffer.
Return value
Type: HRESULT
If the method is successful, the return value is S_OK. If there is no current port, the
return value is S_OK, the value returned in pcchSize is zero, and the lpPortName buffer is
unchanged.
If an error occurs, the return value is a COM error code. For more information, see Error
Handling.
Requirements
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
IPrintDialogServices
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Retrieves the name of the currently selected printer, for use with PrintDlgEx.
Syntax
C++
HRESULT GetCurrentPrinterName(
LPWSTR pPrinterName,
UINT *pcchSize
);
Parameters
pPrinterName
Type: LPTSTR
pcchSize
Type: UINT*
On input, the variable specifies the size, in characters, of the buffer pointed to by the
lpPrinterName parameter. On output, the variable contains the number of bytes (ANSI)
or characters (Unicode), including the terminating null character, written to the buffer.
If the size is zero on input, the function returns the required buffer size (in bytes or
characters) in pcchSize and does not use the lpPrinterName buffer.
Return value
Type: HRESULT
If the method is successful, the return value is S_OK. If no printer is currently selected,
the return value is S_OK, the value returned in pcchSize is zero, and the lpPrinterName
buffer is unchanged.
If an error occurs, the return value is a COM error code. For more information, see Error
Handling.
Requirements
DLL Comdlg32.dll
See also
Common Dialog Box Library
Conceptual
IPrintDialogServices
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
HRESULT QueryInterface(
REFIID riid,
void **ppvObj
);
Parameters
riid
ppvObj
Requirements
Header commdlg.h
See also
IUnknown::QueryInterface
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
ULONG Release();
Requirements
Header commdlg.h
See also
IUnknown::Release
Feedback
Was this page helpful? ツ Yes ト No
Receives messages or notifications intended for the default dialog box procedure of the
Color dialog box. This is an application-defined or library-defined callback function that
is used with the ChooseColor function.
Syntax
C++
LPCCHOOKPROC Lpcchookproc;
UINT_PTR Lpcchookproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
A handle to the Color dialog box for which the message is intended.
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter. If the unnamedParam2 parameter indicates the
WM_INITDIALOG message, then unnamedParam4 is a pointer to a CHOOSECOLOR
structure containing the values specified when the dialog was created.
Return value
If the hook procedure returns zero, the default dialog box procedure processes the
message.
If the hook procedure returns a nonzero value, the default dialog box procedure ignores
the message.
Remarks
When you use the ChooseColor function to create a Color dialog box, you can provide a
CCHookProc hook procedure to process messages or notifications intended for the
dialog box procedure. To enable the hook procedure, use the CHOOSECOLOR structure
that you passed to the dialog creation function. Specify the address of the hook
procedure in the lpfnHook member and specify the CC_ENABLEHOOK flag in the Flags
member.
The default dialog box procedure processes the WM_INITDIALOG message before
passing it to the hook procedure. For all other messages, the hook procedure receives
the message first. Then, the return value of the hook procedure determines whether the
default dialog procedure processes the message or ignores it.
If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid
brush handle to painting the background of the dialog box. In general, if the hook
procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
to painting the background of the specified control.
Do not call the EndDialog function from the hook procedure. Instead, the hook
procedure can call the PostMessage function to post a WM_COMMAND message with
the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog box
and causes the dialog box function to return FALSE. If you need to know why the hook
procedure closed the dialog box, you must provide your own communication
mechanism between the hook procedure and your application.
You can subclass the standard controls of a common dialog box. However, the dialog
box procedure may also subclass the controls. Because of this, you should subclass
controls when your hook procedure processes the WM_INITDIALOG message. This
ensures that your subclass procedure receives the control-specific messages before the
subclass procedure set by the dialog box procedure.
Requirements
See also
CHOOSECOLOR
ChooseColor
Conceptual
EndDialog
PostMessage
Reference
WM_CTLCOLORDLG
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Receives messages or notifications intended for the default dialog box procedure of the
Font dialog box. This is an application-defined or library-defined callback procedure
that is used with the ChooseFont function.
Syntax
C++
LPCFHOOKPROC Lpcfhookproc;
UINT_PTR Lpcfhookproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
A handle to the Font dialog box for which the message is intended.
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter. If the unnamedParam2 parameter indicates the
WM_INITDIALOG message, unnamedParam4 is a pointer to a CHOOSEFONT structure
containing the values specified when the dialog box was created.
Return value
If the hook procedure returns zero, the default dialog box procedure processes the
message.
If the hook procedure returns a nonzero value, the default dialog box procedure ignores
the message.
Remarks
When you use the ChooseFont function to create a Font dialog box, you can provide a
CFHookProc hook procedure to process messages or notifications intended for the
dialog box procedure. To enable the hook procedure, use the CHOOSEFONT structure
that you passed to the dialog creation function. Specify the address of the hook
procedure in the lpfnHook member and specify the CF_ENABLEHOOK flag in the Flags
member.
The default dialog box procedure processes the WM_INITDIALOG message before
passing it to the hook procedure. For all other messages, the hook procedure receives
the message first. The return value of the hook procedure determines whether the
default dialog box procedure processes the message or ignores it.
If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid
brush handle to paint the background of the dialog box. In general, if the hook
procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
to paint the background of the specified control.
Do not call the EndDialog function from the hook procedure. Instead, the hook
procedure can call the PostMessage function to post a WM_COMMAND message with
the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog box
and causes the dialog box function to return FALSE. If you need to know why the hook
procedure closed the dialog box, you must provide your own communication
mechanism between the hook procedure and your application.
You can subclass the standard controls of a common dialog box. However, the dialog
box procedure may also subclass the controls. Because of this, you should subclass
controls when your hook procedure processes the WM_INITDIALOG message. This
ensures that your subclass procedure receives the control-specific messages before the
subclass procedure set by the dialog box procedure.
Requirements
See also
CHOOSEFONT
ChooseFont
Conceptual
EndDialog
PostMessage
Reference
WM_CTLCOLORDLG
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Receives messages or notifications intended for the default dialog box procedure of the
Find or Replace dialog box. The FRHookProc hook procedure is an application-defined
or library-defined callback function that is used with the FindText or ReplaceText
function.
Syntax
C++
LPFRHOOKPROC Lpfrhookproc;
UINT_PTR Lpfrhookproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
A handle to the Find or Replace dialog box for which the message is intended.
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
Return value
If the hook procedure returns zero, the default dialog box procedure processes the
message.
If the hook procedure returns a nonzero value, the default dialog box procedure ignores
the message.
Remarks
When you use the FindText or ReplaceText functions to create a Find or Replace dialog
box, you can provide an FRHookProc hook procedure to process messages or
notifications intended for the dialog box procedure. To enable the hook procedure, use
the FINDREPLACE structure that you passed to the dialog creation function. Specify the
address of the hook procedure in the lpfnHook member and specify the
FR_ENABLEHOOK flag in the Flags member.
The default dialog box procedure processes the WM_INITDIALOG message before
passing it to the hook procedure. For all other messages, the hook procedure receives
the message first. Then, the return value of the hook procedure determines whether the
default dialog procedure processes the message or ignores it.
If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid
brush handle for painting the background of the dialog box. In general, if the hook
procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
for painting the background of the specified control.
Do not call the EndDialog function from the hook procedure. Instead, the hook
procedure can call the PostMessage function to post a WM_COMMAND message with
the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog box
and causes the dialog box function to return FALSE. If you need to know why the hook
procedure closed the dialog box, you must provide your own communication
mechanism between the hook procedure and your application.
You can subclass the standard controls of a common dialog box. However, the dialog
box procedure may also subclass the controls. Because of this, you should subclass
controls when your hook procedure processes the WM_INITDIALOG message. This
ensures that your subclass procedure receives the control-specific messages before the
subclass procedure set by the dialog box procedure.
Requirements
See also
Common Dialog Box Library
Conceptual
EndDialog
FINDREPLACE
FindText
PostMessage
Reference
ReplaceText
WM_CTLCOLORDLG
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Get help at Microsoft Q&A
LPOFNHOOKPROC callback function
(commdlg.h)
Article04/17/2021
[Starting with Windows Vista, the Open and Save As common dialog boxes have been
superseded by the Common Item Dialog. We recommended that you use the Common
Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
Receives notification messages sent from the dialog box. The function also receives
messages for any additional controls that you defined by specifying a child dialog
template. The OFNHookProc hook procedure is an application-defined or library-defined
callback function that is used with the Explorer-style Open and Save As dialog boxes.
Syntax
C++
LPOFNHOOKPROC Lpofnhookproc;
UINT_PTR Lpofnhookproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
A handle to the child dialog box of the Open or Save As dialog box. Use the GetParent
function to get the handle to the Open or Save As dialog box.
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter. If the unnamedParam2 parameter indicates the
WM_INITDIALOG message, unnamedParam4 is a pointer to an OPENFILENAME structure
containing the values specified when the dialog box was created.
Return value
If the hook procedure returns zero, the default dialog box procedure processes the
message.
If the hook procedure returns a nonzero value, the default dialog box procedure ignores
the message.
Remarks
If you do not specify the OFN_EXPLORER flag when you create an Open or Save As
dialog box, and you want a hook procedure, you must use an old-style
OFNHookProcOldStyle hook procedure. In this case, the dialog box will have the old-
style user interface.
If you provide a hook procedure for an Explorer-style common dialog box, the system
creates a dialog box that is a child of the default dialog box. The hook procedure acts as
the dialog procedure for the child dialog. This child dialog is based on the template you
specified in the OPENFILENAME structure, or it is a default child dialog if no template is
specified. The child dialog is created when the default dialog procedure is processing its
WM_INITDIALOG message. After the child dialog processes its own WM_INITDIALOG
message, the default dialog procedure moves the standard controls, if necessary, to
make room for any additional controls of the child dialog. The system then sends the
CDN_INITDONE notification message to the hook procedure.
The hook procedure does not receive messages intended for the standard controls of
the default dialog box. You can subclass the standard controls, but this is discouraged
because it may make your application incompatible with later versions. However, the
Explorer-style common dialog boxes provide a set of messages that the hook procedure
can use to monitor and control the dialog. These include a set of notification messages
sent from the dialog, as well as messages that you can send to retrieve information from
the dialog. For a complete list of these messages, see Explorer-Style Hook Procedures.
If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid
brush handle to painting the background of the dialog box. In general, if it processes
any WM_CTLCOLOR* message, it must return a valid brush handle to painting the
background of the specified control.
Do not call the EndDialog function from the hook procedure. Instead, the hook
procedure can call the PostMessage function to post a WM_COMMAND message with
the IDCANCEL value to the dialog box procedure. Posting IDCANCEL closes the dialog
box and causes the dialog box function to return FALSE. If you need to know why the
hook procedure closed the dialog box, you must provide your own communication
mechanism between the hook procedure and your application.
Requirements
See also
Common Dialog Box Library
Conceptual
GetOpenFileName
GetSaveFileName
OFNHookProcOldStyle
OPENFILENAME
Reference
Feedback
Was this page helpful? ツ Yes ト No
Receives messages that allow you to customize drawing of the sample page in the Page
Setup dialog box. The PagePaintHook hook procedure is an application-defined or
library-defined callback function used with the PageSetupDlg function.
Syntax
C++
LPPAGEPAINTHOOK Lppagepainthook;
UINT_PTR Lppagepainthook(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
Return value
If the hook procedure returns TRUE for any of the first three messages of a drawing
sequence (WM_PSD_PAGESETUPDLG, WM_PSD_FULLPAGERECT, or
WM_PSD_MINMARGINRECT), the dialog box sends no more messages and does not
draw in the sample page until the next time the system needs to redraw the sample
page. If the hook procedure returns FALSE for all three messages, the dialog box sends
the remaining messages of the drawing sequence.
If the hook procedure returns TRUE for any of the remaining messages in a drawing
sequence, the dialog box does not draw the corresponding portion of the sample page.
If the hook procedure returns FALSE for any of these messages, the dialog box draws
that portion of the sample page.
Remarks
The Page Setup dialog box includes an image of a sample page that shows how the
user's selections affect the appearance of the printed output. The image consists of a
rectangle that represents the selected paper or envelope type, with a dotted-line
rectangle representing the current margins, and partial (Greek text) characters to show
how text looks on the printed page. When you use the PageSetupDlg function to create
a Page Setup dialog box, you can provide a PagePaintHook hook procedure to
customize the appearance of the sample page.
To enable the hook procedure, use the PAGESETUPDLG structure that you passed to the
creation function. Specify the pointer to the hook procedure in the lpfnPagePaintHook
member and specify the PSD_ENABLEPAGEPAINTHOOK flag in the Flags member.
Whenever the dialog box is about to draw the contents of the sample page, the hook
procedure receives the following messages in the order in which they are listed.
Message Meaning
WM_PSD_PAGESETUPDLG The dialog box is about to draw the sample page. The hook
procedure can use this message to prepare to draw the contents of
the sample page.
WM_PSD_FULLPAGERECT The dialog box is about to draw the sample page. This message
specifies the bounding rectangle of the sample page.
WM_PSD_MINMARGINRECT The dialog box is about to draw the sample page. This message
specifies the margin rectangle.
WM_PSD_GREEKTEXTRECT The dialog box is about to draw the Greek text inside the margin
rectangle.
WM_PSD_YAFULLPAGERECT The dialog box is about to draw the return address portion of an
envelope sample page. This message is sent for envelopes and
other paper sizes.
Requirements
See also
Common Dialog Box Library
Conceptual
PAGESETUPDLG
PageSetupDlg
Reference
Feedback
Was this page helpful? ツ Yes ト No
Get help at Microsoft Q&A
LPPAGESETUPHOOK callback function
(commdlg.h)
Article04/02/2021
Receives messages or notifications intended for the default dialog box procedure of the
Page Setup dialog box. The PageSetupHook hook procedure is an application-defined or
library-defined callback function used with the PageSetupDlg function.
Syntax
C++
LPPAGESETUPHOOK Lppagesetuphook;
UINT_PTR Lppagesetuphook(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
A handle to the Page Setup dialog box for which the message is intended.
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
Return value
If the hook procedure returns zero, the default dialog box procedure processes the
message.
If the hook procedure returns a nonzero value, the default dialog box procedure ignores
the message.
Remarks
When you use the PageSetupDlg function to create a Page Setup dialog box, you can
provide a PageSetupHook hook procedure to process messages or notifications
intended for the dialog box procedure. To enable the hook procedure, use the
PAGESETUPDLG structure that you passed to the dialog creation function. Specify the
pointer to the hook procedure in the lpfnPageSetupHook member and specify the
PSD_ENABLEPAGESETUPHOOK flag in the Flags member.
The default dialog box procedure processes the WM_INITDIALOG message before
passing it to the hook procedure. For all other messages, the hook procedure receives
the message first. Then, the return value of the hook procedure determines whether the
default dialog procedure processes the message or ignores it.
If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid
brush handle to painting the background of the dialog box. In general, if the hook
procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
to painting the background of the specified control.
Do not call the EndDialog function from the hook procedure. Instead, the hook
procedure can call the PostMessage function to post a WM_COMMAND message with
the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog box
and causes the dialog box function to return FALSE. If you need to know why the hook
procedure closed the dialog box, you must provide your own communication
mechanism between the hook procedure and your application.
You can subclass the standard controls of a common dialog box. However, the dialog
box procedure may also subclass the controls. Because of this, you should subclass
controls when your hook procedure processes the WM_INITDIALOG message. This
ensures that your subclass procedure receives the control-specific messages before the
subclass procedure set by the dialog box procedure.
Requirements
See also
Common Dialog Box Library
Conceptual
EndDialog
PAGESETUPDLG
PageSetupDlg
PostMessage
Reference
WM_CTLCOLORDLG
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Receives messages or notifications intended for the default dialog box procedure of the
Print dialog box. This is an application-defined or library-defined callback function that
is used with the PrintDlg function.
Syntax
C++
LPPRINTHOOKPROC Lpprinthookproc;
UINT_PTR Lpprinthookproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
A handle to the Print dialog box for which the message is intended.
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
Return value
If the hook procedure returns zero, the default dialog box procedure processes the
message.
If the hook procedure returns a nonzero value, the default dialog box procedure ignores
the message.
Remarks
When you use the PrintDlg function to create a Print dialog box, you can provide a
PrintHookProc hook procedure to process messages or notifications intended for the
dialog box procedure. To enable the hook procedure, use the PRINTDLG structure that
you passed to the dialog creation function. Specify the address of the hook procedure in
the lpfnPrintHook member and specify the PD_ENABLEPRINTHOOK flag in the Flags
member.
The default dialog box procedure processes the WM_INITDIALOG message before
passing it to the hook procedure. For all other messages, the hook procedure receives
the message first. Then, the return value of the hook procedure determines whether the
default dialog procedure processes the message or ignores it.
If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid
brush handle to painting the background of the dialog box. In general, if the hook
procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
to painting the background of the specified control.
Do not call the EndDialog function from the hook procedure. Instead, the hook
procedure can call the PostMessage function to post a WM_COMMAND message with
the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog box
and causes the dialog box function to return FALSE. If you need to know why the hook
procedure closed the dialog box, you must provide your own communication
mechanism between the hook procedure and your application.
You can subclass the standard controls of a common dialog box. However, the dialog
box procedure may also subclass the controls. Because of this, you should subclass
controls when your hook procedure processes the WM_INITDIALOG message. This
ensures that your subclass procedure receives the control-specific messages before the
subclass procedure set by the dialog box procedure.
Requirements
See also
Common Dialog Box Library
Conceptual
EndDialog
PRINTDLG
PostMessage
PrintDlg
Reference
WM_CTLCOLORDLG
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
LPSETUPHOOKPROC Lpsetuphookproc;
UINT_PTR Lpsetuphookproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
A handle to the Print Setup dialog box for which the message is intended.
unnamedParam2
unnamedParam3
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
unnamedParam4
Additional information about the message. The exact meaning depends on the value of
the unnamedParam2 parameter.
Return value
If the hook procedure returns zero, the default dialog box procedure processes the
message.
If the hook procedure returns a nonzero value, the default dialog box procedure ignores
the message.
Remarks
The Print Setup dialog box has been superseded by the Page Setup dialog box, which
should be used by new applications. However, for compatibility, the PrintDlg function
continues to support display of the Print Setup dialog box. You can provide a
SetupHookProc hook procedure for the Print Setup dialog box to process messages or
notifications intended for the dialog box procedure.
To enable the hook procedure, use the PRINTDLG structure that you passed to the
dialog creation function. Specify the address of the hook procedure in the
lpfnSetupHook member and specify the PD_ENABLESETUPHOOK flag in the Flags
member.
The default dialog box procedure processes the WM_INITDIALOG message before
passing it to the hook procedure. For all other messages, the hook procedure receives
the message first. Then, the return value of the hook procedure determines whether the
default dialog procedure processes the message or ignores it.
If the hook procedure processes the WM_CTLCOLORDLG message, it must return a valid
brush handle to painting the background of the dialog box. In general, if the hook
procedure processes any WM_CTLCOLOR* message, it must return a valid brush handle
to painting the background of the specified control.
Do not call the EndDialog function from the hook procedure. Instead, the hook
procedure can call the PostMessage function to post a WM_COMMAND message with
the IDABORT value to the dialog box procedure. Posting IDABORT closes the dialog box
and causes the dialog box function to return FALSE. If you need to know why the hook
procedure closed the dialog box, you must provide your own communication
mechanism between the hook procedure and your application.
You can subclass the standard controls of a common dialog box. However, the dialog
box procedure may also subclass the controls. Because of this, you should subclass
controls when your hook procedure processes the WM_INITDIALOG message. This
ensures that your subclass procedure receives the control-specific messages before the
subclass procedure set by the dialog box procedure.
Requirements
See also
Common Dialog Box Library
Conceptual
EndDialog
PRINTDLG
PostMessage
PrintDlg
Reference
WM_CTLCOLORDLG
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
Members
hdr
Type: NMHDR
The code member of this structure can be one of the following notification messages
that identify the message being sent: CDN_FILEOK, CDN_FOLDERCHANGE, CDN_HELP,
CDN_INITDONE, CDN_SELCHANGE, CDN_SHAREVIOLATION, CDN_TYPECHANGE.
lpOFN
Type: LPOPENFILENAME
A pointer to the OPENFILENAME structure that was specified when the Open or Save As
dialog box was created. For some of the notification messages, this structure contains
additional information about the event that caused the notification.
pszFile
Type: LPTSTR
The file name for which a network sharing violation has occurred. This member is valid
only with the CDN_SHAREVIOLATION notification message.
Remarks
Not all of the Open and Save As notification messages use the OFNOTIFY structure. The
CDN_INCLUDEITEM notification message uses the OFNOTIFYEX structure.
7 Note
Requirements
See also
CDN_FILEOK
CDN_FOLDERCHANGE
CDN_HELP
CDN_INITDONE
CDN_SELCHANGE
CDN_SHAREVIOLATION
CDN_TYPECHANGE
Conceptual
OFNOTIFYEX
OPENFILENAME
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
Members
hdr
Type: NMHDR
The code member of this structure identifies the notification message being sent.
lpOFN
Type: LPOPENFILENAME
psf
Type: LPVOID
A pointer to the interface for the folder or shell name-space extension whose items are
being enumerated.
pidl
Type: LPVOID
A pointer to an item identifier list that identifies an item in the container identified by
the psf member. The item identifier is relative to the psf container.
Remarks
7 Note
Requirements
See also
CDN_INCLUDEITEM
Conceptual
OFNHookProc
OFNOTIFY
OPENFILENAME
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
Members
hdr
Type: NMHDR
The code member of this structure identifies the notification message being sent.
lpOFN
Type: LPOPENFILENAME
psf
Type: LPVOID
A pointer to the interface for the folder or shell name-space extension whose items are
being enumerated.
pidl
Type: LPVOID
A pointer to an item identifier list that identifies an item in the container identified by
the psf member. The item identifier is relative to the psf container.
Remarks
7 Note
Requirements
See also
CDN_INCLUDEITEM
Conceptual
OFNHookProc
OFNOTIFY
OPENFILENAME
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
Members
hdr
Type: NMHDR
The code member of this structure can be one of the following notification messages
that identify the message being sent: CDN_FILEOK, CDN_FOLDERCHANGE, CDN_HELP,
CDN_INITDONE, CDN_SELCHANGE, CDN_SHAREVIOLATION, CDN_TYPECHANGE.
lpOFN
Type: LPOPENFILENAME
A pointer to the OPENFILENAME structure that was specified when the Open or Save As
dialog box was created. For some of the notification messages, this structure contains
additional information about the event that caused the notification.
pszFile
Type: LPTSTR
The file name for which a network sharing violation has occurred. This member is valid
only with the CDN_SHAREVIOLATION notification message.
Remarks
Not all of the Open and Save As notification messages use the OFNOTIFY structure. The
CDN_INCLUDEITEM notification message uses the OFNOTIFYEX structure.
7 Note
Requirements
See also
CDN_FILEOK
CDN_FOLDERCHANGE
CDN_HELP
CDN_INITDONE
CDN_SELCHANGE
CDN_SHAREVIOLATION
CDN_TYPECHANGE
Conceptual
OFNOTIFYEX
OPENFILENAME
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
Members
lStructSize
hwndOwner
hInstance
lpstrFilter
lpstrCustomFilter
nMaxCustFilter
nFilterIndex
lpstrFile
nMaxFile
lpstrFileTitle
nMaxFileTitle
lpstrInitialDir
lpstrTitle
Flags
nFileOffset
nFileExtension
lpstrDefExt
lCustData
lpfnHook
lpTemplateName
Requirements
Syntax
C++
Members
lStructSize
hwndOwner
hInstance
lpstrFilter
lpstrCustomFilter
nMaxCustFilter
nFilterIndex
lpstrFile
nMaxFile
lpstrFileTitle
nMaxFileTitle
lpstrInitialDir
lpstrTitle
Flags
nFileOffset
nFileExtension
lpstrDefExt
lCustData
lpfnHook
lpTemplateName
Requirements
[Starting with Windows Vista, the Open and Save As common dialog boxes have been
superseded by the Common Item Dialog. We recommended that you use the Common
Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
Syntax
C++
Members
lStructSize
Type: DWORD
The length, in bytes, of the structure. Use sizeof (OPENFILENAME) for this parameter.
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hInstance
Type: HINSTANCE
lpstrFilter
Type: LPCTSTR
A buffer containing pairs of null-terminated filter strings. The last string in the buffer
must be terminated by two NULL characters.
The first string in each pair is a display string that describes the filter (for example, "Text
Files"), and the second string specifies the filter pattern (for example, ".TXT" ). To specify
multiple filter patterns for a single display string, use a semicolon to separate the patterns
(for example, " .TXT;.DOC;.BAK" ). A pattern string can be a combination of valid file
name characters and the asterisk (*) wildcard character. Do not include spaces in the
pattern string.
The system does not change the order of the filters. It displays them in the File Types
combo box in the order specified in lpstrFilter.
If lpstrFilter is NULL, the dialog box does not display any filters.
In the case of a shortcut, if no filter is set, GetOpenFileName and GetSaveFileName
retrieve the name of the .lnk file, not its target. This behavior is the same as setting the
OFN_NODEREFERENCELINKS flag in the Flags member. To retrieve a shortcut's target
without filtering, use the string "All Files\0*.*\0\0" .
lpstrCustomFilter
Type: LPTSTR
A static buffer that contains a pair of null-terminated filter strings for preserving the
filter pattern chosen by the user. The first string is your display string that describes the
custom filter, and the second string is the filter pattern selected by the user. The first
time your application creates the dialog box, you specify the first string, which can be
any nonempty string. When the user selects a file, the dialog box copies the current filter
pattern to the second string. The preserved filter pattern can be one of the patterns
specified in the lpstrFilter buffer, or it can be a filter pattern typed by the user. The
system uses the strings to initialize the user-defined file filter the next time the dialog
box is created. If the nFilterIndex member is zero, the dialog box uses the custom filter.
If this member is NULL, the dialog box does not preserve user-defined filter patterns.
If this member is not NULL, the value of the nMaxCustFilter member must specify the
size, in characters, of the lpstrCustomFilter buffer.
nMaxCustFilter
Type: DWORD
The size, in characters, of the buffer identified by lpstrCustomFilter. This buffer should
be at least 40 characters long. This member is ignored if lpstrCustomFilter is NULL or
points to a NULL string.
nFilterIndex
Type: DWORD
The index of the currently selected filter in the File Types control. The buffer pointed to
by lpstrFilter contains pairs of strings that define the filters. The first pair of strings has
an index value of 1, the second pair 2, and so on. An index of zero indicates the custom
filter specified by lpstrCustomFilter. You can specify an index on input to indicate the
initial filter description and filter pattern for the dialog box. When the user selects a file,
nFilterIndex returns the index of the currently displayed filter. If nFilterIndex is zero and
lpstrCustomFilter is NULL, the system uses the first filter in the lpstrFilter buffer. If all
three members are zero or NULL, the system does not use any filters and does not show
any files in the file list control of the dialog box.
lpstrFile
Type: LPTSTR
The file name used to initialize the File Name edit control. The first character of this
buffer must be NULL if initialization is not necessary. When the GetOpenFileName or
GetSaveFileName function returns successfully, this buffer contains the drive designator,
path, file name, and extension of the selected file.
If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer
contains the current directory followed by the file names of the selected files. For
Explorer-style dialog boxes, the directory and file name strings are NULL separated, with
an extra NULL character after the last file name. For old-style dialog boxes, the strings
are space separated and the function uses short file names for file names with spaces.
You can use the FindFirstFile function to convert between long and short file names. If
the user selects only one file, the lpstrFile string does not have a separator between the
path and file name.
If the buffer is too small, the function returns FALSE and the CommDlgExtendedError
function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the
lpstrFile buffer contain the required size, in bytes or characters.
nMaxFile
Type: DWORD
The size, in characters, of the buffer pointed to by lpstrFile. The buffer must be large
enough to store the path and file name string or strings, including the terminating NULL
character. The GetOpenFileName and GetSaveFileName functions return FALSE if the
buffer is too small to contain the file information. The buffer should be at least 256
characters long.
lpstrFileTitle
Type: LPTSTR
The file name and extension (without path information) of the selected file. This member
can be NULL.
nMaxFileTitle
Type: DWORD
The size, in characters, of the buffer pointed to by lpstrFileTitle. This member is ignored
if lpstrFileTitle is NULL.
lpstrInitialDir
Type: LPCTSTR
The initial directory. The algorithm for selecting the initial directory varies on different
platforms.
Windows 7:
1. If lpstrInitialDir has the same value as was passed the first time the application
used an Open or Save As dialog box, the path most recently selected by the user is
used as the initial directory.
2. Otherwise, if lpstrFile contains a path, that path is the initial directory.
3. Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.
4. If lpstrInitialDir is NULL and the current directory contains any files of the specified
filter types, the initial directory is the current directory.
5. Otherwise, the initial directory is the personal files directory of the current user.
6. Otherwise, the initial directory is the Desktop folder.
Windows 2000/XP/Vista:
lpstrTitle
Type: LPCTSTR
A string to be placed in the title bar of the dialog box. If this member is NULL, the
system uses the default title (that is, Save As or Open).
Flags
Type: DWORD
A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it
sets these flags to indicate the user's input. This member can be a combination of the
following flags.
Value Meaning
OFN_ALLOWMULTISELECT The File Name list box allows multiple selections. If you
0x00000200 also set the OFN_EXPLORER flag, the dialog box uses the
Explorer-style user interface; otherwise, it uses the old-
style user interface.
If the user selects more than one file, the lpstrFile buffer
returns the path to the current directory followed by the
file names of the selected files. The nFileOffset member is
the offset, in bytes or characters, to the first file name,
and the nFileExtension member is not used. For Explorer-
style dialog boxes, the directory and file name strings are
NULL separated, with an extra NULL character after the
last file name. This format enables the Explorer-style
dialog boxes to return long file names that include
spaces. For old-style dialog boxes, the directory and file
name strings are separated by spaces and the function
uses short file names for file names with spaces. You can
use the FindFirstFile function to convert between long
and short file names.
OFN_CREATEPROMPT If the user specifies a file that does not exist, this flag
0x00002000 causes the dialog box to prompt the user for permission
to create the file. If the user chooses to create the file, the
dialog box closes and the function returns the specified
name; otherwise, the dialog box remains open. If you use
this flag with the OFN_ALLOWMULTISELECT flag, the
dialog box allows the user to specify only one
nonexistent file.
OFN_EXTENSIONDIFFERENT The user typed a file name extension that differs from the
0x00000400 extension specified by lpstrDefExt. The function does not
use this flag if lpstrDefExt is NULL.
OFN_FILEMUSTEXIST The user can type only names of existing files in the File
0x00001000 Name entry field. If this flag is specified and the user
enters an invalid name, the dialog box procedure displays
a warning in a message box. If this flag is specified, the
OFN_PATHMUSTEXIST flag is also used. This flag can be
used in an Open dialog box. It cannot be used with a
Save As dialog box.
OFN_LONGNAMES For old-style dialog boxes, this flag causes the dialog box
0x00200000 to use long file names. If this flag is not specified, or if the
OFN_ALLOWMULTISELECT flag is also set, old-style
dialog boxes use short file names (8.3 format) for file
names with spaces. Explorer-style dialog boxes ignore
this flag and always display long file names.
OFN_NODEREFERENCELINKS Directs the dialog box to return the path and file name of
0x00100000 the selected shortcut (.LNK) file. If this value is not
specified, the dialog box returns the path and file name
of the file referenced by the shortcut.
OFN_NOLONGNAMES For old-style dialog boxes, this flag causes the dialog box
0x00040000 to use short file names (8.3 format). Explorer-style dialog
boxes ignore this flag and always display long file names.
OFN_NOREADONLYRETURN The returned file does not have the Read Only check box
0x00008000 selected and is not in a write-protected directory.
OFN_NOTESTFILECREATE The file is not created before the dialog box is closed.
0x00010000 This flag should be specified if the application saves the
file on a create-nonmodify network share. When an
application specifies this flag, the library does not check
for write protection, a full disk, an open drive door, or
network protection. Applications using this flag must
perform file operations carefully, because a file cannot be
reopened once it is closed.
OFN_PATHMUSTEXIST The user can type only valid paths and file names. If this
0x00000800 flag is used and the user types an invalid path and file
name in the File Name entry field, the dialog box
function displays a warning in a message box.
OFN_SHOWHELP Causes the dialog box to display the Help button. The
0x00000010 hwndOwner member must specify the window to receive
the HELPMSGSTRING registered messages that the dialog
box sends when the user clicks the Help button. An
Explorer-style dialog box sends a CDN_HELP notification
message to your hook procedure when the user clicks the
Help button.
nFileOffset
Type: WORD
The zero-based offset, in characters, from the beginning of the path to the file name in
the string pointed to by lpstrFile. For the ANSI version, this is the number of bytes; for
the Unicode version, this is the number of characters. For example, if lpstrFile points to
the following string, "c:\dir1\dir2\file.ext", this member contains the value 13 to indicate
the offset of the "file.ext" string. If the user selects more than one file, nFileOffset is the
offset to the first file name.
nFileExtension
Type: WORD
The zero-based offset, in characters, from the beginning of the path to the file name
extension in the string pointed to by lpstrFile. For the ANSI version, this is the number
of bytes; for the Unicode version, this is the number of characters. Usually the file name
extension is the substring which follows the last occurrence of the dot (".") character. For
example, txt is the extension of the filename readme.txt, html the extension of
readme.txt.html. Therefore, if lpstrFile points to the string "c:\dir1\dir2\readme.txt", this
member contains the value 20. If lpstrFile points to the string
"c:\dir1\dir2\readme.txt.html", this member contains the value 24. If lpstrFile points to
the string "c:\dir1\dir2\readme.txt.html.", this member contains the value 29. If lpstrFile
points to a string that does not contain any "." character such as "c:\dir1\dir2\readme",
this member contains zero.
lpstrDefExt
Type: LPCTSTR
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnHook member. When the system sends the WM_INITDIALOG message to the hook
procedure, the message's lParam parameter is a pointer to the OPENFILENAME
structure specified when the dialog box was created. The hook procedure can use this
pointer to get the lCustData value.
lpfnHook
Type: LPOFNHOOKPROC
A pointer to a hook procedure. This member is ignored unless the Flags member
includes the OFN_ENABLEHOOK flag.
If the OFN_EXPLORER flag is not set in the Flags member, lpfnHook is a pointer to an
OFNHookProcOldStyle hook procedure that receives messages intended for the dialog
box. The hook procedure returns FALSE to pass a message to the default dialog box
procedure or TRUE to discard the message.
lpTemplateName
Type: LPCTSTR
The name of the dialog template resource in the module identified by the hInstance
member. For numbered dialog box resources, this can be a value returned by the
MAKEINTRESOURCE macro. This member is ignored unless the OFN_ENABLETEMPLATE
flag is set in the Flags member. If the OFN_EXPLORER flag is set, the system uses the
specified template to create a dialog box that is a child of the default Explorer-style
dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create
an old-style dialog box that replaces the default dialog box.
lpEditInfo
This member is conditionally compiled (using #ifdef _MAC ) so that it is applicable only
to Motorola 68K Macintosh computers, and not to Windows client operating systems.
lpstrPrompt
This member is conditionally compiled (using #ifdef _MAC ) so that it is applicable only
to Motorola 68K Macintosh computers, and not to Windows client operating systems.
pvReserved
Type: void*
dwReserved
Type: DWORD
FlagsEx
Type: DWORD
A set of bit flags you can use to initialize the dialog box. Currently, this member can be
zero or the following flag.
Value Meaning
OFN_EX_NOPLACESBAR If this flag is set, the places bar is not displayed. If this
0x00000001 flag is not set, Explorer-style dialog boxes include a
places bar containing icons for commonly-used folders,
such as Favorites and Desktop.
Remarks
For compatibility reasons, the Places Bar is hidden if Flags is set to OFN_ENABLEHOOK
and lStructSize is OPENFILENAME_SIZE_VERSION_400.
7 Note
Requirements
See also
Common Dialog Box Library
Conceptual
GetOpenFileName
GetSaveFileName
Other Resources
Reference
SHGetSpecialFolderLocation
Feedback
Was this page helpful? ツ Yes ト No
[Starting with Windows Vista, the Open and Save As common dialog boxes have been
superseded by the Common Item Dialog. We recommended that you use the Common
Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.]
Syntax
C++
Type: DWORD
The length, in bytes, of the structure. Use sizeof (OPENFILENAME) for this parameter.
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hInstance
Type: HINSTANCE
lpstrFilter
Type: LPCTSTR
A buffer containing pairs of null-terminated filter strings. The last string in the buffer
must be terminated by two NULL characters.
The first string in each pair is a display string that describes the filter (for example, "Text
Files"), and the second string specifies the filter pattern (for example, ".TXT"). To specify
multiple filter patterns for a single display string, use a semicolon to separate the patterns
(for example, ".TXT;.DOC;.BAK"). A pattern string can be a combination of valid file name
characters and the asterisk (*) wildcard character. Do not include spaces in the pattern
string.
The system does not change the order of the filters. It displays them in the File Types
combo box in the order specified in lpstrFilter.
If lpstrFilter is NULL, the dialog box does not display any filters.
lpstrCustomFilter
Type: LPTSTR
A static buffer that contains a pair of null-terminated filter strings for preserving the
filter pattern chosen by the user. The first string is your display string that describes the
custom filter, and the second string is the filter pattern selected by the user. The first
time your application creates the dialog box, you specify the first string, which can be
any nonempty string. When the user selects a file, the dialog box copies the current filter
pattern to the second string. The preserved filter pattern can be one of the patterns
specified in the lpstrFilter buffer, or it can be a filter pattern typed by the user. The
system uses the strings to initialize the user-defined file filter the next time the dialog
box is created. If the nFilterIndex member is zero, the dialog box uses the custom filter.
If this member is NULL, the dialog box does not preserve user-defined filter patterns.
If this member is not NULL, the value of the nMaxCustFilter member must specify the
size, in characters, of the lpstrCustomFilter buffer.
nMaxCustFilter
Type: DWORD
The size, in characters, of the buffer identified by lpstrCustomFilter. This buffer should
be at least 40 characters long. This member is ignored if lpstrCustomFilter is NULL or
points to a NULL string.
nFilterIndex
Type: DWORD
The index of the currently selected filter in the File Types control. The buffer pointed to
by lpstrFilter contains pairs of strings that define the filters. The first pair of strings has
an index value of 1, the second pair 2, and so on. An index of zero indicates the custom
filter specified by lpstrCustomFilter. You can specify an index on input to indicate the
initial filter description and filter pattern for the dialog box. When the user selects a file,
nFilterIndex returns the index of the currently displayed filter. If nFilterIndex is zero and
lpstrCustomFilter is NULL, the system uses the first filter in the lpstrFilter buffer. If all
three members are zero or NULL, the system does not use any filters and does not show
any files in the file list control of the dialog box.
lpstrFile
Type: LPTSTR
The file name used to initialize the File Name edit control. The first character of this
buffer must be NULL if initialization is not necessary. When the GetOpenFileName or
GetSaveFileName function returns successfully, this buffer contains the drive designator,
path, file name, and extension of the selected file.
If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer
contains the current directory followed by the file names of the selected files. For
Explorer-style dialog boxes, the directory and file name strings are NULL separated, with
an extra NULL character after the last file name. For old-style dialog boxes, the strings
are space separated and the function uses short file names for file names with spaces.
You can use the FindFirstFile function to convert between long and short file names. If
the user selects only one file, the lpstrFile string does not have a separator between the
path and file name.
If the buffer is too small, the function returns FALSE and the CommDlgExtendedError
function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the
lpstrFile buffer contain the required size, in bytes or characters.
nMaxFile
Type: DWORD
The size, in characters, of the buffer pointed to by lpstrFile. The buffer must be large
enough to store the path and file name string or strings, including the terminating NULL
character. The GetOpenFileName and GetSaveFileName functions return FALSE if the
buffer is too small to contain the file information. The buffer should be at least 256
characters long.
lpstrFileTitle
Type: LPTSTR
The file name and extension (without path information) of the selected file. This member
can be NULL.
nMaxFileTitle
Type: DWORD
The size, in characters, of the buffer pointed to by lpstrFileTitle. This member is ignored
if lpstrFileTitle is NULL.
lpstrInitialDir
Type: LPCTSTR
The initial directory. The algorithm for selecting the initial directory varies on different
platforms.
Windows 7:
1. If lpstrInitialDir has the same value as was passed the first time the application
used an Open or Save As dialog box, the path most recently selected by the user is
used as the initial directory.
2. Otherwise, if lpstrFile contains a path, that path is the initial directory.
3. Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.
4. If lpstrInitialDir is NULL and the current directory contains any files of the specified
filter types, the initial directory is the current directory.
5. Otherwise, the initial directory is the personal files directory of the current user.
6. Otherwise, the initial directory is the Desktop folder.
Windows 2000/XP/Vista:
lpstrTitle
Type: LPCTSTR
A string to be placed in the title bar of the dialog box. If this member is NULL, the
system uses the default title (that is, Save As or Open).
Flags
Type: DWORD
A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it
sets these flags to indicate the user's input. This member can be a combination of the
following flags.
Value Meaning
OFN_ALLOWMULTISELECT The File Name list box allows multiple selections. If you
0x00000200 also set the OFN_EXPLORER flag, the dialog box uses the
Explorer-style user interface; otherwise, it uses the old-
style user interface.
If the user selects more than one file, the lpstrFile buffer
returns the path to the current directory followed by the
file names of the selected files. The nFileOffset member is
the offset, in bytes or characters, to the first file name,
and the nFileExtension member is not used. For Explorer-
style dialog boxes, the directory and file name strings are
NULL separated, with an extra NULL character after the
last file name. This format enables the Explorer-style
dialog boxes to return long file names that include
spaces. For old-style dialog boxes, the directory and file
name strings are separated by spaces and the function
uses short file names for file names with spaces. You can
use the FindFirstFile function to convert between long
and short file names.
OFN_CREATEPROMPT If the user specifies a file that does not exist, this flag
0x00002000 causes the dialog box to prompt the user for permission
to create the file. If the user chooses to create the file, the
dialog box closes and the function returns the specified
name; otherwise, the dialog box remains open. If you use
this flag with the OFN_ALLOWMULTISELECT flag, the
dialog box allows the user to specify only one
nonexistent file.
OFN_EXTENSIONDIFFERENT The user typed a file name extension that differs from the
0x00000400 extension specified by lpstrDefExt. The function does not
use this flag if lpstrDefExt is NULL.
OFN_FILEMUSTEXIST The user can type only names of existing files in the File
0x00001000 Name entry field. If this flag is specified and the user
enters an invalid name, the dialog box procedure displays
a warning in a message box. If this flag is specified, the
OFN_PATHMUSTEXIST flag is also used. This flag can be
used in an Open dialog box. It cannot be used with a
Save As dialog box.
OFN_LONGNAMES For old-style dialog boxes, this flag causes the dialog box
0x00200000 to use long file names. If this flag is not specified, or if the
OFN_ALLOWMULTISELECT flag is also set, old-style
dialog boxes use short file names (8.3 format) for file
names with spaces. Explorer-style dialog boxes ignore
this flag and always display long file names.
OFN_NODEREFERENCELINKS Directs the dialog box to return the path and file name of
0x00100000 the selected shortcut (.LNK) file. If this value is not
specified, the dialog box returns the path and file name
of the file referenced by the shortcut.
OFN_NOLONGNAMES For old-style dialog boxes, this flag causes the dialog box
0x00040000 to use short file names (8.3 format). Explorer-style dialog
boxes ignore this flag and always display long file names.
OFN_NOREADONLYRETURN The returned file does not have the Read Only check box
0x00008000 selected and is not in a write-protected directory.
OFN_NOTESTFILECREATE The file is not created before the dialog box is closed.
0x00010000 This flag should be specified if the application saves the
file on a create-nonmodify network share. When an
application specifies this flag, the library does not check
for write protection, a full disk, an open drive door, or
network protection. Applications using this flag must
perform file operations carefully, because a file cannot be
reopened once it is closed.
OFN_PATHMUSTEXIST The user can type only valid paths and file names. If this
0x00000800 flag is used and the user types an invalid path and file
name in the File Name entry field, the dialog box
function displays a warning in a message box.
OFN_SHOWHELP Causes the dialog box to display the Help button. The
0x00000010 hwndOwner member must specify the window to receive
the HELPMSGSTRING registered messages that the dialog
box sends when the user clicks the Help button. An
Explorer-style dialog box sends a CDN_HELP notification
message to your hook procedure when the user clicks the
Help button.
nFileOffset
Type: WORD
The zero-based offset, in characters, from the beginning of the path to the file name in
the string pointed to by lpstrFile. For the ANSI version, this is the number of bytes; for
the Unicode version, this is the number of characters. For example, if lpstrFile points to
the following string, "c:\dir1\dir2\file.ext", this member contains the value 13 to indicate
the offset of the "file.ext" string. If the user selects more than one file, nFileOffset is the
offset to the first file name.
nFileExtension
Type: WORD
The zero-based offset, in characters, from the beginning of the path to the file name
extension in the string pointed to by lpstrFile. For the ANSI version, this is the number
of bytes; for the Unicode version, this is the number of characters. Usually the file name
extension is the substring which follows the last occurrence of the dot (".") character. For
example, txt is the extension of the filename readme.txt, html the extension of
readme.txt.html. Therefore, if lpstrFile points to the string "c:\dir1\dir2\readme.txt", this
member contains the value 20. If lpstrFile points to the string
"c:\dir1\dir2\readme.txt.html", this member contains the value 24. If lpstrFile points to
the string "c:\dir1\dir2\readme.txt.html.", this member contains the value 29. If lpstrFile
points to a string that does not contain any "." character such as "c:\dir1\dir2\readme",
this member contains zero.
lpstrDefExt
Type: LPCTSTR
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnHook member. When the system sends the WM_INITDIALOG message to the hook
procedure, the message's lParam parameter is a pointer to the OPENFILENAME
structure specified when the dialog box was created. The hook procedure can use this
pointer to get the lCustData value.
lpfnHook
Type: LPOFNHOOKPROC
A pointer to a hook procedure. This member is ignored unless the Flags member
includes the OFN_ENABLEHOOK flag.
If the OFN_EXPLORER flag is not set in the Flags member, lpfnHook is a pointer to an
OFNHookProcOldStyle hook procedure that receives messages intended for the dialog
box. The hook procedure returns FALSE to pass a message to the default dialog box
procedure or TRUE to discard the message.
lpTemplateName
Type: LPCTSTR
The name of the dialog template resource in the module identified by the hInstance
member. For numbered dialog box resources, this can be a value returned by the
MAKEINTRESOURCE macro. This member is ignored unless the OFN_ENABLETEMPLATE
flag is set in the Flags member. If the OFN_EXPLORER flag is set, the system uses the
specified template to create a dialog box that is a child of the default Explorer-style
dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create
an old-style dialog box that replaces the default dialog box.
lpEditInfo
This member is conditionally compiled (using #ifdef _MAC ) so that it is applicable only
to Motorola 68K Macintosh computers, and not to Windows client operating systems.
lpstrPrompt
This member is conditionally compiled (using #ifdef _MAC ) so that it is applicable only
to Motorola 68K Macintosh computers, and not to Windows client operating systems.
pvReserved
Type: void*
dwReserved
Type: DWORD
FlagsEx
Type: DWORD
A set of bit flags you can use to initialize the dialog box. Currently, this member can be
zero or the following flag.
Value Meaning
OFN_EX_NOPLACESBAR If this flag is set, the places bar is not displayed. If this
0x00000001 flag is not set, Explorer-style dialog boxes include a
places bar containing icons for commonly-used folders,
such as Favorites and Desktop.
Remarks
For compatibility reasons, the Places Bar is hidden if Flags is set to OFN_ENABLEHOOK
and lStructSize is OPENFILENAME_SIZE_VERSION_400.
7 Note
Requirements
See also
Common Dialog Box Library
Conceptual
GetOpenFileName
GetSaveFileName
Other Resources
Reference
SHGetSpecialFolderLocation
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call PageSetupDlg instead of calling this method directly.
Syntax
C++
PageSetupDlgA Pagesetupdlga;
BOOL Pagesetupdlga(
LPPAGESETUPDLGA unnamedParam1
)
{...}
Parameters
unnamedParam1
Requirements
Header commdlg.h
See also
PageSetupDlg
Feedback
Was this page helpful? ツ Yes ト No
Contains information the PageSetupDlg function uses to initialize the Page Setup dialog
box. After the user closes the dialog box, the system returns information about the user-
defined page parameters in this structure.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hDevMode
Type: HGLOBAL
hDevNames
Type: HGLOBAL
A handle to a global memory object that contains a DEVNAMES structure. This structure
contains three strings that specify the driver name, the printer name, and the output
port name. On input, if a handle is specified, the strings in the corresponding
DEVNAMES structure are used to initialize controls in the dialog box. On output, the
dialog box sets hDevNames to a global memory handle to a DEVNAMES structure that
contains strings specifying the user's selections. If the user's selections are not available,
the dialog box sets hDevNames to NULL.
Flags
Type: DWORD
A set of bit flags that you can use to initialize the Page Setup dialog box. When the
dialog box returns, it sets these flags to indicate the user's input. This member can be
one or more of the following values.
Value Meaning
PSD_DEFAULTMINMARGINS Sets the minimum values that the user can specify
0x00000000 for the page margins to be the minimum margins
allowed by the printer. This is the default. This flag
is ignored if the PSD_MARGINS and
PSD_MINMARGINS flags are also specified.
PSD_DISABLEPRINTER Obsolete.
0x00000020 Windows XP/2000: Disables the Printer button,
preventing the user from invoking a dialog box
that contains additional printer setup information.
PSD_INWININIINTLMEASURE Reserved.
0x00000000
ptPaperSize
Type: POINT
rtMinMargin
Type: RECT
The minimum allowable widths for the left, top, right, and bottom margins. The system
ignores this member if the PSD_MINMARGINS flag is not set. These values must be less
than or equal to the values specified in the rtMargin member. The
PSD_INTHOUSANDTHSOFINCHES or PSD_INHUNDREDTHSOFMILLIMETERS flag
indicates the units of measurement.
rtMargin
Type: RECT
The widths of the left, top, right, and bottom margins. If you set the PSD_MARGINS flag,
rtMargin specifies the initial margin values. When PageSetupDlg returns, rtMargin
contains the margin widths selected by the user. The
PSD_INHUNDREDTHSOFMILLIMETERS or PSD_INTHOUSANDTHSOFINCHES flag
indicates the units of measurement.
hInstance
Type: HINSTANCE
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnPageSetupHook member. When the system sends the WM_INITDIALOG message to
the hook procedure, the message's lParam parameter is a pointer to the
PAGESETUPDLG structure specified when the dialog was created. The hook procedure
can use this pointer to get the lCustData value.
lpfnPageSetupHook
Type: LPPAGESETUPHOOK
A pointer to a PageSetupHook hook procedure that can process messages intended for
the dialog box. This member is ignored unless the PSD_ENABLEPAGESETUPHOOK flag
is set in the Flags member.
lpfnPagePaintHook
Type: LPPAGEPAINTHOOK
lpPageSetupTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template is substituted for the standard dialog box template. For
numbered dialog box resources, lpPageSetupTemplateName can be a value returned
by the MAKEINTRESOURCE macro. This member is ignored unless the
PSD_ENABLEPAGESETUPTEMPLATE flag is set in the Flags member.
hPageSetupTemplate
Type: HGLOBAL
Remarks
If the PSD_INHUNDREDTHSOFMILLIMETERS and PSD_INTHOUSANDTHSOFINCHES
flags are not specified, the system queries the LOCALE_IMEASURE value of the default
user locale to determine the unit of measure (either hundredths of millimeters or
thousandths of inches) for the margin widths and paper size.
If both hDevNames and hDevMode have valid handles and the printer name specified
by the wDeviceOffset member of the DEVNAMES structure is not the same as the name
specified by the dmDeviceName member of the DEVMODE structure, the system uses
the name specified by wDeviceOffset by default.
7 Note
Requirements
See also
Common Dialog Box Library
Conceptual
DEVMODE
DEVNAMES
MAKEINTRESOURCE
Other Resources
PagePaintHook
PageSetupDlg
PageSetupHook
Reference
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call PageSetupDlg instead of calling this method directly.
Syntax
C++
PageSetupDlgW Pagesetupdlgw;
BOOL Pagesetupdlgw(
LPPAGESETUPDLGW unnamedParam1
)
{...}
Parameters
unnamedParam1
Requirements
Header commdlg.h
See also
PageSetupDlg
Feedback
Was this page helpful? ツ Yes ト No
Contains information the PageSetupDlg function uses to initialize the Page Setup dialog
box. After the user closes the dialog box, the system returns information about the user-
defined page parameters in this structure.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hDevMode
Type: HGLOBAL
hDevNames
Type: HGLOBAL
A handle to a global memory object that contains a DEVNAMES structure. This structure
contains three strings that specify the driver name, the printer name, and the output
port name. On input, if a handle is specified, the strings in the corresponding
DEVNAMES structure are used to initialize controls in the dialog box. On output, the
dialog box sets hDevNames to a global memory handle to a DEVNAMES structure that
contains strings specifying the user's selections. If the user's selections are not available,
the dialog box sets hDevNames to NULL.
Flags
Type: DWORD
A set of bit flags that you can use to initialize the Page Setup dialog box. When the
dialog box returns, it sets these flags to indicate the user's input. This member can be
one or more of the following values.
Value Meaning
PSD_DEFAULTMINMARGINS Sets the minimum values that the user can specify
0x00000000 for the page margins to be the minimum margins
allowed by the printer. This is the default. This flag
is ignored if the PSD_MARGINS and
PSD_MINMARGINS flags are also specified.
PSD_DISABLEPRINTER Obsolete.
0x00000020 Windows XP/2000: Disables the Printer button,
preventing the user from invoking a dialog box
that contains additional printer setup information.
PSD_INWININIINTLMEASURE Reserved.
0x00000000
ptPaperSize
Type: POINT
rtMinMargin
Type: RECT
The minimum allowable widths for the left, top, right, and bottom margins. The system
ignores this member if the PSD_MINMARGINS flag is not set. These values must be less
than or equal to the values specified in the rtMargin member. The
PSD_INTHOUSANDTHSOFINCHES or PSD_INHUNDREDTHSOFMILLIMETERS flag
indicates the units of measurement.
rtMargin
Type: RECT
The widths of the left, top, right, and bottom margins. If you set the PSD_MARGINS flag,
rtMargin specifies the initial margin values. When PageSetupDlg returns, rtMargin
contains the margin widths selected by the user. The
PSD_INHUNDREDTHSOFMILLIMETERS or PSD_INTHOUSANDTHSOFINCHES flag
indicates the units of measurement.
hInstance
Type: HINSTANCE
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnPageSetupHook member. When the system sends the WM_INITDIALOG message to
the hook procedure, the message's lParam parameter is a pointer to the
PAGESETUPDLG structure specified when the dialog was created. The hook procedure
can use this pointer to get the lCustData value.
lpfnPageSetupHook
Type: LPPAGESETUPHOOK
A pointer to a PageSetupHook hook procedure that can process messages intended for
the dialog box. This member is ignored unless the PSD_ENABLEPAGESETUPHOOK flag
is set in the Flags member.
lpfnPagePaintHook
Type: LPPAGEPAINTHOOK
lpPageSetupTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template is substituted for the standard dialog box template. For
numbered dialog box resources, lpPageSetupTemplateName can be a value returned
by the MAKEINTRESOURCE macro. This member is ignored unless the
PSD_ENABLEPAGESETUPTEMPLATE flag is set in the Flags member.
hPageSetupTemplate
Type: HGLOBAL
Remarks
If the PSD_INHUNDREDTHSOFMILLIMETERS and PSD_INTHOUSANDTHSOFINCHES
flags are not specified, the system queries the LOCALE_IMEASURE value of the default
user locale to determine the unit of measure (either hundredths of millimeters or
thousandths of inches) for the margin widths and paper size.
If both hDevNames and hDevMode have valid handles and the printer name specified
by the wDeviceOffset member of the DEVNAMES structure is not the same as the name
specified by the dmDeviceName member of the DEVMODE structure, the system uses
the name specified by wDeviceOffset by default.
7 Note
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
See also
Common Dialog Box Library
Conceptual
DEVMODE
DEVNAMES
MAKEINTRESOURCE
Other Resources
PagePaintHook
PageSetupDlg
PageSetupHook
Reference
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call PrintDlg instead of calling this method directly.
Syntax
C++
PrintDlgA Printdlga;
BOOL Printdlga(
LPPRINTDLGA pPD
)
{...}
Parameters
pPD
Requirements
Header commdlg.h
See also
PrintDlg
Feedback
Was this page helpful? ツ Yes ト No
Contains information that the PrintDlg function uses to initialize the Print Dialog Box.
After the user closes the dialog box, the system uses this structure to return information
about the user's selections.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hDevMode
Type: HGLOBAL
If hDevMode is NULL on input, PrintDlg allocates memory for the DEVMODE structure,
initializes its members to indicate the user's input, and returns a handle that identifies it.
If the device driver for the specified printer does not support extended device modes,
hDevMode is NULL when PrintDlg returns.
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDevNames
Type: HGLOBAL
The hDevNames member can be NULL, in which case, PrintDlg allocates memory for the
DEVNAMES structure, initializes its members to indicate the user's input, and returns a
handle that identifies it.
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDC
Type: HDC
A handle to a device context or an information context, depending on whether the Flags
member specifies the PD_RETURNDC or PC_RETURNIC flag. If neither flag is specified,
the value of this member is undefined. If both flags are specified, PD_RETURNDC has
priority.
Flags
Type: DWORD
Initializes the Print dialog box. When the dialog box returns, it sets these flags to
indicate the user's input. This member can be one or more of the following values.
Value Meaning
PD_ALLPAGES The default flag that indicates that the All radio button
0x00000000 is initially selected. This flag is used as a placeholder to
indicate that the PD_PAGENUMS and PD_SELECTION
flags are not specified.
See PD_NOPAGENUMS.
PD_PRINTTOFILE If this flag is set, the Print to File check box is selected.
0x00000020 If this flag is set when the PrintDlg function returns, the
offset indicated by the wOutputOffset member of the
DEVNAMES structure contains the string "FILE:". When
you call the StartDoc function to start the printing
operation, specify this "FILE:" string in the lpszOutput
member of the DOCINFO structure. Specifying this
string causes the print subsystem to query the user for
the name of the output file.
PD_RETURNDEFAULT If this flag is set, the PrintDlg function does not display
0x00000400 the dialog box. Instead, it sets the hDevNames and
hDevMode members to handles to DEVMODE and
DEVNAMES structures that are initialized for the
system default printer. Both hDevNames and
hDevMode must be NULL, or PrintDlg returns an
error.
PD_SHOWHELP Causes the dialog box to display the Help button. The
0x00000800 hwndOwner member must specify the window to
receive the HELPMSGSTRING registered messages that
the dialog box sends when the user clicks the Help
button.
To ensure that PrintDlg or PrintDlgEx returns the correct values in the dmCopies and
dmCollate members of the DEVMODE structure, set PD_RETURNDC = TRUE and
PD_USEDEVMODECOPIESANDCOLLATE = TRUE. In so doing, the nCopies member of
the PRINTDLG structure is always 1 and PD_COLLATE is always FALSE.
To ensure that PrintDlg or PrintDlgEx returns the correct values in nCopies and
PD_COLLATE, set PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE
= FALSE. In so doing, dmCopies is always 1 and dmCollate is always FALSE.
On Windows Vista and Windows 7, when you call PrintDlg or PrintDlgEx with
PD_RETURNDC set to TRUE and PD_USEDEVMODECOPIESANDCOLLATE set to FALSE,
the PrintDlg or PrintDlgEx function sets the number of copies in the nCopies member
of the PRINTDLG structure, and it sets the number of copies in the structure represented
by the hDC member of the PRINTDLG structure.
When making calls to GDI, you must ignore the value of nCopies, consider the value as
1, and use the returned hDC to avoid printing duplicate copies.
nFromPage
Type: WORD
When PrintDlg returns, nFromPage is the starting page specified by the user. If the
Pages radio button is selected when the user clicks the Okay button, PrintDlg sets the
PD_PAGENUMS flag and does not return until the user enters a starting page value that
is within the minimum to maximum page range.
If the input value for either nFromPage or nToPage is outside the minimum/maximum
range, PrintDlg returns an error only if the PD_PAGENUMS flag is specified; otherwise, it
displays the dialog box but changes the out-of-range value to the minimum or
maximum value.
nToPage
Type: WORD
The initial value for the ending page edit control. When PrintDlg returns, nToPage is the
ending page specified by the user. If the Pages radio button is selected when the use
clicks the Okay button, PrintDlg sets the PD_PAGENUMS flag and does not return until
the user enters an ending page value that is within the minimum to maximum page
range.
nMinPage
Type: WORD
The minimum value for the page range specified in the From and To page edit controls.
If nMinPage equals nMaxPage, the Pages radio button and the starting and ending
page edit controls are disabled.
nMaxPage
Type: WORD
The maximum value for the page range specified in the From and To page edit controls.
nCopies
Type: WORD
The initial number of copies for the Copies edit control if hDevMode is NULL; otherwise,
the dmCopies member of the DEVMODE structure contains the initial value. When
PrintDlg returns, nCopies contains the actual number of copies to print. This value
depends on whether the application or the printer driver is responsible for printing
multiple copies. If the PD_USEDEVMODECOPIESANDCOLLATE flag is set in the Flags
member, nCopies is always 1 on return, and the printer driver is responsible for printing
multiple copies. If the flag is not set, the application is responsible for printing the
number of copies specified by nCopies. For more information, see the description of the
PD_USEDEVMODECOPIESANDCOLLATE flag.
hInstance
Type: HINSTANCE
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnPrintHook or lpfnSetupHook member. When the system sends the
WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a
pointer to the PRINTDLG structure specified when the dialog was created. The hook
procedure can use this pointer to get the lCustData value.
lpfnPrintHook
Type: LPPRINTHOOKPROC
A pointer to a PrintHookProc hook procedure that can process messages intended for
the Print dialog box. This member is ignored unless the PD_ENABLEPRINTHOOK flag is
set in the Flags member.
lpfnSetupHook
Type: LPSETUPHOOKPROC
A pointer to a SetupHookProc hook procedure that can process messages intended for
the Print Setup dialog box. This member is ignored unless the PD_ENABLESETUPHOOK
flag is set in the Flags member.
lpPrintTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template replaces the default Print dialog box template. This member is
ignored unless the PD_ENABLEPRINTTEMPLATE flag is set in the Flags member.
lpSetupTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template replaces the default Print Setup dialog box template. This
member is ignored unless the PD_ENABLESETUPTEMPLATE flag is set in the Flags
member.
hPrintTemplate
Type: HGLOBAL
hSetupTemplate
Type: HGLOBAL
Remarks
If both hDevMode and hDevNames are NULL, PrintDlg initializes the dialog box using
the current default printer. To initialize the dialog box for a different printer, use the
wDeviceOffset member of the DEVNAMES structure to specify the name of the printer.
Note that the dmDeviceName member of the DEVMODE structure also specifies a
printer name. However, dmDeviceName is limited to 32 characters, and the
wDeviceOffset name is not. If the wDeviceOffset and dmDeviceName names are not
the same, PrintDlg initializes the dialog box using the printer specified by
wDeviceOffset.
If the PD_RETURNDEFAULT flag is set and both hDevMode and hDevNames are NULL,
PrintDlg uses the hDevNames and hDevMode members to return information about
the current default printer without displaying the dialog box.
7 Note
Requirements
See also
Common Dialog Box Library
Conceptual
DEVMODE
DEVNAMES
PrintDlg
Reference
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call PrintDlgEx instead of calling this method directly.
Syntax
C++
PrintDlgExA Printdlgexa;
HRESULT Printdlgexa(
LPPRINTDLGEXA pPD
)
{...}
Parameters
pPD
Requirements
Header commdlg.h
See also
PrintDlgEx
Feedback
Was this page helpful? ツ Yes ト No
Contains information that the PrintDlgEx function uses to initialize the Print property
sheet. After the user closes the property sheet, the system uses this structure to return
information about the user's selections.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the property sheet. This member must be a valid
window handle; it cannot be NULL.
hDevMode
Type: HGLOBAL
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDevNames
Type: HGLOBAL
The hDevNames member can be NULL, in which case, PrintDlgEx allocates memory for
the DEVNAMES structure, initializes its members to indicate the user's input, and returns
a handle that identifies it.
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDC
Type: HDC
Flags
Type: DWORD
A set of bit flags that you can use to initialize the Print property sheet. When the
PrintDlgEx function returns, it sets these flags to indicate the user's input. This member
can be one or more of the following values.
To ensure that PrintDlg or PrintDlgEx returns the correct values in the dmCopies and
dmCollate members of the DEVMODE structure, set PD_RETURNDC = TRUE and
PD_USEDEVMODECOPIESANDCOLLATE = TRUE. In so doing, the nCopies member of
the PRINTDLG structure is always 1 and PD_COLLATE is always FALSE.
To ensure that PrintDlg or PrintDlgEx returns the correct values in nCopies and
PD_COLLATE, set PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE
= FALSE. In so doing, dmCopies is always 1 and dmCollate is always FALSE.
Starting with Windows Vista, when you call PrintDlg or PrintDlgEx with PD_RETURNDC
set to TRUE and PD_USEDEVMODECOPIESANDCOLLATE set to FALSE, the PrintDlg or
PrintDlgEx function sets the number of copies in the nCopies member of the PRINTDLG
structure, and it sets the number of copies in the structure represented by the hDC
member of the PRINTDLG structure.
When making calls to GDI, you must ignore the value of nCopies, consider the value as
1, and use the returned hDC to avoid printing duplicate copies.
Value Meaning
PD_ALLPAGES The default flag that indicates that the All radio button
0x00000000 is initially selected. This flag is used as a placeholder to
indicate that the PD_PAGENUMS, PD_SELECTION, and
PD_CURRENTPAGE flags are not specified.
See PD_NOPAGENUMS.
PD_CURRENTPAGE If this flag is set, the Current Page radio button is
0x00400000 selected. If none of the PD_PAGENUMS,
PD_SELECTION, or PD_CURRENTPAGE flags is set, the
All radio button is selected.
PD_PRINTTOFILE If this flag is set, the Print to File check box is selected.
0x00000020 If this flag is set when PrintDlgEx returns, the offset
indicated by the wOutputOffset member of the
DEVNAMES structure contains the string "FILE:". When
you call the StartDoc function to start the printing
operation, specify this "FILE:" string in the lpszOutput
member of the DOCINFO structure. Specifying this
string causes the print subsystem to query the user for
the name of the output file.
Flags2
Type: DWORD
ExclusionFlags
Type: DWORD
A set of bit flags that can exclude items from the printer driver property pages in the
Print property sheet. This value is used only if the PD_EXCLUSIONFLAGS flag is set in
the Flags member. Exclusion flags should be used only if the item to be excluded will be
included on either the General page or on an application-defined page in the Print
property sheet. This member can specify the following flag.
PD_EXCL_COPIESANDCOLLATE
Excludes the Copies and Collate controls from the printer driver property pages in a
Print property sheet. This flag should always be set when the application uses the
default Copies and Collate controls provided by the lower portion of the General page
of the Print property sheet.
nPageRanges
Type: DWORD
On input, set this member to the initial number of page ranges specified in the
lpPageRanges array. When the PrintDlgEx function returns, nPageRanges indicates the
number of user-specified page ranges stored in the lpPageRanges array. If the
PD_NOPAGENUMS flag is specified, this value is not valid.
nMaxPageRanges
Type: DWORD
The size, in array elements, of the lpPageRanges buffer. This value indicates the
maximum number of page ranges that can be stored in the array. If the
PD_NOPAGENUMS flag is specified, this value is not valid. If the PD_NOPAGENUMS flag
is not specified, this value must be greater than zero.
lpPageRanges
Type: LPPRINTPAGERANGE
nMinPage
Type: DWORD
The minimum value for the page ranges specified in the Pages edit control. If the
PD_NOPAGENUMS flag is specified, this value is not valid.
nMaxPage
Type: DWORD
The maximum value for the page ranges specified in the Pages edit control. If the
PD_NOPAGENUMS flag is specified, this value is not valid.
nCopies
Type: DWORD
Contains the initial number of copies for the Copies edit control if hDevMode is NULL;
otherwise, the dmCopies member of the DEVMODE structure contains the initial value.
When PrintDlgEx returns, nCopies contains the actual number of copies the application
must print. This value depends on whether the application or the printer driver is
responsible for printing multiple copies. If the PD_USEDEVMODECOPIESANDCOLLATE
flag is set in the Flags member, nCopies is always 1 on return, and the printer driver is
responsible for printing multiple copies. If the flag is not set, the application is
responsible for printing the number of copies specified by nCopies. For more
information, see the description of the PD_USEDEVMODECOPIESANDCOLLATE flag.
hInstance
Type: HINSTANCE
lpPrintTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template replaces the default dialog box template in the lower portion of
the General page. The default template contains controls similar to those of the Print
dialog box. This member is ignored unless the PD_ENABLEPRINTTEMPLATE flag is set in
the Flags member.
lpCallback
Type: LPUNKNOWN
A pointer to an application-defined callback object.
The object should contain the IPrintDialogCallback class to receive messages for the
child dialog box in the lower portion of the General page.
The callback object should also contain the IObjectWithSite class to receive a pointer to
the IPrintDialogServices interface. The PrintDlgEx function calls
IUnknown::QueryInterface on the callback object for both IID_IPrintDialogCallback and
IID_IObjectWithSite to determine which interfaces are supported.
If you do not want to retrieve any of the callback information, set lpCallback to NULL.
nPropertyPages
Type: DWORD
lphPropertyPages
Type: HPROPSHEETPAGE*
Contains an array of property page handles to add to the Print property sheet. The
additional property pages follow the General page. Use the CreatePropertySheetPage
function to create these additional pages. When the PrintDlgEx function returns, all the
HPROPSHEETPAGE handles in the lphPropertyPages array have been destroyed. If
nPropertyPages is zero, lphPropertyPages should be NULL.
nStartPage
Type: DWORD
The property page that is initially displayed. To display the General page, specify
START_PAGE_GENERAL. Otherwise, specify the zero-based index of a property page in
the array specified in the lphPropertyPages member. For consistency, it is
recommended that the property sheet always be started on the General page.
dwResultAction
Type: DWORD
On input, set this member to zero. If the PrintDlgEx function returns S_OK,
dwResultAction contains the outcome of the dialog. If PrintDlgEx returns an error, this
member should be ignored. The dwResultAction member can be one of the following
values.
PD_RESULT_APPLY
The user clicked the Apply button and later clicked the Cancel button. This indicates
that the user wants to apply the changes made in the property sheet, but does not want
to print yet. The PRINTDLGEX structure contains the information specified by the user at
the time the Apply button was clicked.
PD_RESULT_CANCEL
The user clicked the Cancel button. The information in the PRINTDLGEX structure is
unchanged.
PD_RESULT_PRINT
The user clicked the Print button. The PRINTDLGEX structure contains the information
specified by the user.
Remarks
If both hDevMode and hDevNames are NULL, PrintDlgEx initializes the property sheet
using the current default printer. To initialize the property sheet for a different printer,
use the wDeviceOffset member of the DEVNAMES structure to specify the name of the
printer.
Note that the dmDeviceName member of the DEVMODE structure also specifies a
printer name. However, dmDeviceName is limited to 32 characters, and the
wDeviceOffset name is not. If the wDeviceOffset and dmDeviceName names are not
the same, PrintDlgEx initializes the property sheet using the printer specified by
wDeviceOffset.
If the PD_RETURNDEFAULT flag is set and both hDevMode and hDevNames are NULL,
PrintDlgEx uses the hDevNames and hDevMode members to return information about
the current default printer without displaying the dialog box.
During the execution of PrintDlgEx, the DEVMODE and DEVNAMES structures that you
specified in the PRINTDLGEX structure may not always contain current data. For this
reason, application-specific property pages as well as IPrintDialogCallback routines for
the initial page should use the IPrintDialogServices interface to retrieve information
about the state of the current printer.
7 Note
The commdlg.h header defines PRINTDLGEX as an alias which automatically selects
the ANSI or Unicode version of this function based on the definition of the
UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with
code that not encoding-neutral can lead to mismatches that result in compilation
or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
See also
Common Dialog Box Library
Conceptual
DEVMODE
DEVNAMES
IPrintDialogCallback
IPrintDialogServices
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call PrintDlgEx instead of calling this method directly.
Syntax
C++
PrintDlgExW Printdlgexw;
HRESULT Printdlgexw(
LPPRINTDLGEXW pPD
)
{...}
Parameters
pPD
Requirements
Header commdlg.h
See also
PrintDlgEx
Feedback
Was this page helpful? ツ Yes ト No
Contains information that the PrintDlgEx function uses to initialize the Print property
sheet. After the user closes the property sheet, the system uses this structure to return
information about the user's selections.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the property sheet. This member must be a valid
window handle; it cannot be NULL.
hDevMode
Type: HGLOBAL
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDevNames
Type: HGLOBAL
The hDevNames member can be NULL, in which case, PrintDlgEx allocates memory for
the DEVNAMES structure, initializes its members to indicate the user's input, and returns
a handle that identifies it.
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDC
Type: HDC
Flags
Type: DWORD
A set of bit flags that you can use to initialize the Print property sheet. When the
PrintDlgEx function returns, it sets these flags to indicate the user's input. This member
can be one or more of the following values.
To ensure that PrintDlg or PrintDlgEx returns the correct values in the dmCopies and
dmCollate members of the DEVMODE structure, set PD_RETURNDC = TRUE and
PD_USEDEVMODECOPIESANDCOLLATE = TRUE. In so doing, the nCopies member of
the PRINTDLG structure is always 1 and PD_COLLATE is always FALSE.
To ensure that PrintDlg or PrintDlgEx returns the correct values in nCopies and
PD_COLLATE, set PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE
= FALSE. In so doing, dmCopies is always 1 and dmCollate is always FALSE.
Starting with Windows Vista, when you call PrintDlg or PrintDlgEx with PD_RETURNDC
set to TRUE and PD_USEDEVMODECOPIESANDCOLLATE set to FALSE, the PrintDlg or
PrintDlgEx function sets the number of copies in the nCopies member of the PRINTDLG
structure, and it sets the number of copies in the structure represented by the hDC
member of the PRINTDLG structure.
When making calls to GDI, you must ignore the value of nCopies, consider the value as
1, and use the returned hDC to avoid printing duplicate copies.
Value Meaning
PD_ALLPAGES The default flag that indicates that the All radio button
0x00000000 is initially selected. This flag is used as a placeholder to
indicate that the PD_PAGENUMS, PD_SELECTION, and
PD_CURRENTPAGE flags are not specified.
See PD_NOPAGENUMS.
PD_PRINTTOFILE If this flag is set, the Print to File check box is selected.
0x00000020 If this flag is set when PrintDlgEx returns, the offset
indicated by the wOutputOffset member of the
DEVNAMES structure contains the string "FILE:". When
you call the StartDoc function to start the printing
operation, specify this "FILE:" string in the lpszOutput
member of the DOCINFO structure. Specifying this
string causes the print subsystem to query the user for
the name of the output file.
Flags2
Type: DWORD
ExclusionFlags
Type: DWORD
A set of bit flags that can exclude items from the printer driver property pages in the
Print property sheet. This value is used only if the PD_EXCLUSIONFLAGS flag is set in
the Flags member. Exclusion flags should be used only if the item to be excluded will be
included on either the General page or on an application-defined page in the Print
property sheet. This member can specify the following flag.
PD_EXCL_COPIESANDCOLLATE
Excludes the Copies and Collate controls from the printer driver property pages in a
Print property sheet. This flag should always be set when the application uses the
default Copies and Collate controls provided by the lower portion of the General page
of the Print property sheet.
nPageRanges
Type: DWORD
On input, set this member to the initial number of page ranges specified in the
lpPageRanges array. When the PrintDlgEx function returns, nPageRanges indicates the
number of user-specified page ranges stored in the lpPageRanges array. If the
PD_NOPAGENUMS flag is specified, this value is not valid.
nMaxPageRanges
Type: DWORD
The size, in array elements, of the lpPageRanges buffer. This value indicates the
maximum number of page ranges that can be stored in the array. If the
PD_NOPAGENUMS flag is specified, this value is not valid. If the PD_NOPAGENUMS flag
is not specified, this value must be greater than zero.
lpPageRanges
Type: LPPRINTPAGERANGE
nMinPage
Type: DWORD
The minimum value for the page ranges specified in the Pages edit control. If the
PD_NOPAGENUMS flag is specified, this value is not valid.
nMaxPage
Type: DWORD
The maximum value for the page ranges specified in the Pages edit control. If the
PD_NOPAGENUMS flag is specified, this value is not valid.
nCopies
Type: DWORD
Contains the initial number of copies for the Copies edit control if hDevMode is NULL;
otherwise, the dmCopies member of the DEVMODE structure contains the initial value.
When PrintDlgEx returns, nCopies contains the actual number of copies the application
must print. This value depends on whether the application or the printer driver is
responsible for printing multiple copies. If the PD_USEDEVMODECOPIESANDCOLLATE
flag is set in the Flags member, nCopies is always 1 on return, and the printer driver is
responsible for printing multiple copies. If the flag is not set, the application is
responsible for printing the number of copies specified by nCopies. For more
information, see the description of the PD_USEDEVMODECOPIESANDCOLLATE flag.
hInstance
Type: HINSTANCE
lpPrintTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template replaces the default dialog box template in the lower portion of
the General page. The default template contains controls similar to those of the Print
dialog box. This member is ignored unless the PD_ENABLEPRINTTEMPLATE flag is set in
the Flags member.
lpCallback
Type: LPUNKNOWN
The callback object should also contain the IObjectWithSite class to receive a pointer to
the IPrintDialogServices interface. The PrintDlgEx function calls
IUnknown::QueryInterface on the callback object for both IID_IPrintDialogCallback and
IID_IObjectWithSite to determine which interfaces are supported.
If you do not want to retrieve any of the callback information, set lpCallback to NULL.
nPropertyPages
Type: DWORD
lphPropertyPages
Type: HPROPSHEETPAGE*
Contains an array of property page handles to add to the Print property sheet. The
additional property pages follow the General page. Use the CreatePropertySheetPage
function to create these additional pages. When the PrintDlgEx function returns, all the
HPROPSHEETPAGE handles in the lphPropertyPages array have been destroyed. If
nPropertyPages is zero, lphPropertyPages should be NULL.
nStartPage
Type: DWORD
The property page that is initially displayed. To display the General page, specify
START_PAGE_GENERAL. Otherwise, specify the zero-based index of a property page in
the array specified in the lphPropertyPages member. For consistency, it is
recommended that the property sheet always be started on the General page.
dwResultAction
Type: DWORD
On input, set this member to zero. If the PrintDlgEx function returns S_OK,
dwResultAction contains the outcome of the dialog. If PrintDlgEx returns an error, this
member should be ignored. The dwResultAction member can be one of the following
values.
PD_RESULT_APPLY
The user clicked the Apply button and later clicked the Cancel button. This indicates
that the user wants to apply the changes made in the property sheet, but does not want
to print yet. The PRINTDLGEX structure contains the information specified by the user at
the time the Apply button was clicked.
PD_RESULT_CANCEL
The user clicked the Cancel button. The information in the PRINTDLGEX structure is
unchanged.
PD_RESULT_PRINT
The user clicked the Print button. The PRINTDLGEX structure contains the information
specified by the user.
Remarks
If both hDevMode and hDevNames are NULL, PrintDlgEx initializes the property sheet
using the current default printer. To initialize the property sheet for a different printer,
use the wDeviceOffset member of the DEVNAMES structure to specify the name of the
printer.
Note that the dmDeviceName member of the DEVMODE structure also specifies a
printer name. However, dmDeviceName is limited to 32 characters, and the
wDeviceOffset name is not. If the wDeviceOffset and dmDeviceName names are not
the same, PrintDlgEx initializes the property sheet using the printer specified by
wDeviceOffset.
If the PD_RETURNDEFAULT flag is set and both hDevMode and hDevNames are NULL,
PrintDlgEx uses the hDevNames and hDevMode members to return information about
the current default printer without displaying the dialog box.
During the execution of PrintDlgEx, the DEVMODE and DEVNAMES structures that you
specified in the PRINTDLGEX structure may not always contain current data. For this
reason, application-specific property pages as well as IPrintDialogCallback routines for
the initial page should use the IPrintDialogServices interface to retrieve information
about the state of the current printer.
7 Note
The commdlg.h header defines PRINTDLGEX as an alias which automatically selects
the ANSI or Unicode version of this function based on the definition of the
UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with
code that not encoding-neutral can lead to mismatches that result in compilation
or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
See also
Common Dialog Box Library
Conceptual
DEVMODE
DEVNAMES
IPrintDialogCallback
IPrintDialogServices
PrintDlgEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
2 Warning
Apps should generally call PrintDlg instead of calling this method directly.
Syntax
C++
PrintDlgW Printdlgw;
BOOL Printdlgw(
LPPRINTDLGW pPD
)
{...}
Parameters
pPD
Requirements
Header commdlg.h
See also
[PrintDlg](https://docs.microsoft.com/previous-
versions/windows/desktop/legacy/ms646940(v=vs.85)
Feedback
Was this page helpful? ツ Yes ト No
Contains information that the PrintDlg function uses to initialize the Print Dialog Box.
After the user closes the dialog box, the system uses this structure to return information
about the user's selections.
Syntax
C++
Members
lStructSize
Type: DWORD
hwndOwner
Type: HWND
A handle to the window that owns the dialog box. This member can be any valid
window handle, or it can be NULL if the dialog box has no owner.
hDevMode
Type: HGLOBAL
If hDevMode is NULL on input, PrintDlg allocates memory for the DEVMODE structure,
initializes its members to indicate the user's input, and returns a handle that identifies it.
If the device driver for the specified printer does not support extended device modes,
hDevMode is NULL when PrintDlg returns.
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDevNames
Type: HGLOBAL
The hDevNames member can be NULL, in which case, PrintDlg allocates memory for the
DEVNAMES structure, initializes its members to indicate the user's input, and returns a
handle that identifies it.
For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.
hDC
Type: HDC
A handle to a device context or an information context, depending on whether the Flags
member specifies the PD_RETURNDC or PC_RETURNIC flag. If neither flag is specified,
the value of this member is undefined. If both flags are specified, PD_RETURNDC has
priority.
Flags
Type: DWORD
Initializes the Print dialog box. When the dialog box returns, it sets these flags to
indicate the user's input. This member can be one or more of the following values.
Value Meaning
PD_ALLPAGES The default flag that indicates that the All radio button
0x00000000 is initially selected. This flag is used as a placeholder to
indicate that the PD_PAGENUMS and PD_SELECTION
flags are not specified.
See PD_NOPAGENUMS.
PD_PRINTTOFILE If this flag is set, the Print to File check box is selected.
0x00000020 If this flag is set when the PrintDlg function returns, the
offset indicated by the wOutputOffset member of the
DEVNAMES structure contains the string "FILE:". When
you call the StartDoc function to start the printing
operation, specify this "FILE:" string in the lpszOutput
member of the DOCINFO structure. Specifying this
string causes the print subsystem to query the user for
the name of the output file.
PD_RETURNDEFAULT If this flag is set, the PrintDlg function does not display
0x00000400 the dialog box. Instead, it sets the hDevNames and
hDevMode members to handles to DEVMODE and
DEVNAMES structures that are initialized for the
system default printer. Both hDevNames and
hDevMode must be NULL, or PrintDlg returns an
error.
PD_SHOWHELP Causes the dialog box to display the Help button. The
0x00000800 hwndOwner member must specify the window to
receive the HELPMSGSTRING registered messages that
the dialog box sends when the user clicks the Help
button.
To ensure that PrintDlg or PrintDlgEx returns the correct values in the dmCopies and
dmCollate members of the DEVMODE structure, set PD_RETURNDC = TRUE and
PD_USEDEVMODECOPIESANDCOLLATE = TRUE. In so doing, the nCopies member of
the PRINTDLG structure is always 1 and PD_COLLATE is always FALSE.
To ensure that PrintDlg or PrintDlgEx returns the correct values in nCopies and
PD_COLLATE, set PD_RETURNDC = TRUE and PD_USEDEVMODECOPIESANDCOLLATE
= FALSE. In so doing, dmCopies is always 1 and dmCollate is always FALSE.
On Windows Vista and Windows 7, when you call PrintDlg or PrintDlgEx with
PD_RETURNDC set to TRUE and PD_USEDEVMODECOPIESANDCOLLATE set to FALSE,
the PrintDlg or PrintDlgEx function sets the number of copies in the nCopies member
of the PRINTDLG structure, and it sets the number of copies in the structure represented
by the hDC member of the PRINTDLG structure.
When making calls to GDI, you must ignore the value of nCopies, consider the value as
1, and use the returned hDC to avoid printing duplicate copies.
nFromPage
Type: WORD
When PrintDlg returns, nFromPage is the starting page specified by the user. If the
Pages radio button is selected when the user clicks the Okay button, PrintDlg sets the
PD_PAGENUMS flag and does not return until the user enters a starting page value that
is within the minimum to maximum page range.
If the input value for either nFromPage or nToPage is outside the minimum/maximum
range, PrintDlg returns an error only if the PD_PAGENUMS flag is specified; otherwise, it
displays the dialog box but changes the out-of-range value to the minimum or
maximum value.
nToPage
Type: WORD
The initial value for the ending page edit control. When PrintDlg returns, nToPage is the
ending page specified by the user. If the Pages radio button is selected when the use
clicks the Okay button, PrintDlg sets the PD_PAGENUMS flag and does not return until
the user enters an ending page value that is within the minimum to maximum page
range.
nMinPage
Type: WORD
The minimum value for the page range specified in the From and To page edit controls.
If nMinPage equals nMaxPage, the Pages radio button and the starting and ending
page edit controls are disabled.
nMaxPage
Type: WORD
The maximum value for the page range specified in the From and To page edit controls.
nCopies
Type: WORD
The initial number of copies for the Copies edit control if hDevMode is NULL; otherwise,
the dmCopies member of the DEVMODE structure contains the initial value. When
PrintDlg returns, nCopies contains the actual number of copies to print. This value
depends on whether the application or the printer driver is responsible for printing
multiple copies. If the PD_USEDEVMODECOPIESANDCOLLATE flag is set in the Flags
member, nCopies is always 1 on return, and the printer driver is responsible for printing
multiple copies. If the flag is not set, the application is responsible for printing the
number of copies specified by nCopies. For more information, see the description of the
PD_USEDEVMODECOPIESANDCOLLATE flag.
hInstance
Type: HINSTANCE
lCustData
Type: LPARAM
Application-defined data that the system passes to the hook procedure identified by the
lpfnPrintHook or lpfnSetupHook member. When the system sends the
WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a
pointer to the PRINTDLG structure specified when the dialog was created. The hook
procedure can use this pointer to get the lCustData value.
lpfnPrintHook
Type: LPPRINTHOOKPROC
A pointer to a PrintHookProc hook procedure that can process messages intended for
the Print dialog box. This member is ignored unless the PD_ENABLEPRINTHOOK flag is
set in the Flags member.
lpfnSetupHook
Type: LPSETUPHOOKPROC
A pointer to a SetupHookProc hook procedure that can process messages intended for
the Print Setup dialog box. This member is ignored unless the PD_ENABLESETUPHOOK
flag is set in the Flags member.
lpPrintTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template replaces the default Print dialog box template. This member is
ignored unless the PD_ENABLEPRINTTEMPLATE flag is set in the Flags member.
lpSetupTemplateName
Type: LPCTSTR
The name of the dialog box template resource in the module identified by the hInstance
member. This template replaces the default Print Setup dialog box template. This
member is ignored unless the PD_ENABLESETUPTEMPLATE flag is set in the Flags
member.
hPrintTemplate
Type: HGLOBAL
hSetupTemplate
Type: HGLOBAL
Remarks
If both hDevMode and hDevNames are NULL, PrintDlg initializes the dialog box using
the current default printer. To initialize the dialog box for a different printer, use the
wDeviceOffset member of the DEVNAMES structure to specify the name of the printer.
Note that the dmDeviceName member of the DEVMODE structure also specifies a
printer name. However, dmDeviceName is limited to 32 characters, and the
wDeviceOffset name is not. If the wDeviceOffset and dmDeviceName names are not
the same, PrintDlg initializes the dialog box using the printer specified by
wDeviceOffset.
If the PD_RETURNDEFAULT flag is set and both hDevMode and hDevNames are NULL,
PrintDlg uses the hDevNames and hDevMode members to return information about
the current default printer without displaying the dialog box.
7 Note
Requirements
See also
Common Dialog Box Library
Conceptual
DEVMODE
DEVNAMES
PrintDlg
Reference
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Represents a range of pages in a print job. A print job can have more than one page
range. This information is supplied in the PRINTDLGEX structure when calling the
PrintDlgEx function.
Syntax
C++
Members
nFromPage
Type: DWORD
nToPage
Type: DWORD
Requirements
Feedback
Was this page helpful? ツ Yes ト No
Creates a system-defined modeless dialog box that lets the user specify a string to
search for and a replacement string, as well as options to control the find and replace
operations.
Syntax
C++
HWND ReplaceTextA(
[in, out] LPFINDREPLACEA unnamedParam1
);
Parameters
[in, out] unnamedParam1
Type: LPFINDREPLACE
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box. You
can use the window handle to communicate with the dialog box or close it.
If the function fails, the return value is NULL. To get extended error information, call the
CommDlgExtendedError function, which can return one of the following error codes:
Remarks
The ReplaceText function does not perform a text replacement operation. Instead, the
dialog box sends FINDMSGSTRING registered messages to the window procedure of the
owner window of the dialog box. When you create the dialog box, the hwndOwner
member of the FINDREPLACE structure is a handle to the owner window.
Before calling ReplaceText, you must call the RegisterWindowMessage function to get
the identifier for the FINDMSGSTRING message. The dialog box procedure uses this
identifier to send messages when the user clicks the Find Next, Replace, or Replace All
buttons, or when the dialog box is closing. The lParam parameter of a FINDMSGSTRING
message contains a pointer to the FINDREPLACE structure. The Flags member of this
structure indicates the event that caused the message. Other members of the structure
indicate the user's input.
If you create a Replace dialog box, you must also use the IsDialogMessage function in
the main message loop of your application to ensure that the dialog box correctly
processes keyboard input, such as the TAB and ESC keys. The IsDialogMessage function
returns a value that indicates whether the Replace dialog box processed the message.
You can provide an FRHookProc hook procedure for a Replace dialog box. The hook
procedure can process messages sent to the dialog box. To enable a hook procedure,
set the FR_ENABLEHOOK flag in the Flags member of the FINDREPLACE structure and
specify the address of the hook procedure in the lpfnHook member.
7 Note
Requirements
DLL Comdlg32.dll
See also
CommDlgExtendedError
Conceptual
FINDREPLACE
FRHookProc
IsDialogMessage
Reference
RegisterWindowMessage
WM_CTLCOLORDLG
Feedback
Was this page helpful? ツ Yes ト No
Creates a system-defined modeless dialog box that lets the user specify a string to
search for and a replacement string, as well as options to control the find and replace
operations.
Syntax
C++
HWND ReplaceTextW(
[in, out] LPFINDREPLACEW unnamedParam1
);
Parameters
[in, out] unnamedParam1
Type: LPFINDREPLACE
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box. You
can use the window handle to communicate with the dialog box or close it.
If the function fails, the return value is NULL. To get extended error information, call the
CommDlgExtendedError function, which can return one of the following error codes:
Remarks
The ReplaceText function does not perform a text replacement operation. Instead, the
dialog box sends FINDMSGSTRING registered messages to the window procedure of the
owner window of the dialog box. When you create the dialog box, the hwndOwner
member of the FINDREPLACE structure is a handle to the owner window.
Before calling ReplaceText, you must call the RegisterWindowMessage function to get
the identifier for the FINDMSGSTRING message. The dialog box procedure uses this
identifier to send messages when the user clicks the Find Next, Replace, or Replace All
buttons, or when the dialog box is closing. The lParam parameter of a FINDMSGSTRING
message contains a pointer to the FINDREPLACE structure. The Flags member of this
structure indicates the event that caused the message. Other members of the structure
indicate the user's input.
If you create a Replace dialog box, you must also use the IsDialogMessage function in
the main message loop of your application to ensure that the dialog box correctly
processes keyboard input, such as the TAB and ESC keys. The IsDialogMessage function
returns a value that indicates whether the Replace dialog box processed the message.
You can provide an FRHookProc hook procedure for a Replace dialog box. The hook
procedure can process messages sent to the dialog box. To enable a hook procedure,
set the FR_ENABLEHOOK flag in the Flags member of the FINDREPLACE structure and
specify the address of the hook procedure in the lpfnHook member.
7 Note
Requirements
DLL Comdlg32.dll
See also
CommDlgExtendedError
Conceptual
FINDREPLACE
FRHookProc
IsDialogMessage
Reference
RegisterWindowMessage
WM_CTLCOLORDLG
Feedback
Was this page helpful? ツ Yes ト No
Data Exchange
Desktop Window Manager (DWM)
Developer Notes
Dialog Boxes
Display Devices Reference
High DPI
Input Feedback Configuration
Input Source Identification
Internationalization for Windows Applications
Keyboard and Mouse Input
Menus and Other Resources
Mobile Device Management Settings Provider
Pointer Device Input Stack
Pointer Input Messages and Notifications
Remote Desktop Services
Security and Identity
System Services
The Windows Shell
Touch Hit Testing
Touch Injection
Touch Input
Window Stations and Desktops
Windows Accessibility Features
Windows and Messages
Windows Controls
Windows GDI
Functions
ActivateKeyboardLayout
Sets the input locale identifier (formerly called the keyboard layout handle) for the calling thread
or the current process. The input locale identifier specifies a locale as well as the physical layout of
the keyboard.
AddClipboardFormatListener
Places the given window in the system-maintained clipboard format listener list.
AdjustWindowRect
Calculates the required size of the window rectangle, based on the desired client-rectangle size.
The window rectangle can then be passed to the CreateWindow function to create a window
whose client area is the desired size.
AdjustWindowRectEx
Calculates the required size of the window rectangle, based on the desired size of the client
rectangle. The window rectangle can then be passed to the CreateWindowEx function to create a
window whose client area is the desired size.
AdjustWindowRectExForDpi
Calculates the required size of the window rectangle, based on the desired size of the client
rectangle and the provided DPI.
AllowSetForegroundWindow
Enables the specified process to set the foreground window using the SetForegroundWindow
function. The calling process must already be able to set the foreground window. For more
information, see Remarks later in this topic.
AnimateWindow
Enables you to produce special effects when showing or hiding windows. There are four types of
animation:_roll, slide, collapse or expand, and alpha-blended fade.
AnyPopup
Indicates whether an owned, visible, top-level pop-up, or overlapped window exists on the screen.
The function searches the entire screen, not just the calling application's client area.
AppendMenuA
Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or
shortcut menu. You can use this function to specify the content, appearance, and behavior of the
menu item. (ANSI)
AppendMenuW
Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or
shortcut menu. You can use this function to specify the content, appearance, and behavior of the
menu item. (Unicode)
AreDpiAwarenessContextsEqual
ArrangeIconicWindows
Arranges all the minimized (iconic) child windows of the specified parent window.
AttachThreadInput
Attaches or detaches the input processing mechanism of one thread to that of another thread.
BeginDeferWindowPos
Allocates memory for a multiple-window- position structure and returns the handle to the
structure.
BeginPaint
The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT
structure with information about the painting.
BlockInput
BringWindowToTop
Brings the specified window to the top of the Z order. If the window is a top-level window, it is
activated. If the window is a child window, the top-level parent window associated with the child
window is activated.
BroadcastSystemMessage
BroadcastSystemMessageA
BroadcastSystemMessageExA
BroadcastSystemMessageExW
Sends a message to the specified recipients. (BroadcastSystemMessageExW)
BroadcastSystemMessageW
CalculatePopupWindowPosition
Calculates an appropriate pop-up window position using the specified anchor point, pop-up
window size, flags, and the optional exclude rectangle.
CallMsgFilterA
Passes the specified message and hook code to the hook procedures associated with the
WH_SYSMSGFILTER and WH_MSGFILTER hooks. (ANSI)
CallMsgFilterW
Passes the specified message and hook code to the hook procedures associated with the
WH_SYSMSGFILTER and WH_MSGFILTER hooks. (Unicode)
CallNextHookEx
Passes the hook information to the next hook procedure in the current hook chain. A hook
procedure can call this function either before or after processing the hook information.
CallWindowProcA
CallWindowProcW
CascadeWindows
ChangeClipboardChain
ChangeDisplaySettingsA
The ChangeDisplaySettings function changes the settings of the default display device to the
specified graphics mode. (ANSI)
ChangeDisplaySettingsExA
The ChangeDisplaySettingsEx function changes the settings of the specified display device to the
specified graphics mode. (ANSI)
ChangeDisplaySettingsExW
The ChangeDisplaySettingsEx function changes the settings of the specified display device to the
specified graphics mode. (Unicode)
ChangeDisplaySettingsW
The ChangeDisplaySettings function changes the settings of the default display device to the
specified graphics mode. (Unicode)
ChangeWindowMessageFilter
Adds or removes a message from the User Interface Privilege Isolation (UIPI) message filter.
ChangeWindowMessageFilterEx
Modifies the User Interface Privilege Isolation (UIPI) message filter for a specified window.
CharLowerA
Converts a character string or a single character to lowercase. If the operand is a character string,
the function converts the characters in place. (ANSI)
CharLowerBuffA
Converts uppercase characters in a buffer to lowercase characters. The function converts the
characters in place. (ANSI)
CharLowerBuffW
Converts uppercase characters in a buffer to lowercase characters. The function converts the
characters in place. (Unicode)
CharLowerW
Converts a character string or a single character to lowercase. If the operand is a character string,
the function converts the characters in place. (Unicode)
CharNextA
Retrieves a pointer to the next character in a string. This function can handle strings consisting of
either single- or multi-byte characters. (ANSI)
CharNextExA
Retrieves the pointer to the next character in a string. This function can handle strings consisting
of either single- or multi-byte characters.
CharNextW
Retrieves a pointer to the next character in a string. This function can handle strings consisting of
either single- or multi-byte characters. (Unicode)
CharPrevA
Retrieves a pointer to the preceding character in a string. This function can handle strings
consisting of either single- or multi-byte characters. (ANSI)
CharPrevExA
Retrieves the pointer to the preceding character in a string. This function can handle strings
consisting of either single- or multi-byte characters.
CharPrevW
Retrieves a pointer to the preceding character in a string. This function can handle strings
consisting of either single- or multi-byte characters. (Unicode)
CharToOemA
Translates a string into the OEM-defined character set.Warning Do not use. (ANSI)
CharToOemBuffA
Translates a specified number of characters in a string into the OEM-defined character set. (ANSI)
CharToOemBuffW
Translates a specified number of characters in a string into the OEM-defined character set.
(Unicode)
CharToOemW
Translates a string into the OEM-defined character set.Warning Do not use. (Unicode)
CharUpperA
Converts a character string or a single character to uppercase. If the operand is a character string,
the function converts the characters in place. (ANSI)
CharUpperBuffA
Converts lowercase characters in a buffer to uppercase characters. The function converts the
characters in place. (ANSI)
CharUpperBuffW
Converts lowercase characters in a buffer to uppercase characters. The function converts the
characters in place. (Unicode)
CharUpperW
Converts a character string or a single character to uppercase. If the operand is a character string,
the function converts the characters in place. (Unicode)
CheckDlgButton
CheckMenuItem
Sets the state of the specified menu item's check-mark attribute to either selected or clear.
CheckMenuRadioItem
Checks a specified menu item and makes it a radio item. At the same time, the function clears all
other menu items in the associated group and clears the radio-item type flag for those items.
CheckRadioButton
Adds a check mark to (checks) a specified radio button in a group and removes a check mark
from (clears) all other radio buttons in the group.
ChildWindowFromPoint
Determines which, if any, of the child windows belonging to a parent window contains the
specified point. The search is restricted to immediate child windows. Grandchildren, and deeper
descendant windows are not searched.
ChildWindowFromPointEx
Determines which, if any, of the child windows belonging to the specified parent window contains
the specified point.
ClientToScreen
The ClientToScreen function converts the client-area coordinates of a specified point to screen
coordinates.
ClipCursor
CloseDesktop
CloseGestureInfoHandle
CloseTouchInputHandle
Closes a touch input handle, frees process memory associated with it, and invalidates the handle.
CloseWindow
CloseWindowStation
CopyAcceleratorTableA
Copies the specified accelerator table. This function is used to obtain the accelerator-table data
that corresponds to an accelerator-table handle, or to determine the size of the accelerator-table
data. (ANSI)
CopyAcceleratorTableW
Copies the specified accelerator table. This function is used to obtain the accelerator-table data
that corresponds to an accelerator-table handle, or to determine the size of the accelerator-table
data. (Unicode)
CopyCursor
CopyIcon
Copies the specified icon from another module to the current module.
CopyImage
Creates a new image (icon, cursor, or bitmap) and copies the attributes of the specified image to
the new one. If necessary, the function stretches the bits to fit the desired size of the new image.
CopyRect
CountClipboardFormats
CreateAcceleratorTableA
CreateAcceleratorTableW
CreateCaret
Creates a new shape for the system caret and assigns ownership of the caret to the specified
window. The caret shape can be a line, a block, or a bitmap.
CreateCursor
Creates a cursor having the specified size, bit patterns, and hot spot.
CreateDesktopA
Creates a new desktop, associates it with the current window station of the calling process, and
assigns it to the calling thread. (ANSI)
CreateDesktopExA
Creates a new desktop with the specified heap, associates it with the current window station of
the calling process, and assigns it to the calling thread. (ANSI)
CreateDesktopExW
Creates a new desktop with the specified heap, associates it with the current window station of
the calling process, and assigns it to the calling thread. (Unicode)
CreateDesktopW
Creates a new desktop, associates it with the current window station of the calling process, and
assigns it to the calling thread. (Unicode)
CreateDialogA
Creates a modeless dialog box from a dialog box template resource. The CreateDialog macro uses
the CreateDialogParam function. (ANSI)
CreateDialogIndirectA
Creates a modeless dialog box from a dialog box template in memory. The CreateDialogIndirect
macro uses the CreateDialogIndirectParam function. (ANSI)
CreateDialogIndirectParamA
Creates a modeless dialog box from a dialog box template in memory. (ANSI)
CreateDialogIndirectParamW
Creates a modeless dialog box from a dialog box template in memory. (Unicode)
CreateDialogIndirectW
Creates a modeless dialog box from a dialog box template in memory. The CreateDialogIndirect
macro uses the CreateDialogIndirectParam function. (Unicode)
CreateDialogParamA
Creates a modeless dialog box from a dialog box template resource. (ANSI)
CreateDialogParamW
Creates a modeless dialog box from a dialog box template resource. (Unicode)
CreateDialogW
Creates a modeless dialog box from a dialog box template resource. The CreateDialog macro uses
the CreateDialogParam function. (Unicode)
CreateIcon
Creates an icon that has the specified size, colors, and bit patterns.
CreateIconFromResource
Creates an icon or cursor from resource bits describing the icon. (CreateIconFromResource)
CreateIconFromResourceEx
Creates an icon or cursor from resource bits describing the icon. (CreateIconFromResourceEx)
CreateIconIndirect
CreateMDIWindowA
Creates a multiple-document interface (MDI) child window. (ANSI)
CreateMDIWindowW
CreateMenu
Creates a menu. The menu is initially empty, but it can be filled with menu items by using the
InsertMenuItem, AppendMenu, and InsertMenu functions.
CreatePopupMenu
CreateSyntheticPointerDevice
Configures the pointer injection device for the calling application, and initializes the maximum
number of simultaneous pointers that the app can inject.
CreateWindowA
CreateWindowExA
Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this
function is identical to the CreateWindow function. (ANSI)
CreateWindowExW
Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this
function is identical to the CreateWindow function. (Unicode)
CreateWindowStationA
Creates a window station object, associates it with the calling process, and assigns it to the current
session. (ANSI)
CreateWindowStationW
Creates a window station object, associates it with the calling process, and assigns it to the current
session. (Unicode)
CreateWindowW
DefDlgProcA
Calls the default dialog box window procedure to provide default processing for any window
messages that a dialog box with a private window class does not process. (ANSI)
DefDlgProcW
Calls the default dialog box window procedure to provide default processing for any window
messages that a dialog box with a private window class does not process. (Unicode)
DeferWindowPos
Updates the specified multiple-window � position structure for the specified window.
DefFrameProcA
Provides default processing for any window messages that the window procedure of a multiple-
document interface (MDI) frame window does not process. (ANSI)
DefFrameProcW
Provides default processing for any window messages that the window procedure of a multiple-
document interface (MDI) frame window does not process. (Unicode)
DefMDIChildProcA
Provides default processing for any window message that the window procedure of a multiple-
document interface (MDI) child window does not process. (ANSI)
DefMDIChildProcW
Provides default processing for any window message that the window procedure of a multiple-
document interface (MDI) child window does not process. (Unicode)
DefRawInputProc
DefWindowProcA
Calls the default window procedure to provide default processing for any window messages that
an application does not process. (ANSI)
DefWindowProcW
Calls the default window procedure to provide default processing for any window messages that
an application does not process. (Unicode)
DeleteMenu
Deletes an item from the specified menu. If the menu item opens a menu or submenu, this
function destroys the handle to the menu or submenu and frees the memory used by the menu or
submenu.
DeregisterShellHookWindow
Unregisters a specified Shell window that is registered to receive Shell hook messages.
DestroyAcceleratorTable
DestroyCaret
Destroys the caret's current shape, frees the caret from the window, and removes the caret from
the screen.
DestroyCursor
Destroys a cursor and frees any memory the cursor occupied. Do not use this function to destroy
a shared cursor.
DestroyIcon
DestroyMenu
Destroys the specified menu and frees any memory that the menu occupies.
DestroySyntheticPointerDevice
DestroyWindow
DialogBoxA
Creates a modal dialog box from a dialog box template resource. DialogBox does not return
control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (ANSI)
DialogBoxIndirectA
Creates a modal dialog box from a dialog box template in memory. DialogBoxIndirect does not
return control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (ANSI)
DialogBoxIndirectParamA
Creates a modal dialog box from a dialog box template in memory. (ANSI)
DialogBoxIndirectParamW
Creates a modal dialog box from a dialog box template in memory. (Unicode)
DialogBoxIndirectW
Creates a modal dialog box from a dialog box template in memory. DialogBoxIndirect does not
return control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (Unicode)
DialogBoxParamA
Creates a modal dialog box from a dialog box template resource. (ANSI)
DialogBoxParamW
Creates a modal dialog box from a dialog box template resource. (Unicode)
DialogBoxW
Creates a modal dialog box from a dialog box template resource. DialogBox does not return
control until the specified callback function terminates the modal dialog box by calling the
EndDialog function. (Unicode)
DisableProcessWindowsGhosting
Disables the window ghosting feature for the calling GUI process. Window ghosting is a Windows
Manager feature that lets the user minimize, move, or close the main window of an application
that is not responding.
DispatchMessage
DispatchMessageA
DispatchMessageW
DisplayConfigSetDeviceInfo
DlgDirListA
Replaces the contents of a list box with the names of the subdirectories and files in a specified
directory. You can filter the list of names by specifying a set of file attributes. The list can
optionally include mapped drives. (ANSI)
DlgDirListComboBoxA
Replaces the contents of a combo box with the names of the subdirectories and files in a specified
directory. You can filter the list of names by specifying a set of file attributes. The list of names can
include mapped drive letters. (ANSI)
DlgDirListComboBoxW
Replaces the contents of a combo box with the names of the subdirectories and files in a specified
directory. You can filter the list of names by specifying a set of file attributes. The list of names can
include mapped drive letters. (Unicode)
DlgDirListW
Replaces the contents of a list box with the names of the subdirectories and files in a specified
directory. You can filter the list of names by specifying a set of file attributes. The list can
optionally include mapped drives. (Unicode)
DlgDirSelectComboBoxExA
Retrieves the current selection from a combo box filled by using the DlgDirListComboBox
function. The selection is interpreted as a drive letter, a file, or a directory name. (ANSI)
DlgDirSelectComboBoxExW
Retrieves the current selection from a combo box filled by using the DlgDirListComboBox
function. The selection is interpreted as a drive letter, a file, or a directory name. (Unicode)
DlgDirSelectExA
Retrieves the current selection from a single-selection list box. It assumes that the list box has
been filled by the DlgDirList function and that the selection is a drive letter, filename, or directory
name. (ANSI)
DlgDirSelectExW
Retrieves the current selection from a single-selection list box. It assumes that the list box has
been filled by the DlgDirList function and that the selection is a drive letter, filename, or directory
name. (Unicode)
DragDetect
Captures the mouse and tracks its movement until the user releases the left button, presses the
ESC key, or moves the mouse outside the drag rectangle around the specified point.
DrawAnimatedRects
Animates the caption of a window to indicate the opening of an icon or the minimizing or
maximizing of a window.
DrawCaption
DrawEdge
DrawFocusRect
The DrawFocusRect function draws a rectangle in the style used to indicate that the rectangle has
the focus.
DrawFrameControl
The DrawFrameControl function draws a frame control of the specified type and style.
DrawIcon
DrawIconEx
Draws an icon or cursor into the specified device context, performing the specified raster
operations, and stretching or compressing the icon or cursor as specified.
DrawMenuBar
Redraws the menu bar of the specified window. If the menu bar changes after the system has
created the window, this function must be called to draw the changed menu bar.
DrawStateA
The DrawState function displays an image and applies a visual effect to indicate a state, such as a
disabled or default state. (ANSI)
DrawStateW
The DrawState function displays an image and applies a visual effect to indicate a state, such as a
disabled or default state. (Unicode)
DrawText
The DrawText function draws formatted text in the specified rectangle. (DrawText function)
DrawTextA
The DrawText function draws formatted text in the specified rectangle. It formats the text
according to the specified method (expanding tabs, justifying characters, breaking lines, and so
forth). (DrawTextA)
DrawTextExA
The DrawTextEx function draws formatted text in the specified rectangle. (ANSI)
DrawTextExW
The DrawTextEx function draws formatted text in the specified rectangle. (Unicode)
DrawTextW
The DrawTextW (Unicode) function draws formatted text in the specified rectangle. (DrawTextW
function)
EmptyClipboard
Empties the clipboard and frees handles to data in the clipboard. The function then assigns
ownership of the clipboard to the window that currently has the clipboard open.
EnableMenuItem
EnableMouseInPointer
Enables the mouse to act as a pointer input device and send WM_POINTER messages.
EnableNonClientDpiScaling
In high-DPI displays, enables automatic display scaling of the non-client area portions of the
specified top-level window. Must be called during the initialization of that window.
EnableScrollBar
The EnableScrollBar function enables or disables one or both scroll bar arrows.
EnableWindow
Enables or disables mouse and keyboard input to the specified window or control. When input is
disabled, the window does not receive input such as mouse clicks and key presses. When input is
enabled, the window receives all input.
EndDeferWindowPos
Simultaneously updates the position and size of one or more windows in a single screen-
refreshing cycle.
EndDialog
Destroys a modal dialog box, causing the system to end any processing for the dialog box.
EndMenu
EndPaint
The EndPaint function marks the end of painting in the specified window. This function is required
for each call to the BeginPaint function, but only after painting is complete.
EndTask
EnumChildWindows
Enumerates the child windows that belong to the specified parent window by passing the handle
to each child window, in turn, to an application-defined callback function.
EnumClipboardFormats
EnumDesktopsA
Enumerates all desktops associated with the specified window station of the calling process. The
function passes the name of each desktop, in turn, to an application-defined callback function.
(ANSI)
EnumDesktopsW
Enumerates all desktops associated with the specified window station of the calling process. The
function passes the name of each desktop, in turn, to an application-defined callback function.
(Unicode)
EnumDesktopWindows
Enumerates all top-level windows associated with the specified desktop. It passes the handle to
each window, in turn, to an application-defined callback function.
EnumDisplayDevicesA
The EnumDisplayDevices function lets you obtain information about the display devices in the
current session. (ANSI)
EnumDisplayDevicesW
The EnumDisplayDevices function lets you obtain information about the display devices in the
current session. (Unicode)
EnumDisplayMonitors
EnumDisplaySettingsA
The EnumDisplaySettings function retrieves information about one of the graphics modes for a
display device. To retrieve information for all the graphics modes of a display device, make a series
of calls to this function. (ANSI)
EnumDisplaySettingsExA
The EnumDisplaySettingsEx function retrieves information about one of the graphics modes for a
display device. To retrieve information for all the graphics modes for a display device, make a
series of calls to this function. (ANSI)
EnumDisplaySettingsExW
The EnumDisplaySettingsEx function retrieves information about one of the graphics modes for a
display device. To retrieve information for all the graphics modes for a display device, make a
series of calls to this function. (Unicode)
EnumDisplaySettingsW
The EnumDisplaySettings function retrieves information about one of the graphics modes for a
display device. To retrieve information for all the graphics modes of a display device, make a series
of calls to this function. (Unicode)
EnumPropsA
Enumerates all entries in the property list of a window by passing them, one by one, to the
specified callback function. EnumProps continues until the last entry is enumerated or the callback
function returns FALSE. (ANSI)
EnumPropsExA
Enumerates all entries in the property list of a window by passing them, one by one, to the
specified callback function. EnumPropsEx continues until the last entry is enumerated or the
callback function returns FALSE. (ANSI)
EnumPropsExW
Enumerates all entries in the property list of a window by passing them, one by one, to the
specified callback function. EnumPropsEx continues until the last entry is enumerated or the
callback function returns FALSE. (Unicode)
EnumPropsW
Enumerates all entries in the property list of a window by passing them, one by one, to the
specified callback function. EnumProps continues until the last entry is enumerated or the callback
function returns FALSE. (Unicode)
EnumThreadWindows
Enumerates all nonchild windows associated with a thread by passing the handle to each window,
in turn, to an application-defined callback function.
EnumWindows
Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to
an application-defined callback function. EnumWindows continues until the last top-level window
is enumerated or the callback function returns FALSE.
EnumWindowStationsA
Enumerates all window stations in the current session. The function passes the name of each
window station, in turn, to an application-defined callback function. (ANSI)
EnumWindowStationsW
Enumerates all window stations in the current session. The function passes the name of each
window station, in turn, to an application-defined callback function. (Unicode)
EqualRect
The EqualRect function determines whether the two specified rectangles are equal by comparing
the coordinates of their upper-left and lower-right corners.
EvaluateProximityToPolygon
Returns the score of a polygon as the probable touch target (compared to all other polygons that
intersect the touch contact area) and an adjusted touch point within the polygon.
EvaluateProximityToRect
Returns the score of a rectangle as the probable touch target, compared to all other rectangles
that intersect the touch contact area, and an adjusted touch point within the rectangle.
ExcludeUpdateRgn
The ExcludeUpdateRgn function prevents drawing within invalid areas of a window by excluding
an updated region in the window from a clipping region.
ExitWindows
ExitWindowsEx
Logs off the interactive user, shuts down the system, or shuts down and restarts the system.
FillRect
The FillRect function fills a rectangle by using the specified brush. This function includes the left
and top borders, but excludes the right and bottom borders of the rectangle.
FindWindowA
Retrieves a handle to the top-level window whose class name and window name match the
specified strings. This function does not search child windows. This function does not perform a
case-sensitive search. (ANSI)
FindWindowExA
Retrieves a handle to a window whose class name and window name match the specified strings.
The function searches child windows, beginning with the one following the specified child
window. This function does not perform a case-sensitive search. (ANSI)
FindWindowExW
Retrieves a handle to a window whose class name and window name match the specified strings.
The function searches child windows, beginning with the one following the specified child
window. This function does not perform a case-sensitive search. (Unicode)
FindWindowW
Retrieves a handle to the top-level window whose class name and window name match the
specified strings. This function does not search child windows. This function does not perform a
case-sensitive search. (Unicode)
FlashWindow
Flashes the specified window one time. It does not change the active state of the window.
FlashWindowEx
Flashes the specified window. It does not change the active state of the window.
FrameRect
The FrameRect function draws a border around the specified rectangle by using the specified
brush. The width and height of the border are always one logical unit.
GET_APPCOMMAND_LPARAM
GET_DEVICE_LPARAM
Retrieves the input device type from the specified LPARAM value.
GET_FLAGS_LPARAM
Retrieves the state of certain virtual keys from the specified LPARAM value. (GET_FLAGS_LPARAM)
GET_KEYSTATE_LPARAM
Retrieves the state of certain virtual keys from the specified LPARAM value.
(GET_KEYSTATE_LPARAM)
GET_KEYSTATE_WPARAM
Retrieves the state of certain virtual keys from the specified WPARAM value.
GET_NCHITTEST_WPARAM
GET_POINTERID_WPARAM
Retrieves the pointer ID using the specified value.
GET_RAWINPUT_CODE_WPARAM
GET_WHEEL_DELTA_WPARAM
GET_XBUTTON_WPARAM
Retrieves the state of certain buttons from the specified WPARAM value.
GetActiveWindow
Retrieves the window handle to the active window attached to the calling thread's message
queue.
GetAltTabInfoA
Retrieves status information for the specified window if it is the application-switching (ALT+TAB)
window. (ANSI)
GetAltTabInfoW
Retrieves status information for the specified window if it is the application-switching (ALT+TAB)
window. (Unicode)
GetAncestor
GetAsyncKeyState
Determines whether a key is up or down at the time the function is called, and whether the key
was pressed after a previous call to GetAsyncKeyState.
GetAutoRotationState
Retrieves an AR_STATE value containing the state of screen auto-rotation for the system, for
example whether auto-rotation is supported, and whether it is enabled by the user.
GetAwarenessFromDpiAwarenessContext
GetCapture
Retrieves a handle to the window (if any) that has captured the mouse. Only one window at a time
can capture the mouse; this window receives mouse input whether or not the cursor is within its
borders.
GetCaretBlinkTime
Retrieves the time required to invert the caret's pixels. The user can set this value.
GetCaretPos
GetCIMSSM
GetClassInfoA
GetClassInfoExA
Retrieves information about a window class, including a handle to the small icon associated with
the window class. The GetClassInfo function does not retrieve a handle to the small icon. (ANSI)
GetClassInfoExW
Retrieves information about a window class, including a handle to the small icon associated with
the window class. The GetClassInfo function does not retrieve a handle to the small icon.
(Unicode)
GetClassInfoW
GetClassLongA
Retrieves the specified 32-bit (DWORD) value from the WNDCLASSEX structure associated with
the specified window. (ANSI)
GetClassLongPtrA
Retrieves the specified value from the WNDCLASSEX structure associated with the specified
window. (ANSI)
GetClassLongPtrW
Retrieves the specified value from the WNDCLASSEX structure associated with the specified
window. (Unicode)
GetClassLongW
Retrieves the specified 32-bit (DWORD) value from the WNDCLASSEX structure associated with
the specified window. (Unicode)
GetClassName
The GetClassName function retrieves the name of the class to which the specified window
belongs. (GetClassName)
GetClassNameA
Retrieves the name of the class to which the specified window belongs. (GetClassNameA)
GetClassNameW
The GetClassNameW (Unicode) function retrieves the name of the class to which the specified
window belongs. (GetClassNameW)
GetClassWord
Retrieves the 16-bit (WORD) value at the specified offset into the extra class memory for the
window class to which the specified window belongs.
GetClientRect
GetClipboardData
Retrieves data from the clipboard in a specified format. The clipboard must have been opened
previously.
GetClipboardFormatNameA
Retrieves from the clipboard the name of the specified registered format. The function copies the
name to the specified buffer. (ANSI)
GetClipboardFormatNameW
Retrieves from the clipboard the name of the specified registered format. The function copies the
name to the specified buffer. (Unicode)
GetClipboardOwner
GetClipboardSequenceNumber
Retrieves the clipboard sequence number for the current window station.
GetClipboardViewer
Retrieves the handle to the first window in the clipboard viewer chain.
GetClipCursor
Retrieves the screen coordinates of the rectangular area to which the cursor is confined.
GetComboBoxInfo
GetCurrentInputMessageSource
GetCursor
GetCursorInfo
GetCursorPos
GetDC
The GetDC function retrieves a handle to a device context (DC) for the client area of a specified
window or for the entire screen.
GetDCEx
The GetDCEx function retrieves a handle to a device context (DC) for the client area of a specified
window or for the entire screen.
GetDesktopWindow
Retrieves a handle to the desktop window. The desktop window covers the entire screen. The
desktop window is the area on top of which other windows are painted.
GetDialogBaseUnits
Retrieves the system's dialog base units, which are the average width and height of characters in
the system font.
GetDialogControlDpiChangeBehavior
Retrieves and per-monitor DPI scaling behavior overrides of a child window in a dialog.
GetDialogDpiChangeBehavior
Returns the flags that might have been set on a given dialog by an earlier call to
SetDialogDpiChangeBehavior.
GetDisplayAutoRotationPreferences
GetDisplayAutoRotationPreferencesByProcessId
Retrieves the screen auto-rotation preferences for the process indicated by the dwProcessId
parameter.
GetDisplayConfigBufferSizes
The GetDisplayConfigBufferSizes function retrieves the size of the buffers that are required to call
the QueryDisplayConfig function.
GetDlgCtrlID
GetDlgItem
GetDlgItemInt
Translates the text of a specified control in a dialog box into an integer value.
GetDlgItemTextA
Retrieves the title or text associated with a control in a dialog box. (ANSI)
GetDlgItemTextW
Retrieves the title or text associated with a control in a dialog box. (Unicode)
GetDoubleClickTime
GetDpiAwarenessContextForProcess
Gets a DPI_AWARENESS_CONTEXT handle for the specified process.
GetDpiForSystem
GetDpiForWindow
Returns the dots per inch (dpi) value for the specified window.
GetDpiFromDpiAwarenessContext
Retrieves the DPI from a given DPI_AWARENESS_CONTEXT handle. This enables you to determine
the DPI of a thread without needed to examine a window created within that thread.
GetFocus
Retrieves the handle to the window that has the keyboard focus, if the window is attached to the
calling thread's message queue.
GetForegroundWindow
Retrieves a handle to the foreground window (the window with which the user is currently
working). The system assigns a slightly higher priority to the thread that creates the foreground
window than it does to other threads.
GetGestureConfig
Retrieves the configuration for which Windows Touch gesture messages are sent from a window.
GetGestureExtraArgs
GetGestureInfo
GetGuiResources
Retrieves the count of handles to graphical user interface (GUI) objects in use by the specified
process.
GetGUIThreadInfo
GetIconInfo
Retrieves information about the specified icon or cursor.
GetIconInfoExA
Retrieves information about the specified icon or cursor. GetIconInfoEx extends GetIconInfo by
using the newer ICONINFOEX structure. (ANSI)
GetIconInfoExW
Retrieves information about the specified icon or cursor. GetIconInfoEx extends GetIconInfo by
using the newer ICONINFOEX structure. (Unicode)
GetInputState
Determines whether there are mouse-button or keyboard messages in the calling thread's
message queue.
GetKBCodePage
GetKeyboardLayout
Retrieves the active input locale identifier (formerly called the keyboard layout).
GetKeyboardLayoutList
Retrieves the input locale identifiers (formerly called keyboard layout handles) corresponding to
the current set of input locales in the system. The function copies the identifiers to the specified
buffer.
GetKeyboardLayoutNameA
Retrieves the name of the active input locale identifier (formerly called the keyboard layout) for
the calling thread. (ANSI)
GetKeyboardLayoutNameW
Retrieves the name of the active input locale identifier (formerly called the keyboard layout) for
the calling thread. (Unicode)
GetKeyboardState
Copies the status of the 256 virtual keys to the specified buffer.
GetKeyboardType
GetKeyNameTextW
GetKeyState
Retrieves the status of the specified virtual key. The status specifies whether the key is up, down,
or toggled (on, off�alternating each time the key is pressed).
GetLastActivePopup
Determines which pop-up window owned by the specified window was most recently active.
GetLastInputInfo
GetLayeredWindowAttributes
GetListBoxInfo
GetMenu
GetMenuBarInfo
GetMenuCheckMarkDimensions
GetMenuContextHelpId
Retrieves the Help context identifier associated with the specified menu.
GetMenuDefaultItem
GetMenuItemCount
GetMenuItemID
Retrieves the menu item identifier of a menu item located at the specified position in a menu.
GetMenuItemInfoA
GetMenuItemInfoW
GetMenuItemRect
GetMenuState
Retrieves the menu flags associated with the specified menu item.
GetMenuStringA
Copies the text string of the specified menu item into the specified buffer. (ANSI)
GetMenuStringW
Copies the text string of the specified menu item into the specified buffer. (Unicode)
GetMessage
The GetMessage function retrieves a message from the calling thread's message queue.
(GetMessage)
GetMessageA
Retrieves a message from the calling thread's message queue. The function dispatches incoming
sent messages until a posted message is available for retrieval. (GetMessageA)
GetMessageExtraInfo
Retrieves the extra message information for the current thread. Extra message information is an
application- or driver-defined value associated with the current thread's message queue.
GetMessagePos
Retrieves the cursor position for the last message retrieved by the GetMessage function.
GetMessageTime
Retrieves the message time for the last message retrieved by the GetMessage function.
GetMessageW
The GetMessageW function (Unicode) retrieves a message from the calling thread's message
queue. (GetMessageW)
GetMonitorInfoA
GetMonitorInfoW
GetMouseMovePointsEx
GetNextDlgGroupItem
Retrieves a handle to the first control in a group of controls that precedes (or follows) the
specified control in a dialog box.
GetNextDlgTabItem
Retrieves a handle to the first control that has the WS_TABSTOP style that precedes (or follows)
the specified control.
GetNextWindow
Retrieves a handle to the next or previous window in the Z-Order. The next window is below the
specified window; the previous window is above.
GetOpenClipboardWindow
Retrieves the handle to the window that currently has the clipboard open.
GetParent
Retrieves a handle to the specified window's parent or owner.
GetPhysicalCursorPos
GetPointerCursorId
GetPointerDevice
GetPointerDeviceCursors
Gets the cursor IDs that are mapped to the cursors associated with a pointer device.
GetPointerDeviceProperties
GetPointerDeviceRects
Gets the x and y range for the pointer device (in himetric) and the x and y range (current
resolution) for the display that the pointer device is mapped to.
GetPointerDevices
GetPointerFrameInfo
Gets the entire frame of information for the specified pointers associated with the current
message.
GetPointerFrameInfoHistory
Gets the entire frame of information (including coalesced input frames) for the specified pointers
associated with the current message.
GetPointerFramePenInfo
Gets the entire frame of pen-based information for the specified pointers (of type PT_PEN)
associated with the current message.
GetPointerFramePenInfoHistory
Gets the entire frame of pen-based information (including coalesced input frames) for the
specified pointers (of type PT_PEN) associated with the current message.
GetPointerFrameTouchInfo
Gets the entire frame of touch-based information for the specified pointers (of type PT_TOUCH)
associated with the current message.
GetPointerFrameTouchInfoHistory
Gets the entire frame of touch-based information (including coalesced input frames) for the
specified pointers (of type PT_TOUCH) associated with the current message.
GetPointerInfo
Gets the information for the specified pointer associated with the current message.
GetPointerInfoHistory
Gets the information associated with the individual inputs, if any, that were coalesced into the
current message for the specified pointer.
GetPointerInputTransform
Gets one or more transforms for the pointer information coordinates associated with the current
message.
GetPointerPenInfo
Gets the pen-based information for the specified pointer (of type PT_PEN) associated with the
current message.
GetPointerPenInfoHistory
Gets the pen-based information associated with the individual inputs, if any, that were coalesced
into the current message for the specified pointer (of type PT_PEN).
GetPointerTouchInfo
Gets the touch-based information for the specified pointer (of type PT_TOUCH) associated with
the current message.
GetPointerTouchInfoHistory
Gets the touch-based information associated with the individual inputs, if any, that were
coalesced into the current message for the specified pointer (of type PT_TOUCH).
GetPointerType
Retrieves the pointer type for a specified pointer.
GetPriorityClipboardFormat
GetProcessDefaultLayout
Retrieves the default layout that is used when windows are created with no parent or owner.
GetProcessWindowStation
Retrieves a handle to the current window station for the calling process.
GetPropA
Retrieves a data handle from the property list of the specified window. The character string
identifies the handle to be retrieved. The string and handle must have been added to the property
list by a previous call to the SetProp function. (ANSI)
GetPropW
Retrieves a data handle from the property list of the specified window. The character string
identifies the handle to be retrieved. The string and handle must have been added to the property
list by a previous call to the SetProp function. (Unicode)
GetQueueStatus
Retrieves the type of messages found in the calling thread's message queue.
GetRawInputBuffer
GetRawInputData
GetRawInputDeviceInfoA
GetRawInputDeviceInfoW
GetRawInputDeviceList
GetRegisteredRawInputDevices
Retrieves the information about the raw input devices for the current application.
GetScrollBarInfo
The GetScrollBarInfo function retrieves information about the specified scroll bar.
GetScrollInfo
The GetScrollInfo function retrieves the parameters of a scroll bar, including the minimum and
maximum scrolling positions, the page size, and the position of the scroll box (thumb).
GetScrollPos
The GetScrollPos function retrieves the current position of the scroll box (thumb) in the specified
scroll bar.
GetScrollRange
The GetScrollRange function retrieves the current minimum and maximum scroll box (thumb)
positions for the specified scroll bar.
GetShellWindow
GetSubMenu
Retrieves a handle to the drop-down menu or submenu activated by the specified menu item.
GetSysColor
GetSysColorBrush
The GetSysColorBrush function retrieves a handle identifying a logical brush that corresponds to
the specified color index.
GetSystemDpiForProcess
Retrieves the system DPI associated with a given process. This is useful for avoiding compatibility
issues that arise from sharing DPI-sensitive information between multiple system-aware processes
with different system DPI values.
GetSystemMenu
Enables the application to access the window menu (also known as the system menu or the
control menu) for copying and modifying.
GetSystemMetrics
GetSystemMetricsForDpi
Retrieves the specified system metric or system configuration setting taking into account a
provided DPI.
GetTabbedTextExtentA
The GetTabbedTextExtent function computes the width and height of a character string. (ANSI)
GetTabbedTextExtentW
The GetTabbedTextExtent function computes the width and height of a character string. (Unicode)
GetThreadDesktop
GetThreadDpiAwarenessContext
GetThreadDpiHostingBehavior
GetTitleBarInfo
GetTopWindow
Examines the Z order of the child windows associated with the specified parent window and
retrieves a handle to the child window at the top of the Z order.
GetTouchInputInfo
Retrieves detailed information about touch inputs associated with a particular touch input handle.
GetUnpredictedMessagePos
Gets pointer data before it has gone through touch prediction processing.
GetUpdatedClipboardFormats
GetUpdateRect
The GetUpdateRect function retrieves the coordinates of the smallest rectangle that completely
encloses the update region of the specified window.
GetUpdateRgn
The GetUpdateRgn function retrieves the update region of a window by copying it into the
specified region. The coordinates of the update region are relative to the upper-left corner of the
window (that is, they are client coordinates).
GetUserObjectInformationA
Retrieves information about the specified window station or desktop object. (ANSI)
GetUserObjectInformationW
Retrieves information about the specified window station or desktop object. (Unicode)
GetUserObjectSecurity
GetWindow
Retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the
specified window.
GetWindowContextHelpId
Retrieves the Help context identifier, if any, associated with the specified window.
GetWindowDC
The GetWindowDC function retrieves the device context (DC) for the entire window, including title
bar, menus, and scroll bars.
GetWindowDisplayAffinity
Retrieves the current display affinity setting, from any process, for a given window.
GetWindowDpiAwarenessContext
Returns the DPI_AWARENESS_CONTEXT associated with a window.
GetWindowDpiHostingBehavior
GetWindowFeedbackSetting
GetWindowInfo
GetWindowLongA
GetWindowLongPtrA
Retrieves information about the specified window. The function also retrieves the value at a
specified offset into the extra window memory. (ANSI)
GetWindowLongPtrW
Retrieves information about the specified window. The function also retrieves the value at a
specified offset into the extra window memory. (Unicode)
GetWindowLongW
GetWindowModuleFileNameA
Retrieves the full path and file name of the module associated with the specified window handle.
(ANSI)
GetWindowModuleFileNameW
Retrieves the full path and file name of the module associated with the specified window handle.
(Unicode)
GetWindowPlacement
Retrieves the show state and the restored, minimized, and maximized positions of the specified
window.
GetWindowRect
Retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are
given in screen coordinates that are relative to the upper-left corner of the screen.
GetWindowRgn
GetWindowRgnBox
The GetWindowRgnBox function retrieves the dimensions of the tightest bounding rectangle for
the window region of a window.
GetWindowTextA
Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified
window is a control, the text of the control is copied. However, GetWindowText cannot retrieve
the text of a control in another application. (ANSI)
GetWindowTextLengthA
Retrieves the length, in characters, of the specified window's title bar text (if the window has a title
bar). (ANSI)
GetWindowTextLengthW
Retrieves the length, in characters, of the specified window's title bar text (if the window has a title
bar). (Unicode)
GetWindowTextW
Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified
window is a control, the text of the control is copied. However, GetWindowText cannot retrieve
the text of a control in another application. (Unicode)
GetWindowThreadProcessId
Retrieves the identifier of the thread that created the specified window and, optionally, the
identifier of the process that created the window.
GetWindowWord
Retrieves the 16-bit (DWORD) value at the specified offset into the extra window memor
GID_ROTATE_ANGLE_FROM_ARGUMENT
GID_ROTATE_ANGLE_TO_ARGUMENT
Converts a radian value to an argument for rotation gesture messages.
GrayStringA
The GrayString function draws gray text at the specified location. (ANSI)
GrayStringW
The GrayString function draws gray text at the specified location. (Unicode)
HAS_POINTER_CONFIDENCE_WPARAM
Checks whether the specified pointer message is considered intentional rather than accidental.
HideCaret
Removes the caret from the screen. Hiding a caret does not destroy its current shape or invalidate
the insertion point.
HiliteMenuItem
InflateRect
The InflateRect function increases or decreases the width and height of the specified rectangle.
InheritWindowMonitor
InitializeTouchInjection
Configures the touch injection context for the calling application and initializes the maximum
number of simultaneous contacts that the app can inject.
InjectSyntheticPointerInput
InjectTouchInput
InSendMessage
Determines whether the current window procedure is processing a message that was sent from
another thread (in the same process or a different process) by a call to the SendMessage function.
InSendMessageEx
Determines whether the current window procedure is processing a message that was sent from
another thread (in the same process or a different process).
InsertMenuA
Inserts a new menu item into a menu, moving other items down the menu. (ANSI)
InsertMenuItemA
InsertMenuItemW
InsertMenuW
Inserts a new menu item into a menu, moving other items down the menu. (Unicode)
InternalGetWindowText
Copies the text of the specified window's title bar (if it has one) into a buffer.
IntersectRect
The IntersectRect function calculates the intersection of two source rectangles and places the
coordinates of the intersection rectangle into the destination rectangle.
InvalidateRect
The InvalidateRect function adds a rectangle to the specified window's update region. The update
region represents the portion of the window's client area that must be redrawn.
InvalidateRgn
The InvalidateRgn function invalidates the client area within the specified region by adding it to
the current update region of a window.
InvertRect
The InvertRect function inverts a rectangle in a window by performing a logical NOT operation on
the color values for each pixel in the rectangle's interior.
IS_INTRESOURCE
Checks whether the specified pointer input ended abruptly, or was invalid, indicating the
interaction was not completed.
IS_POINTER_FIFTHBUTTON_WPARAM
IS_POINTER_FIRSTBUTTON_WPARAM
IS_POINTER_FLAG_SET_WPARAM
IS_POINTER_FOURTHBUTTON_WPARAM
IS_POINTER_INCONTACT_WPARAM
IS_POINTER_INRANGE_WPARAM
IS_POINTER_NEW_WPARAM
IS_POINTER_SECONDBUTTON_WPARAM
IS_POINTER_THIRDBUTTON_WPARAM
IsCharAlphaA
IsCharAlphaNumericA
IsCharAlphaNumericW
IsCharAlphaW
IsCharLowerA
Determines whether a character is lowercase. This determination is based on the semantics of the
language selected by the user during setup or through Control Panel.
IsCharLowerW
IsCharUpperA
Determines whether a character is uppercase. This determination is based on the semantics of the
language selected by the user during setup or through Control Panel. (ANSI)
IsCharUpperW
Determines whether a character is uppercase. This determination is based on the semantics of the
language selected by the user during setup or through Control Panel. (Unicode)
IsChild
IsClipboardFormatAvailable
IsDialogMessageA
Determines whether a message is intended for the specified dialog box and, if it is, processes the
message. (ANSI)
IsDialogMessageW
Determines whether a message is intended for the specified dialog box and, if it is, processes the
message. (Unicode)
IsDlgButtonChecked
IsGUIThread
Determines whether the calling thread is already a GUI thread. It can also optionally convert the
thread to a GUI thread.
IsHungAppWindow
Determines whether the system considers that a specified application is not responding.
IsIconic
IsImmersiveProcess
IsMenu
IsMouseInPointerEnabled
Indicates whether EnableMouseInPointer is set for the mouse to act as a pointer input device and
send WM_POINTER messages.
IsProcessDPIAware
IsRectEmpty
IsTouchWindow
Checks whether a specified window is touch-capable and, optionally, retrieves the modifier flags
set for the window's touch capability.
IsValidDpiAwarenessContext
Determines if a specified DPI_AWARENESS_CONTEXT is valid and supported by the current
system.
IsWindow
IsWindowArranged
Determines whether the specified window is arranged (that is, whether it's snapped).
IsWindowEnabled
Determines whether the specified window is enabled for mouse and keyboard input.
IsWindowUnicode
IsWindowVisible
IsWinEventHookInstalled
Determines whether there is an installed WinEvent hook that might be notified of a specified
event.
IsWow64Message
Determines whether the last message read from the current thread's queue originated from a
WOW64 process.
IsZoomed
keybd_event
Synthesizes a keystroke.
KillTimer
LoadAcceleratorsA
LoadBitmapA
The LoadBitmap function loads the specified bitmap resource from a module's executable file.
(ANSI)
LoadBitmapW
The LoadBitmap function loads the specified bitmap resource from a module's executable file.
(Unicode)
LoadCursorA
Loads the specified cursor resource from the executable (.EXE) file associated with an application
instance. (ANSI)
LoadCursorFromFileA
LoadCursorFromFileW
LoadCursorW
Loads the specified cursor resource from the executable (.EXE) file associated with an application
instance. (Unicode)
LoadIconA
Loads the specified icon resource from the executable (.exe) file associated with an application
instance. (ANSI)
LoadIconW
Loads the specified icon resource from the executable (.exe) file associated with an application
instance. (Unicode)
LoadImageA
LoadImageW
Loads a new input locale identifier (formerly called the keyboard layout) into the system. (ANSI)
LoadKeyboardLayoutW
Loads a new input locale identifier (formerly called the keyboard layout) into the system.
(Unicode)
LoadMenuA
Loads the specified menu resource from the executable (.exe) file associated with an application
instance. (ANSI)
LoadMenuIndirectA
LoadMenuIndirectW
LoadMenuW
Loads the specified menu resource from the executable (.exe) file associated with an application
instance. (Unicode)
LoadStringA
Loads a string resource from the executable file associated with a specified module, copies the
string into a buffer, and appends a terminating null character. (ANSI)
LoadStringW
Loads a string resource from the executable file associated with a specified module, copies the
string into a buffer, and appends a terminating null character. (Unicode)
LockSetForegroundWindow
The foreground process can call the LockSetForegroundWindow function to disable calls to the
SetForegroundWindow function.
LockWindowUpdate
The LockWindowUpdate function disables or enables drawing in the specified window. Only one
window can be locked at a time.
LockWorkStation
Locks the workstation's display.
LogicalToPhysicalPoint
LogicalToPhysicalPointForPerMonitorDPI
Converts a point in a window from logical coordinates into physical coordinates, regardless of the
dots per inch (dpi) awareness of the caller.
LookupIconIdFromDirectory
Searches through icon or cursor data for the icon or cursor that best fits the current display
device. (LookupIconIdFromDirectory)
LookupIconIdFromDirectoryEx
Searches through icon or cursor data for the icon or cursor that best fits the current display
device. (LookupIconIdFromDirectoryEx)
MAKEINTRESOURCEA
MAKEINTRESOURCEW
MAKELPARAM
Creates a value for use as an lParam parameter in a message. The macro concatenates the
specified values.
MAKELRESULT
Creates a value for use as a return value from a window procedure. The macro concatenates the
specified values.
MAKEWPARAM
Creates a value for use as a wParam parameter in a message. The macro concatenates the
specified values.
MapDialogRect
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code
into a virtual-key code. (ANSI)
MapVirtualKeyExA
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code
into a virtual-key code. The function translates the codes using the input language and an input
locale identifier. (ANSI)
MapVirtualKeyExW
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code
into a virtual-key code. The function translates the codes using the input language and an input
locale identifier. (Unicode)
MapVirtualKeyW
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code
into a virtual-key code. (Unicode)
MapWindowPoints
The MapWindowPoints function converts (maps) a set of points from a coordinate space relative
to one window to a coordinate space relative to another window.
MenuItemFromPoint
MessageBeep
Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the
registry.
MessageBox
The MessageBox function displays a modal dialog box that contains a system icon, a set of
buttons, and a brief application-specific message.
MessageBoxA
Displays a modal dialog box that contains a system icon, a set of buttons, and a brief application-
specific message, such as status or error information. The message box returns an integer value
that indicates which button the user clicked. (MessageBoxA)
MessageBoxExA
Creates, displays, and operates a message box. (ANSI)
MessageBoxExW
MessageBoxIndirectA
Creates, displays, and operates a message box. The message box contains application-defined
message text and title, any icon, and any combination of predefined push buttons. (ANSI)
MessageBoxIndirectW
Creates, displays, and operates a message box. The message box contains application-defined
message text and title, any icon, and any combination of predefined push buttons. (Unicode)
MessageBoxW
The MessageBoxW (Unicode) function displays a modal dialog box that contains a system icon, a
set of buttons, and a brief application-specific message.
ModifyMenuA
ModifyMenuW
MonitorFromPoint
The MonitorFromPoint function retrieves a handle to the display monitor that contains a specified
point.
MonitorFromRect
The MonitorFromRect function retrieves a handle to the display monitor that has the largest area
of intersection with a specified rectangle.
MonitorFromWindow
The MonitorFromWindow function retrieves a handle to the display monitor that has the largest
area of intersection with the bounding rectangle of a specified window.
mouse_event
MoveWindow
Changes the position and dimensions of the specified window.
MsgWaitForMultipleObjects
Waits until one or all of the specified objects are in the signaled state or the time-out interval
elapses. The objects can include input event objects.
MsgWaitForMultipleObjectsEx
Waits until one or all of the specified objects are in the signaled state, an I/O completion routine
or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
The array of objects can include input event objects.
NEXTRAWINPUTBLOCK
NotifyWinEvent
Signals the system that a predefined event occurred. If any client applications have registered a
hook function for the event, the system calls the client's hook function.
OemKeyScan
Maps OEMASCII codes 0 through 0x0FF into the OEM scan codes and shift states. The function
provides information that allows a program to send OEM text to another program by simulating
keyboard input.
OemToCharA
Translates a string from the OEM-defined character set into either an ANSI or a wide-character
string.Warning Do not use. (ANSI)
OemToCharBuffA
Translates a specified number of characters in a string from the OEM-defined character set into
either an ANSI or a wide-character string. (ANSI)
OemToCharBuffW
Translates a specified number of characters in a string from the OEM-defined character set into
either an ANSI or a wide-character string. (Unicode)
OemToCharW
Translates a string from the OEM-defined character set into either an ANSI or a wide-character
string.Warning Do not use. (Unicode)
OffsetRect
The OffsetRect function moves the specified rectangle by the specified offsets.
OpenClipboard
Opens the clipboard for examination and prevents other applications from modifying the
clipboard content.
OpenDesktopA
OpenDesktopW
OpenIcon
Restores a minimized (iconic) window to its previous size and position; it then activates the
window.
OpenInputDesktop
OpenWindowStationA
OpenWindowStationW
PackTouchHitTestingProximityEvaluation
Returns the proximity evaluation score and the adjusted touch-point coordinates as a packed
value for the WM_TOUCHHITTESTING callback.
PaintDesktop
The PaintDesktop function fills the clipping region in the specified device context with the desktop
pattern or wallpaper. The function is provided primarily for shell desktops.
PeekMessageA
Dispatches incoming nonqueued messages, checks the thread message queue for a posted
message, and retrieves the message (if any exist). (ANSI)
PeekMessageW
Dispatches incoming nonqueued messages, checks the thread message queue for a posted
message, and retrieves the message (if any exist). (Unicode)
PhysicalToLogicalPoint
PhysicalToLogicalPointForPerMonitorDPI
Converts a point in a window from physical coordinates into logical coordinates, regardless of the
dots per inch (dpi) awareness of the caller.
POINTSTOPOINT
The POINTSTOPOINT macro copies the contents of a POINTS structure into a POINT structure.
POINTTOPOINTS
PostMessageA
Places (posts) a message in the message queue associated with the thread that created the
specified window and returns without waiting for the thread to process the message. (ANSI)
PostMessageW
Places (posts) a message in the message queue associated with the thread that created the
specified window and returns without waiting for the thread to process the message. (Unicode)
PostQuitMessage
Indicates to the system that a thread has made a request to terminate (quit). It is typically used in
response to a WM_DESTROY message.
PostThreadMessageA
Posts a message to the message queue of the specified thread. It returns without waiting for the
thread to process the message. (ANSI)
PostThreadMessageW
Posts a message to the message queue of the specified thread. It returns without waiting for the
thread to process the message. (Unicode)
PrintWindow
The PrintWindow function copies a visual window into the specified device context (DC), typically
a printer DC.
PrivateExtractIconsA
Creates an array of handles to icons that are extracted from a specified file. (ANSI)
PrivateExtractIconsW
Creates an array of handles to icons that are extracted from a specified file. (Unicode)
PtInRect
The PtInRect function determines whether the specified point lies within the specified rectangle.
QueryDisplayConfig
The QueryDisplayConfig function retrieves information about all possible display paths for all
display devices, or views, in the current setting.
RealChildWindowFromPoint
Retrieves a handle to the child window at the specified point. The search is restricted to
immediate child windows; grandchildren and deeper descendant windows are not searched.
RealGetWindowClassA
RealGetWindowClassW
RedrawWindow
The RedrawWindow function updates the specified rectangle or region in a window's client area.
RegisterClassA
Registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx
function. (RegisterClassA)
RegisterClassExA
Registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx
function. (RegisterClassExA)
RegisterClassExW
Registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx
function. (RegisterClassExW)
RegisterClassW
Registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx
function. (RegisterClassW)
RegisterClipboardFormatA
Registers a new clipboard format. This format can then be used as a valid clipboard format. (ANSI)
RegisterClipboardFormatW
Registers a new clipboard format. This format can then be used as a valid clipboard format.
(Unicode)
RegisterDeviceNotificationA
Registers the device or type of device for which a window will receive notifications. (ANSI)
RegisterDeviceNotificationW
Registers the device or type of device for which a window will receive notifications. (Unicode)
RegisterForTooltipDismissNotification
Lets apps or UI frameworks register and unregister windows to receive notification to dismiss their
tooltip windows.
RegisterHotKey
RegisterPointerDeviceNotifications
RegisterPointerInputTarget
Allows the caller to register a target window to which all pointer input of the specified type is
redirected.
RegisterPointerInputTargetEx
RegisterPowerSettingNotification
Registers the application to receive power setting notifications for the specific power setting
event.
RegisterRawInputDevices
RegisterShellHookWindow
Registers a specified Shell window to receive certain messages for events or notifications that are
useful to Shell applications.
RegisterSuspendResumeNotification
RegisterTouchHitTestingWindow
RegisterTouchWindow
RegisterWindowMessageA
Defines a new window message that is guaranteed to be unique throughout the system. The
message value can be used when sending or posting messages. (ANSI)
RegisterWindowMessageW
Defines a new window message that is guaranteed to be unique throughout the system. The
message value can be used when sending or posting messages. (Unicode)
ReleaseCapture
Releases the mouse capture from a window in the current thread and restores normal mouse
input processing.
ReleaseDC
The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The
effect of the ReleaseDC function depends on the type of DC. It frees only common and window
DCs. It has no effect on class or private DCs.
RemoveClipboardFormatListener
Removes the given window from the system-maintained clipboard format listener list.
RemoveMenu
RemovePropA
Removes an entry from the property list of the specified window. The specified character string
identifies the entry to be removed. (ANSI)
RemovePropW
Removes an entry from the property list of the specified window. The specified character string
identifies the entry to be removed. (Unicode)
ReplyMessage
ScreenToClient
The ScreenToClient function converts the screen coordinates of a specified point on the screen to
client-area coordinates.
ScrollDC
ScrollWindow
The ScrollWindow function scrolls the contents of the specified window's client area.
ScrollWindowEx
The ScrollWindowEx function scrolls the contents of the specified window's client area.
SendDlgItemMessageA
SendDlgItemMessageW
SendInput
The SendMessage function sends the specified message to a window or windows. (SendMessage
function)
SendMessageA
Sends the specified message to a window or windows. The SendMessage function calls the
window procedure for the specified window and does not return until the window procedure has
processed the message. (SendMessageA)
SendMessageCallbackA
SendMessageCallbackW
SendMessageTimeoutA
SendMessageTimeoutW
SendMessageW
The SendMessageW (Unicode) function sends the specified message to a window or windows.
(SendMessageW)
SendNotifyMessageA
SendNotifyMessageW
SetActiveWindow
Activates a window. The window must be attached to the calling thread's message queue.
SetAdditionalForegroundBoostProcesses
Sets the mouse capture to the specified window belonging to the current thread.
SetCaretBlinkTime
Sets the caret blink time to the specified number of milliseconds. The blink time is the elapsed
time, in milliseconds, required to invert the caret's pixels.
SetCaretPos
Moves the caret to the specified coordinates. If the window that owns the caret was created with
the CS_OWNDC class style, then the specified coordinates are subject to the mapping mode of
the device context associated with that window.
SetClassLongA
Replaces the specified 32-bit (long) value at the specified offset into the extra class memory or the
WNDCLASSEX structure for the class to which the specified window belongs. (ANSI)
SetClassLongPtrA
Replaces the specified value at the specified offset in the extra class memory or the WNDCLASSEX
structure for the class to which the specified window belongs. (ANSI)
SetClassLongPtrW
Replaces the specified value at the specified offset in the extra class memory or the WNDCLASSEX
structure for the class to which the specified window belongs. (Unicode)
SetClassLongW
Replaces the specified 32-bit (long) value at the specified offset into the extra class memory or the
WNDCLASSEX structure for the class to which the specified window belongs. (Unicode)
SetClassWord
Replaces the 16-bit (WORD) value at the specified offset into the extra class memory for the
window class to which the specified window belongs.
SetClipboardData
SetClipboardViewer
Adds the specified window to the chain of clipboard viewers. Clipboard viewer windows receive a
WM_DRAWCLIPBOARD message whenever the content of the clipboard changes. This function is
used for backward compatibility with earlier versions of Windows.
SetCoalescableTimer
Creates a timer with the specified time-out value and coalescing tolerance delay.
SetCursor
SetCursorPos
SetDialogControlDpiChangeBehavior
Overrides the default per-monitor DPI scaling behavior of a child window in a dialog.
SetDialogDpiChangeBehavior
Dialogs in Per-Monitor v2 contexts are automatically DPI scaled. This method lets you customize
their DPI change behavior.
SetDisplayAutoRotationPreferences
SetDisplayConfig
The SetDisplayConfig function modifies the display topology, source, and target modes by
exclusively enabling the specified paths in the current session.
SetDlgItemInt
Sets the text of a control in a dialog box to the string representation of a specified integer value.
SetDlgItemTextA
SetDlgItemTextW
SetDoubleClickTime
SetFocus
Sets the keyboard focus to the specified window. The window must be attached to the calling
thread's message queue.
SetForegroundWindow
Brings the thread that created the specified window into the foreground and activates the
window.
SetGestureConfig
Configures the messages that are sent from a window for Windows Touch gestures.
SetKeyboardState
Copies an array of keyboard key states into the calling thread's keyboard input-state table. This is
the same table accessed by the GetKeyboardState and GetKeyState functions. Changes made to
this table do not affect keyboard input to any other thread.
SetLastErrorEx
SetLayeredWindowAttributes
SetMenu
SetMenuContextHelpId
SetMenuDefaultItem
SetMenuInfo
SetMenuItemBitmaps
Associates the specified bitmap with a menu item. Whether the menu item is selected or clear, the
system displays the appropriate bitmap next to the menu item.
SetMenuItemInfoA
Changes information about a menu item. (ANSI)
SetMenuItemInfoW
SetMessageExtraInfo
SetParent
SetPhysicalCursorPos
SetProcessDefaultLayout
Changes the default layout when windows are created with no parent or owner only for the
currently running process.
SetProcessDPIAware
SetProcessDpiAwarenessContext
Sets the current process to a specified dots per inch (dpi) awareness context. The DPI awareness
contexts are from the DPI_AWARENESS_CONTEXT value.
SetProcessRestrictionExemption
Exempts the calling process from restrictions preventing desktop processes from interacting with
the Windows Store app environment. This function is used by development and debugging tools.
SetProcessWindowStation
SetPropA
Adds a new entry or changes an existing entry in the property list of the specified window. (ANSI)
SetPropW
Adds a new entry or changes an existing entry in the property list of the specified window.
(Unicode)
SetRect
The SetRect function sets the coordinates of the specified rectangle. This is equivalent to
assigning the left, top, right, and bottom arguments to the appropriate members of the RECT
structure.
SetRectEmpty
The SetRectEmpty function creates an empty rectangle in which all coordinates are set to zero.
SetScrollInfo
The SetScrollInfo function sets the parameters of a scroll bar, including the minimum and
maximum scrolling positions, the page size, and the position of the scroll box (thumb). The
function also redraws the scroll bar, if requested.
SetScrollPos
The SetScrollPos function sets the position of the scroll box (thumb) in the specified scroll bar and,
if requested, redraws the scroll bar to reflect the new position of the scroll box.
SetScrollRange
The SetScrollRange function sets the minimum and maximum scroll box positions for the specified
scroll bar.
SetSysColors
SetSystemCursor
Enables an application to customize the system cursors. It replaces the contents of the system
cursor specified by the id parameter with the contents of the cursor specified by the hcur
parameter and then destroys hcur.
SetThreadCursorCreationScaling
Sets the DPI scale for which the cursors being created on this thread are intended. This value is
taken into account when scaling the cursor for the specific monitor on which it is being shown.
SetThreadDesktop
Assigns the specified desktop to the calling thread. All subsequent operations on the desktop use
the access rights granted to the desktop.
SetThreadDpiAwarenessContext
Set the DPI awareness for the current thread to the provided value.
SetThreadDpiHostingBehavior
Sets the thread's DPI_HOSTING_BEHAVIOR. This behavior allows windows created in the thread to
host child windows with a different DPI_AWARENESS_CONTEXT.
SetTimer
SetUserObjectInformationA
Sets information about the specified window station or desktop object. (ANSI)
SetUserObjectInformationW
Sets information about the specified window station or desktop object. (Unicode)
SetUserObjectSecurity
Sets the security of a user object. This can be, for example, a window or a DDE conversation.
SetWindowContextHelpId
SetWindowDisplayAffinity
Stores the display affinity setting in kernel mode on the hWnd associated with the window.
SetWindowFeedbackSetting
SetWindowLongA
Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the
specified offset into the extra window memory. (ANSI)
SetWindowLongPtrA
SetWindowLongPtrW
SetWindowLongW
Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the
specified offset into the extra window memory. (Unicode)
SetWindowPlacement
Sets the show state and the restored, minimized, and maximized positions of the specified
window.
SetWindowPos
Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows
are ordered according to their appearance on the screen. The topmost window receives the
highest rank and is the first window in the Z order.
SetWindowRgn
SetWindowsHookExA
SetWindowsHookExW
SetWindowTextA
Changes the text of the specified window's title bar (if it has one). If the specified window is a
control, the text of the control is changed. However, SetWindowText cannot change the text of a
control in another application. (ANSI)
SetWindowTextW
Changes the text of the specified window's title bar (if it has one). If the specified window is a
control, the text of the control is changed. However, SetWindowText cannot change the text of a
control in another application. (Unicode)
SetWinEventHook
ShowCaret
Makes the caret visible on the screen at the caret's current position. When the caret becomes
visible, it begins flashing automatically.
ShowCursor
Displays or hides the cursor. (ShowCursor)
ShowOwnedPopups
ShowScrollBar
ShowWindow
ShowWindowAsync
Sets the show state of a window without waiting for the operation to complete.
ShutdownBlockReasonCreate
Indicates that the system cannot be shut down and sets a reason string to be displayed to the
user if system shutdown is initiated.
ShutdownBlockReasonDestroy
Indicates that the system can be shut down and frees the reason string.
ShutdownBlockReasonQuery
SkipPointerFrameMessages
Determines which pointer input frame generated the most recently retrieved message for the
specified pointer and discards any queued (unretrieved) pointer input messages generated from
the same pointer input frame.
SoundSentry
SubtractRect
The SubtractRect function determines the coordinates of a rectangle formed by subtracting one
rectangle from another.
SwapMouseButton
Reverses or restores the meaning of the left and right mouse buttons.
SwitchDesktop
Makes the specified desktop visible and activates it. This enables the desktop to receive input
from the user.
SwitchToThisWindow
SystemParametersInfoA
SystemParametersInfoForDpi
Retrieves the value of one of the system-wide parameters, taking into account the provided DPI
value.
SystemParametersInfoW
TabbedTextOutA
The TabbedTextOut function writes a character string at a specified location, expanding tabs to the
values specified in an array of tab-stop positions. Text is written in the currently selected font,
background color, and text color. (ANSI)
TabbedTextOutW
The TabbedTextOut function writes a character string at a specified location, expanding tabs to the
values specified in an array of tab-stop positions. Text is written in the currently selected font,
background color, and text color. (Unicode)
TileWindows
ToAscii
Translates the specified virtual-key code and keyboard state to the corresponding character or
characters.
ToAsciiEx
Translates the specified virtual-key code and keyboard state to the corresponding character or
characters. The function translates the code using the input language and physical keyboard
layout identified by the input locale identifier.
TOUCH_COORD_TO_PIXEL
ToUnicode
Translates the specified virtual-key code and keyboard state to the corresponding Unicode
character or characters. (ToUnicode)
ToUnicodeEx
Translates the specified virtual-key code and keyboard state to the corresponding Unicode
character or characters. (ToUnicodeEx)
TrackMouseEvent
Posts messages when the mouse pointer leaves a window or hovers over a window for a specified
amount of time.
TrackPopupMenu
Displays a shortcut menu at the specified location and tracks the selection of items on the menu.
The shortcut menu can appear anywhere on the screen.
TrackPopupMenuEx
Displays a shortcut menu at the specified location and tracks the selection of items on the
shortcut menu. The shortcut menu can appear anywhere on the screen.
TranslateAcceleratorA
TranslateAcceleratorW
TranslateMDISysAccel
Processes accelerator keystrokes for window menu commands of the multiple-document interface
(MDI) child windows associated with the specified MDI client window.
TranslateMessage
Translates virtual-key messages into character messages. The character messages are posted to
the calling thread's message queue, to be read the next time the thread calls the GetMessage or
PeekMessage function.
UnhookWindowsHookEx
UnhookWinEvent
UnionRect
The UnionRect function creates the union of two rectangles. The union is the smallest rectangle
that contains both source rectangles.
UnloadKeyboardLayout
UnregisterClassA
Unregisters a window class, freeing the memory required for the class. (ANSI)
UnregisterClassW
Unregisters a window class, freeing the memory required for the class. (Unicode)
UnregisterDeviceNotification
UnregisterHotKey
UnregisterPointerInputTarget
Allows the caller to unregister a target window to which all pointer input of the specified type is
redirected.
UnregisterPointerInputTargetEx
UnregisterPowerSettingNotification
UnregisterSuspendResumeNotification
Cancels a registration to receive notification when the system is suspended or resumed. Similar to
PowerUnregisterSuspendResumeNotification but operates in user mode.
UnregisterTouchWindow
UpdateLayeredWindow
Updates the position, size, shape, content, and translucency of a layered window.
UpdateWindow
The UpdateWindow function updates the client area of the specified window by sending a
WM_PAINT message to the window if the window's update region is not empty.
UserHandleGrantAccess
Grants or denies access to a handle to a User object to a job that has a user-interface restriction.
ValidateRect
The ValidateRect function validates the client area within a rectangle by removing the rectangle
from the update region of the specified window.
ValidateRgn
The ValidateRgn function validates the client area within a region by removing the region from the
current update region of the specified window.
VkKeyScanA
Translates a character to the corresponding virtual-key code and shift state for the current
keyboard. (ANSI)
VkKeyScanExA
Translates a character to the corresponding virtual-key code and shift state. The function
translates the character using the input language and physical keyboard layout identified by the
input locale identifier. (ANSI)
VkKeyScanExW
Translates a character to the corresponding virtual-key code and shift state. The function
translates the character using the input language and physical keyboard layout identified by the
input locale identifier. (Unicode)
VkKeyScanW
Translates a character to the corresponding virtual-key code and shift state for the current
keyboard. (Unicode)
WaitForInputIdle
Waits until the specified process has finished processing its initial input and is waiting for user
input with no input pending, or until the time-out interval has elapsed.
WaitMessage
Yields control to other threads when a thread has no other messages in its message queue. The
WaitMessage function suspends the thread and does not return until a new message is placed in
the thread's message queue.
WindowFromDC
The WindowFromDC function returns a handle to the window associated with the specified
display device context (DC). Output functions that use the specified device context draw into this
window.
WindowFromPhysicalPoint
Retrieves a handle to the window that contains the specified physical point.
WindowFromPoint
WinHelpA
Launches Windows Help (Winhelp.exe) and passes additional data that indicates the nature of the
help requested by the application. (ANSI)
WinHelpW
Launches Windows Help (Winhelp.exe) and passes additional data that indicates the nature of the
help requested by the application. (Unicode)
wsprintfA
wsprintfW
wvsprintfA
Writes formatted data to the specified buffer using a pointer to a list of arguments. (ANSI)
wvsprintfW
Writes formatted data to the specified buffer using a pointer to a list of arguments. (Unicode)
Callback functions
DLGPROC
Application-defined callback function used with the CreateDialog and DialogBox families of
functions.
DRAWSTATEPROC
EDITWORDBREAKPROCA
EDITWORDBREAKPROCW
GRAYSTRINGPROC
The OutputProc function is an application-defined callback function used with the GrayString
function.
HOOKPROC
MONITORENUMPROC
MSGBOXCALLBACK
A callback function, which you define in your application, that processes help events for the
message box.
PROPENUMPROCA
PROPENUMPROCEXA
PROPENUMPROCEXW
PROPENUMPROCW
SENDASYNCPROC
TIMERPROC
WINEVENTPROC
An application-defined callback (or hook) function that the system calls in response to events
generated by an accessible object.
WNDPROC
A callback function, which you define in your application, that processes messages sent to a
window.
Structures
ACCEL
Contains information about the time-out period associated with the accessibility features.
ALTTABINFO
ANIMATIONINFO
AUDIODESCRIPTION
Contains information associated with audio descriptions. This structure is used with the
SystemParametersInfo function when the SPI_GETAUDIODESCRIPTION or
SPI_SETAUDIODESCRIPTION action value is specified.
BSMINFO
CBT_CREATEWNDA
Contains information passed to a WH_CBT hook procedure, CBTProc, before a window is created.
(ANSI)
CBT_CREATEWNDW
Contains information passed to a WH_CBT hook procedure, CBTProc, before a window is created.
(Unicode)
CBTACTIVATESTRUCT
CHANGEFILTERSTRUCT
CLIENTCREATESTRUCT
Contains information about the menu and first multiple-document interface (MDI) child window
of an MDI client window.
COMBOBOXINFO
Contains combo box status information.
COMPAREITEMSTRUCT
Supplies the identifiers and application-supplied data for two items in a sorted, owner-drawn list
box or combo box.
COPYDATASTRUCT
CREATESTRUCTA
Defines the initialization parameters passed to the window procedure of an application. These
members are identical to the parameters of the CreateWindowEx function. (ANSI)
CREATESTRUCTW
Defines the initialization parameters passed to the window procedure of an application. These
members are identical to the parameters of the CreateWindowEx function. (Unicode)
CURSORINFO
CURSORSHAPE
CWPRETSTRUCT
CWPSTRUCT
DEBUGHOOKINFO
DELETEITEMSTRUCT
DLGITEMTEMPLATE
Defines the dimensions and style of a control in a dialog box. One or more of these structures are
combined with a DLGTEMPLATE structure to form a standard template for a dialog box.
DLGTEMPLATE
DRAWITEMSTRUCT
Provides information that the owner window uses to determine how to paint an owner-drawn
control or menu item.
DRAWTEXTPARAMS
The DRAWTEXTPARAMS structure contains extended formatting options for the DrawTextEx
function.
EVENTMSG
Contains information about a hardware message sent to the system message queue. This
structure is used to store message information for the JournalPlaybackProc callback function.
FILTERKEYS
Contains information about the FilterKeys accessibility feature, which enables a user with
disabilities to set the keyboard repeat rate (RepeatKeys), acceptance delay (SlowKeys), and bounce
rate (BounceKeys).
FLASHWINFO
Contains the flash status for a window and the number of times the system should flash the
window.
GESTURECONFIG
Gets and sets the configuration for enabling gesture messages and the type of this configuration.
GESTUREINFO
GESTURENOTIFYSTRUCT
GUITHREADINFO
Contains information about a simulated message generated by an input device other than a
keyboard or mouse.
HELPINFO
Contains information about an item for which context-sensitive help has been requested.
HELPWININFOA
Contains the size and position of either a primary or secondary Help window. An application can
set this information by calling the WinHelp function with the HELP_SETWINPOS value. (ANSI)
HELPWININFOW
Contains the size and position of either a primary or secondary Help window. An application can
set this information by calling the WinHelp function with the HELP_SETWINPOS value. (Unicode)
HIGHCONTRASTA
HIGHCONTRASTW
ICONINFO
ICONINFOEXA
Contains information about an icon or a cursor. Extends ICONINFO. Used by GetIconInfoEx. (ANSI)
ICONINFOEXW
ICONMETRICSA
Contains the scalable metrics associated with icons. This structure is used with the
SystemParametersInfo function when the SPI_GETICONMETRICS or SPI_SETICONMETRICS action is
specified. (ANSI)
ICONMETRICSW
Contains the scalable metrics associated with icons. This structure is used with the
SystemParametersInfo function when the SPI_GETICONMETRICS or SPI_SETICONMETRICS action is
specified. (Unicode)
INPUT
Used by SendInput to store information for synthesizing input events such as keystrokes, mouse
movement, and mouse clicks.
INPUT_INJECTION_VALUE
INPUT_MESSAGE_SOURCE
INPUT_TRANSFORM
KBDLLHOOKSTRUCT
KEYBDINPUT
LASTINPUTINFO
MDICREATESTRUCTA
Contains information about the class, title, owner, location, and size of a multiple-document
interface (MDI) child window. (ANSI)
MDICREATESTRUCTW
Contains information about the class, title, owner, location, and size of a multiple-document
interface (MDI) child window. (Unicode)
MDINEXTMENU
MEASUREITEMSTRUCT
Informs the system of the dimensions of an owner-drawn control or menu item. This allows the
system to process user interaction with the control correctly.
MENUBARINFO
MENUGETOBJECTINFO
Contains information about the menu that the mouse cursor is on.
MENUINFO
MENUITEMINFOA
MENUITEMINFOW
MENUITEMTEMPLATE
MENUITEMTEMPLATEHEADER
Defines the header for a menu template. A complete menu template consists of a header and one
or more menu item lists.
MINIMIZEDMETRICS
MINMAXINFO
Contains information about a window's maximized size and position and its minimum and
maximum tracking size.
MONITORINFO
MONITORINFOEXA
MONITORINFOEXW
MOUSEHOOKSTRUCT
Contains information about a mouse event passed to a WH_MOUSE hook procedure, MouseProc.
MOUSEHOOKSTRUCTEX
Contains information about a mouse event passed to a WH_MOUSE hook procedure, MouseProc.
This is an extension of the MOUSEHOOKSTRUCT structure that includes information about wheel
movement or the use of the X button.
MOUSEINPUT
MOUSEKEYS
MOUSEMOVEPOINT
MSG
MSGBOXPARAMSA
Contains information used to display a message box. The MessageBoxIndirect function uses this
structure. (ANSI)
MSGBOXPARAMSW
Contains information used to display a message box. The MessageBoxIndirect function uses this
structure. (Unicode)
MSLLHOOKSTRUCT
Specifies a keyword to search for and the keyword table to be searched by Windows Help. (ANSI)
MULTIKEYHELPW
Specifies a keyword to search for and the keyword table to be searched by Windows Help.
(Unicode)
NCCALCSIZE_PARAMS
Contains information that an application can use while processing the WM_NCCALCSIZE message
to calculate the size, position, and valid contents of the client area of a window.
NMHDR
The NMHDR structure contains information about a notification message. (NMHDR structure)
NONCLIENTMETRICSA
Contains the scalable metrics associated with the nonclient area of a nonminimized window.
(ANSI)
NONCLIENTMETRICSW
Contains the scalable metrics associated with the nonclient area of a nonminimized window.
(Unicode)
PAINTSTRUCT
The PAINTSTRUCT structure contains information for an application. This information can be used
to paint the client area of a window owned by that application.
POINTER_DEVICE_CURSOR_INFO
POINTER_DEVICE_INFO
Contains information about a pointer device. An array of these structures is returned from the
GetPointerDevices function. A single structure is returned from a call to the GetPointerDevice
function.
POINTER_DEVICE_PROPERTY
Contains pointer-based device properties (Human Interface Device (HID) global items that
correspond to HID usages).
POINTER_INFO
Contains basic pointer information common to all pointer types. Applications can retrieve this
information using the GetPointerInfo, GetPointerFrameInfo, GetPointerInfoHistory and
GetPointerFrameInfoHistory functions.
POINTER_PEN_INFO
POINTER_TOUCH_INFO
POINTER_TYPE_INFO
POWERBROADCAST_SETTING
Sent with a power setting event and contains data about the specific change.
RAWHID
Describes the format of the raw input from a Human Interface Device (HID).
RAWINPUT
RAWINPUTDEVICE
RAWINPUTDEVICELIST
RAWINPUTHEADER
Contains the header information that is part of the raw input data.
RAWKEYBOARD
RAWMOUSE
RID_DEVICE_INFO_HID
Defines the raw input data coming from the specified Human Interface Device (HID).
RID_DEVICE_INFO_KEYBOARD
Defines the raw input data coming from the specified keyboard.
RID_DEVICE_INFO_MOUSE
Defines the raw input data coming from the specified mouse.
SCROLLBARINFO
SCROLLINFO
The SCROLLINFO structure contains scroll bar parameters to be set by the SetScrollInfo function
(or SBM_SETSCROLLINFO message), or retrieved by the GetScrollInfo function (or
SBM_GETSCROLLINFO message).
SERIALKEYSA
Contains information about the SerialKeys accessibility feature, which interprets data from a
communication aid attached to a serial port as commands causing the system to simulate
keyboard and mouse input. (ANSI)
SERIALKEYSW
Contains information about the SerialKeys accessibility feature, which interprets data from a
communication aid attached to a serial port as commands causing the system to simulate
keyboard and mouse input. (Unicode)
SOUNDSENTRYA
Contains information about the SoundSentry accessibility feature. When the SoundSentry feature
is on, the computer displays a visual indication only when a sound is generated. (ANSI)
SOUNDSENTRYW
Contains information about the SoundSentry accessibility feature. When the SoundSentry feature
is on, the computer displays a visual indication only when a sound is generated. (Unicode)
STICKYKEYS
STYLESTRUCT
TITLEBARINFO
TITLEBARINFOEX
Expands on the information described in the TITLEBARINFO structure by including the coordinates
of each element of the title bar.
TOGGLEKEYS
TOUCH_HIT_TESTING_INPUT
Contains information about the touch contact area reported by the touch digitizer.
TOUCH_HIT_TESTING_PROXIMITY_EVALUATION
Contains the hit test score that indicates whether the object is the likely target of the touch
contact area, relative to other objects that intersect the touch contact area.
TOUCHINPUT
TOUCHPREDICTIONPARAMETERS
Contains hardware input details that can be used to predict touch targets and help compensate
for hardware latency when processing touch and gesture input that contains distance and velocity
data.
TPMPARAMS
TRACKMOUSEEVENT
Used by the TrackMouseEvent function to track when the mouse pointer leaves a window or
hovers over a window for a specified amount of time.
UPDATELAYEREDWINDOWINFO
USAGE_PROPERTIES
Contains device properties (Human Interface Device (HID) global items that correspond to HID
usages) for any type of HID input device.
USEROBJECTFLAGS
WINDOWINFO
WINDOWPLACEMENT
WINDOWPOS
WNDCLASSA
Contains the window class attributes that are registered by the RegisterClass function. (ANSI)
WNDCLASSEXA
WNDCLASSEXW
WNDCLASSW
Contains the window class attributes that are registered by the RegisterClass function. (Unicode)
WTSSESSION_NOTIFICATION
Provides information about the session change notification. A service receives this structure in its
HandlerEx function in response to a session change event.
Enumerations
AR_STATE
Indicates the state of screen auto-rotation for the system. For example, whether auto-rotation is
supported, and whether it is enabled by the user.
DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS
Describes per-monitor DPI scaling behavior overrides for child windows within dialogs. The values
in this enumeration are bitfields and can be combined.
DIALOG_DPI_CHANGE_BEHAVIORS
In Per Monitor v2 contexts, dialogs will automatically respond to DPI changes by resizing
themselves and re-computing the positions of their child windows (here referred to as re-
layouting).
FEEDBACK_TYPE
INPUT_MESSAGE_DEVICE_TYPE
INPUT_MESSAGE_ORIGIN_ID
ORIENTATION_PREFERENCE
POINTER_BUTTON_CHANGE_TYPE
POINTER_DEVICE_CURSOR_TYPE
POINTER_DEVICE_TYPE
POINTER_FEEDBACK_MODE
Identifies the visual feedback behaviors available to CreateSyntheticPointerDevice.
tagPOINTER_INPUT_TYPE
TOOLTIP_DISMISS_FLAGS
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template resource. The CreateDialog
macro uses the CreateDialogParam function.
Syntax
C++
void CreateDialogA(
[in, optional] hInstance,
[in] lpName,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpName
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and its low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The CreateDialog function uses the CreateWindowEx function to create the dialog box.
CreateDialog then sends a WM_INITDIALOG message (and a WM_SETFONT message if
the template specifies the DS_SETFONT or DS_SHELLFONT style) to the dialog box
procedure. The function displays the dialog box if the template specifies the WS_VISIBLE
style. Finally, CreateDialog returns the window handle to the dialog box.
After CreateDialog returns, the application displays the dialog box (if it is not already
displayed) by using the ShowWindow function. The application destroys the dialog box
by using the DestroyWindow function. To support keyboard navigation and other dialog
box functionality, the message loop for the dialog box must call the IsDialogMessage
function.
Examples
For an example, see Creating a Modeless Dialog Box.
7 Note
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialogIndirect
CreateDialogIndirectParam
CreateDialogParam
CreateWindowEx
DestroyWindow
Dialog Boxes
DialogBox
DialogProc
IsDialogMessage
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template in memory. The
CreateDialogIndirect macro uses the CreateDialogIndirectParam function.
Syntax
C++
void CreateDialogIndirectA(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
[in] lpTemplate
Type: LPCDLGTEMPLATE
A template that CreateDialogIndirect uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
In an extended dialog box template, the header uses the DLGTEMPLATEEX format and
the control definitions use the DLGITEMTEMPLATEEX format.
After CreateDialogIndirect returns, you can free the template, which is only used to get
the dialog box started.
[in, optional] hWndParent
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The CreateDialogIndirect macro uses the CreateWindowEx function to create the dialog
box. CreateDialogIndirect then sends a WM_INITDIALOG message to the dialog box
procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT style, the
function also sends a WM_SETFONT message to the dialog box procedure. The function
displays the dialog box if the template specifies the WS_VISIBLE style. Finally,
CreateDialogIndirect returns the window handle to the dialog box.
After CreateDialogIndirect returns, you can use the ShowWindow function to display
the dialog box (if it is not already visible). To destroy the dialog box, use the
DestroyWindow function. To support keyboard navigation and other dialog box
functionality, the message loop for the dialog box must call the IsDialogMessage
function.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings. Use the MultiByteToWideChar function to generate
Unicode strings from ANSI strings.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateDialogIndirectParam
CreateDialogParam
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
DestroyWindow
Dialog Boxes
DialogProc
IsDialogMessage
MultiByteToWideChar
Other Resources
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template in memory. Before displaying
the dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
HWND CreateDialogIndirectParamA(
[in, optional] HINSTANCE hInstance,
[in] LPCDLGTEMPLATEA lpTemplate,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplate
Type: LPCDLGTEMPLATE
The template CreateDialogIndirectParam uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
In an extended dialog box template, the header uses the DLGTEMPLATEEX format and
the control definitions use the DLGITEMTEMPLATEEX format.
After CreateDialogIndirectParam returns, you can free the template, which is only used
to get the dialog box started.
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG
message.
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box.
If the function fails, the return value is NULL. To get extended error information, call
GetLastError.
Remarks
The CreateDialogIndirectParam function uses the CreateWindowEx function to create
the dialog box. CreateDialogIndirectParam then sends a WM_INITDIALOG message to
the dialog box procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT
style, the function also sends a WM_SETFONT message to the dialog box procedure. The
function displays the dialog box if the template specifies the WS_VISIBLE style. Finally,
CreateDialogIndirectParam returns the window handle to the dialog box.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateDialogIndirect
CreateDialogParam
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
DestroyWindow
Dialog Boxes
DialogProc
MultiByteToWideChar
Other Resources
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template in memory. Before displaying
the dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
HWND CreateDialogIndirectParamW(
[in, optional] HINSTANCE hInstance,
[in] LPCDLGTEMPLATEW lpTemplate,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplate
Type: LPCDLGTEMPLATE
The template CreateDialogIndirectParam uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
In an extended dialog box template, the header uses the DLGTEMPLATEEX format and
the control definitions use the DLGITEMTEMPLATEEX format.
After CreateDialogIndirectParam returns, you can free the template, which is only used
to get the dialog box started.
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG
message.
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box.
If the function fails, the return value is NULL. To get extended error information, call
GetLastError.
Remarks
The CreateDialogIndirectParam function uses the CreateWindowEx function to create
the dialog box. CreateDialogIndirectParam then sends a WM_INITDIALOG message to
the dialog box procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT
style, the function also sends a WM_SETFONT message to the dialog box procedure. The
function displays the dialog box if the template specifies the WS_VISIBLE style. Finally,
CreateDialogIndirectParam returns the window handle to the dialog box.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateDialogIndirect
CreateDialogParam
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
DestroyWindow
Dialog Boxes
DialogProc
MultiByteToWideChar
Other Resources
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template in memory. The
CreateDialogIndirect macro uses the CreateDialogIndirectParam function.
Syntax
C++
void CreateDialogIndirectW(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
[in] lpTemplate
Type: LPCDLGTEMPLATE
A template that CreateDialogIndirect uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
In an extended dialog box template, the header uses the DLGTEMPLATEEX format and
the control definitions use the DLGITEMTEMPLATEEX format.
After CreateDialogIndirect returns, you can free the template, which is only used to get
the dialog box started.
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The CreateDialogIndirect macro uses the CreateWindowEx function to create the dialog
box. CreateDialogIndirect then sends a WM_INITDIALOG message to the dialog box
procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT style, the
function also sends a WM_SETFONT message to the dialog box procedure. The function
displays the dialog box if the template specifies the WS_VISIBLE style. Finally,
CreateDialogIndirect returns the window handle to the dialog box.
After CreateDialogIndirect returns, you can use the ShowWindow function to display
the dialog box (if it is not already visible). To destroy the dialog box, use the
DestroyWindow function. To support keyboard navigation and other dialog box
functionality, the message loop for the dialog box must call the IsDialogMessage
function.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings. Use the MultiByteToWideChar function to generate
Unicode strings from ANSI strings.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateDialogIndirectParam
CreateDialogParam
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
DestroyWindow
Dialog Boxes
DialogProc
IsDialogMessage
MultiByteToWideChar
Other Resources
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template resource. Before displaying
the dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
HWND CreateDialogParamA(
[in, optional] HINSTANCE hInstance,
[in] LPCSTR lpTemplateName,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplateName
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
[in, optional] hWndParent
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to be passed to the dialog box procedure in the lParam parameter in the
WM_INITDIALOG message.
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box.
If the function fails, the return value is NULL. To get extended error information, call
GetLastError.
Remarks
The CreateDialogParam function uses the CreateWindowEx function to create the
dialog box. CreateDialogParam then sends a WM_INITDIALOG message (and a
WM_SETFONT message if the template specifies the DS_SETFONT or DS_SHELLFONT
style) to the dialog box procedure. The function displays the dialog box if the template
specifies the WS_VISIBLE style. Finally, CreateDialogParam returns the window handle
of the dialog box.
After CreateDialogParam returns, the application displays the dialog box (if it is not
already displayed) using the ShowWindow function. The application destroys the dialog
box by using the DestroyWindow function. To support keyboard navigation and other
dialog box functionality, the message loop for the dialog box must call the
IsDialogMessage function.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateDialogIndirect
CreateDialogIndirectParam
CreateWindowEx
DestroyWindow
Dialog Boxes
DialogProc
IsDialogMessage
MAKEINTRESOURCE
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template resource. Before displaying
the dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
HWND CreateDialogParamW(
[in, optional] HINSTANCE hInstance,
[in] LPCWSTR lpTemplateName,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplateName
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
[in, optional] hWndParent
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to be passed to the dialog box procedure in the lParam parameter in the
WM_INITDIALOG message.
Return value
Type: HWND
If the function succeeds, the return value is the window handle to the dialog box.
If the function fails, the return value is NULL. To get extended error information, call
GetLastError.
Remarks
The CreateDialogParam function uses the CreateWindowEx function to create the
dialog box. CreateDialogParam then sends a WM_INITDIALOG message (and a
WM_SETFONT message if the template specifies the DS_SETFONT or DS_SHELLFONT
style) to the dialog box procedure. The function displays the dialog box if the template
specifies the WS_VISIBLE style. Finally, CreateDialogParam returns the window handle
of the dialog box.
After CreateDialogParam returns, the application displays the dialog box (if it is not
already displayed) using the ShowWindow function. The application destroys the dialog
box by using the DestroyWindow function. To support keyboard navigation and other
dialog box functionality, the message loop for the dialog box must call the
IsDialogMessage function.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateDialogIndirect
CreateDialogIndirectParam
CreateWindowEx
DestroyWindow
Dialog Boxes
DialogProc
IsDialogMessage
MAKEINTRESOURCE
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modeless dialog box from a dialog box template resource. The CreateDialog
macro uses the CreateDialogParam function.
Syntax
C++
void CreateDialogW(
[in, optional] hInstance,
[in] lpName,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpName
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and its low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The CreateDialog function uses the CreateWindowEx function to create the dialog box.
CreateDialog then sends a WM_INITDIALOG message (and a WM_SETFONT message if
the template specifies the DS_SETFONT or DS_SHELLFONT style) to the dialog box
procedure. The function displays the dialog box if the template specifies the WS_VISIBLE
style. Finally, CreateDialog returns the window handle to the dialog box.
After CreateDialog returns, the application displays the dialog box (if it is not already
displayed) by using the ShowWindow function. The application destroys the dialog box
by using the DestroyWindow function. To support keyboard navigation and other dialog
box functionality, the message loop for the dialog box must call the IsDialogMessage
function.
Examples
For an example, see Creating a Modeless Dialog Box.
7 Note
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialogIndirect
CreateDialogIndirectParam
CreateDialogParam
CreateWindowEx
DestroyWindow
Dialog Boxes
DialogBox
DialogProc
IsDialogMessage
Reference
ShowWindow
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Calls the default dialog box window procedure to provide default processing for any
window messages that a dialog box with a private window class does not process.
Syntax
C++
Parameters
[in] hDlg
Type: HWND
[in] Msg
Type: UINT
The message.
[in] wParam
Type: WPARAM
[in] lParam
Type: LPARAM
The return value specifies the result of the message processing and depends on the
message sent.
Remarks
The DefDlgProc function is the window procedure for the predefined class of dialog
box. This procedure provides internal processing for the dialog box by forwarding
messages to the dialog box procedure and carrying out default processing for any
messages that the dialog box procedure returns as FALSE. Applications that create
custom window procedures for their custom dialog boxes often use DefDlgProc instead
of the DefWindowProc function to carry out default message processing.
Applications create custom dialog box classes by filling a WNDCLASS structure with
appropriate information and registering the class with the RegisterClass function. Some
applications fill the structure by using the GetClassInfo function, specifying the name of
the predefined dialog box. In such cases, the applications modify at least the
lpszClassName member before registering. In all cases, the cbWndExtra member of
WNDCLASS for a custom dialog box class must be set to at least DLGWINDOWEXTRA.
The DefDlgProc function must not be called by a dialog box procedure; doing so results
in recursive execution.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
DefWindowProc
Dialog Boxes
GetClassInfo
Reference
RegisterClass
WNDCLASS
Feedback
Was this page helpful? ツ Yes ト No
Calls the default dialog box window procedure to provide default processing for any
window messages that a dialog box with a private window class does not process.
Syntax
C++
Parameters
[in] hDlg
Type: HWND
[in] Msg
Type: UINT
The message.
[in] wParam
Type: WPARAM
[in] lParam
Type: LPARAM
The return value specifies the result of the message processing and depends on the
message sent.
Remarks
The DefDlgProc function is the window procedure for the predefined class of dialog
box. This procedure provides internal processing for the dialog box by forwarding
messages to the dialog box procedure and carrying out default processing for any
messages that the dialog box procedure returns as FALSE. Applications that create
custom window procedures for their custom dialog boxes often use DefDlgProc instead
of the DefWindowProc function to carry out default message processing.
Applications create custom dialog box classes by filling a WNDCLASS structure with
appropriate information and registering the class with the RegisterClass function. Some
applications fill the structure by using the GetClassInfo function, specifying the name of
the predefined dialog box. In such cases, the applications modify at least the
lpszClassName member before registering. In all cases, the cbWndExtra member of
WNDCLASS for a custom dialog box class must be set to at least DLGWINDOWEXTRA.
The DefDlgProc function must not be called by a dialog box procedure; doing so results
in recursive execution.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
DefWindowProc
Dialog Boxes
GetClassInfo
Reference
RegisterClass
WNDCLASS
Feedback
Was this page helpful? ツ Yes ト No
Creates a modal dialog box from a dialog box template resource. DialogBox does not
return control until the specified callback function terminates the modal dialog box by
calling the EndDialog function.
Syntax
C++
void DialogBoxA(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplate
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and its low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
Type: HWND
A handle to the window that owns the dialog box.
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The DialogBox macro uses the CreateWindowEx function to create the dialog box.
DialogBox then sends a WM_INITDIALOG message (and a WM_SETFONT message if the
template specifies the DS_SETFONT or DS_SHELLFONT style) to the dialog box
procedure. The function displays the dialog box (regardless of whether the template
specifies the WS_VISIBLE style), disables the owner window, and starts its own message
loop to retrieve and dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBox destroys the
dialog box, ends the message loop, enables the owner window (if previously enabled),
and returns the nResult parameter specified by the dialog box procedure when it called
EndDialog.
Examples
7 Note
The winuser.h header defines DialogBox as an alias which automatically selects the
ANSI or Unicode version of this function based on the definition of the UNICODE
preprocessor constant. Mixing usage of the encoding-neutral alias with code that
not encoding-neutral can lead to mismatches that result in compilation or runtime
errors. For more information, see Conventions for Function Prototypes.
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateWindowEx
Dialog Boxes
DialogBoxIndirect
DialogBoxIndirectParam
DialogBoxParam
DialogProc
EndDialog
MAKEINTRESOURCE
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Get help at Microsoft Q&A
DialogBoxIndirectA macro (winuser.h)
Article02/09/2023
Creates a modal dialog box from a dialog box template in memory. DialogBoxIndirect
does not return control until the specified callback function terminates the modal dialog
box by calling the EndDialog function.
Syntax
C++
void DialogBoxIndirectA(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
[in] lpTemplate
Type: LPCDLGTEMPLATE
The template that DialogBoxIndirect uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
In an extended template for a dialog box, the header uses the DLGTEMPLATEEX format
and the control definitions use the DLGITEMTEMPLATEEX format.
[in, optional] hWndParent
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The DialogBoxIndirect macro uses the CreateWindowEx function to create the dialog
box. DialogBoxIndirect then sends a WM_INITDIALOG message to the dialog box
procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT style, the
function also sends a WM_SETFONT message to the dialog box procedure. The function
displays the dialog box (regardless of whether the template specifies the WS_VISIBLE
style), disables the owner window, and starts its own message loop to retrieve and
dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBoxIndirect
destroys the dialog box, ends the message loop, enables the owner window (if
previously enabled), and returns the nResult parameter specified by the dialog box
procedure when it called EndDialog.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings. Use the MultiByteToWideChar function to generate
Unicode strings from ANSI strings.
Examples
For an example, see Creating a Template in Memory.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
Dialog Boxes
DialogBox
DialogBoxIndirectParam
DialogBoxParam
DialogProc
EndDialog
MultiByteToWideChar
Other Resources
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modal dialog box from a dialog box template in memory. Before displaying
the dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
INT_PTR DialogBoxIndirectParamA(
[in, optional] HINSTANCE hInstance,
[in] LPCDLGTEMPLATEA hDialogTemplate,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
[in] hDialogTemplate
Type: LPCDLGTEMPLATE
The template that DialogBoxIndirectParam uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG
message.
Return value
Type: INT_PTR
If the function succeeds, the return value is the nResult parameter specified in the call to
the EndDialog function that was used to terminate the dialog box.
If the function fails because the hWndParent parameter is invalid, the return value is
zero. The function returns zero in this case for compatibility with previous versions of
Windows. If the function fails for any other reason, the return value is –1. To get
extended error information, call GetLastError.
Remarks
The DialogBoxIndirectParam function uses the CreateWindowEx function to create the
dialog box. DialogBoxIndirectParam then sends a WM_INITDIALOG message to the
dialog box procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT style,
the function also sends a WM_SETFONT message to the dialog box procedure. The
function displays the dialog box (regardless of whether the template specifies the
WS_VISIBLE style), disables the owner window, and starts its own message loop to
retrieve and dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBoxIndirectParam
destroys the dialog box, ends the message loop, enables the owner window (if
previously enabled), and returns the nResult parameter specified by the dialog box
procedure when it called EndDialog.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
Dialog Boxes
DialogBox
DialogBoxIndirect
DialogBoxParam
DialogProc
EndDialog
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modal dialog box from a dialog box template in memory. Before displaying
the dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
INT_PTR DialogBoxIndirectParamW(
[in, optional] HINSTANCE hInstance,
[in] LPCDLGTEMPLATEW hDialogTemplate,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
[in] hDialogTemplate
Type: LPCDLGTEMPLATE
The template that DialogBoxIndirectParam uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG
message.
Return value
Type: INT_PTR
If the function succeeds, the return value is the nResult parameter specified in the call to
the EndDialog function that was used to terminate the dialog box.
If the function fails because the hWndParent parameter is invalid, the return value is
zero. The function returns zero in this case for compatibility with previous versions of
Windows. If the function fails for any other reason, the return value is –1. To get
extended error information, call GetLastError.
Remarks
The DialogBoxIndirectParam function uses the CreateWindowEx function to create the
dialog box. DialogBoxIndirectParam then sends a WM_INITDIALOG message to the
dialog box procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT style,
the function also sends a WM_SETFONT message to the dialog box procedure. The
function displays the dialog box (regardless of whether the template specifies the
WS_VISIBLE style), disables the owner window, and starts its own message loop to
retrieve and dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBoxIndirectParam
destroys the dialog box, ends the message loop, enables the owner window (if
previously enabled), and returns the nResult parameter specified by the dialog box
procedure when it called EndDialog.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
Dialog Boxes
DialogBox
DialogBoxIndirect
DialogBoxParam
DialogProc
EndDialog
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modal dialog box from a dialog box template in memory. DialogBoxIndirect
does not return control until the specified callback function terminates the modal dialog
box by calling the EndDialog function.
Syntax
C++
void DialogBoxIndirectW(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
[in] lpTemplate
Type: LPCDLGTEMPLATE
The template that DialogBoxIndirect uses to create the dialog box. A dialog box
template consists of a header that describes the dialog box, followed by one or more
additional blocks of data that describe each of the controls in the dialog box. The
template can use either the standard format or the extended format.
In an extended template for a dialog box, the header uses the DLGTEMPLATEEX format
and the control definitions use the DLGITEMTEMPLATEEX format.
[in, optional] hWndParent
Type: HWND
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The DialogBoxIndirect macro uses the CreateWindowEx function to create the dialog
box. DialogBoxIndirect then sends a WM_INITDIALOG message to the dialog box
procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT style, the
function also sends a WM_SETFONT message to the dialog box procedure. The function
displays the dialog box (regardless of whether the template specifies the WS_VISIBLE
style), disables the owner window, and starts its own message loop to retrieve and
dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBoxIndirect
destroys the dialog box, ends the message loop, enables the owner window (if
previously enabled), and returns the nResult parameter specified by the dialog box
procedure when it called EndDialog.
In a standard dialog box template, the DLGTEMPLATE structure and each of the
DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation
data array that follows a DLGITEMTEMPLATE structure must also be aligned on a
DWORD boundary. All of the other variable-length arrays in the template must be
aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the
DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The
creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be
aligned on a DWORD boundary. All of the other variable-length arrays in the template
must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and
buttons, must be Unicode strings. Use the MultiByteToWideChar function to generate
Unicode strings from ANSI strings.
Examples
For an example, see Creating a Template in Memory.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindowEx
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
Dialog Boxes
DialogBox
DialogBoxIndirectParam
DialogBoxParam
DialogProc
EndDialog
MultiByteToWideChar
Other Resources
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modal dialog box from a dialog box template resource. Before displaying the
dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
INT_PTR DialogBoxParamA(
[in, optional] HINSTANCE hInstance,
[in] LPCSTR lpTemplateName,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplateName
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and its low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG
message.
Return value
Type: INT_PTR
If the function succeeds, the return value is the value of the nResult parameter specified
in the call to the EndDialog function used to terminate the dialog box.
If the function fails because the hWndParent parameter is invalid, the return value is
zero. The function returns zero in this case for compatibility with previous versions of
Windows. If the function fails for any other reason, the return value is –1. To get
extended error information, call GetLastError.
Remarks
The DialogBoxParam function uses the CreateWindowEx function to create the dialog
box. DialogBoxParam then sends a WM_INITDIALOG message (and a WM_SETFONT
message if the template specifies the DS_SETFONT or DS_SHELLFONT style) to the
dialog box procedure. The function displays the dialog box (regardless of whether the
template specifies the WS_VISIBLE style), disables the owner window, and starts its own
message loop to retrieve and dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBoxParam destroys
the dialog box, ends the message loop, enables the owner window (if previously
enabled), and returns the nResult parameter specified by the dialog box procedure when
it called EndDialog.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindowEx
Dialog Boxes
DialogBox
DialogBoxIndirect
DialogBoxIndirectParam
DialogProc
EndDialog
MAKEINTRESOURCE
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modal dialog box from a dialog box template resource. Before displaying the
dialog box, the function passes an application-defined value to the dialog box
procedure as the lParam parameter of the WM_INITDIALOG message. An application
can use this value to initialize dialog box controls.
Syntax
C++
INT_PTR DialogBoxParamW(
[in, optional] HINSTANCE hInstance,
[in] LPCWSTR lpTemplateName,
[in, optional] HWND hWndParent,
[in, optional] DLGPROC lpDialogFunc,
[in] LPARAM dwInitParam
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplateName
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and its low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
[in] dwInitParam
Type: LPARAM
The value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG
message.
Return value
Type: INT_PTR
If the function succeeds, the return value is the value of the nResult parameter specified
in the call to the EndDialog function used to terminate the dialog box.
If the function fails because the hWndParent parameter is invalid, the return value is
zero. The function returns zero in this case for compatibility with previous versions of
Windows. If the function fails for any other reason, the return value is –1. To get
extended error information, call GetLastError.
Remarks
The DialogBoxParam function uses the CreateWindowEx function to create the dialog
box. DialogBoxParam then sends a WM_INITDIALOG message (and a WM_SETFONT
message if the template specifies the DS_SETFONT or DS_SHELLFONT style) to the
dialog box procedure. The function displays the dialog box (regardless of whether the
template specifies the WS_VISIBLE style), disables the owner window, and starts its own
message loop to retrieve and dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBoxParam destroys
the dialog box, ends the message loop, enables the owner window (if previously
enabled), and returns the nResult parameter specified by the dialog box procedure when
it called EndDialog.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindowEx
Dialog Boxes
DialogBox
DialogBoxIndirect
DialogBoxIndirectParam
DialogProc
EndDialog
MAKEINTRESOURCE
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Creates a modal dialog box from a dialog box template resource. DialogBox does not
return control until the specified callback function terminates the modal dialog box by
calling the EndDialog function.
Syntax
C++
void DialogBoxW(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);
Parameters
[in, optional] hInstance
Type: HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is
NULL, then the current executable is used.
[in] lpTemplate
Type: LPCTSTR
The dialog box template. This parameter is either the pointer to a null-terminated
character string that specifies the name of the dialog box template or an integer value
that specifies the resource identifier of the dialog box template. If the parameter
specifies a resource identifier, its high-order word must be zero and its low-order word
must contain the identifier. You can use the MAKEINTRESOURCE macro to create this
value.
Type: HWND
A handle to the window that owns the dialog box.
Type: DLGPROC
A pointer to the dialog box procedure. For more information about the dialog box
procedure, see DialogProc.
Return value
None
Remarks
The DialogBox macro uses the CreateWindowEx function to create the dialog box.
DialogBox then sends a WM_INITDIALOG message (and a WM_SETFONT message if the
template specifies the DS_SETFONT or DS_SHELLFONT style) to the dialog box
procedure. The function displays the dialog box (regardless of whether the template
specifies the WS_VISIBLE style), disables the owner window, and starts its own message
loop to retrieve and dispatch messages for the dialog box.
When the dialog box procedure calls the EndDialog function, DialogBox destroys the
dialog box, ends the message loop, enables the owner window (if previously enabled),
and returns the nResult parameter specified by the dialog box procedure when it called
EndDialog.
Examples
7 Note
The winuser.h header defines DialogBox as an alias which automatically selects the
ANSI or Unicode version of this function based on the definition of the UNICODE
preprocessor constant. Mixing usage of the encoding-neutral alias with code that
not encoding-neutral can lead to mismatches that result in compilation or runtime
errors. For more information, see Conventions for Function Prototypes.
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateDialog
CreateWindowEx
Dialog Boxes
DialogBoxIndirect
DialogBoxIndirectParam
DialogBoxParam
DialogProc
EndDialog
MAKEINTRESOURCE
Reference
WM_INITDIALOG
WM_SETFONT
Feedback
Was this page helpful? ツ Yes ト No
Get help at Microsoft Q&A
DLGITEMTEMPLATE structure
(winuser.h)
Article03/13/2023
Defines the dimensions and style of a control in a dialog box. One or more of these
structures are combined with a DLGTEMPLATE structure to form a standard template for
a dialog box.
Syntax
C++
typedef struct {
DWORD style;
DWORD dwExtendedStyle;
short x;
short y;
short cx;
short cy;
WORD id;
} DLGITEMTEMPLATE;
Members
style
Type: DWORD
The style of the control. This member can be a combination of window style values (such
as WS_BORDER) and one or more of the control style values (such as BS_PUSHBUTTON
and ES_LEFT).
dwExtendedStyle
Type: DWORD
The extended styles for a window. This member is not used to create controls in dialog
boxes, but applications that use dialog box templates can use it to create other types of
windows. For a list of values, see Extended Window Styles.
x
Type: short
The x-coordinate, in dialog box units, of the upper-left corner of the control. This
coordinate is always relative to the upper-left corner of the dialog box's client area.
Type: short
The y-coordinate, in dialog box units, of the upper-left corner of the control. This
coordinate is always relative to the upper-left corner of the dialog box's client area.
cx
Type: short
cy
Type: short
id
Type: WORD
Remarks
In a standard template for a dialog box, the DLGITEMTEMPLATE structure is always
immediately followed by three variable-length arrays specifying the class, title, and
creation data for the control. Each array consists of one or more 16-bit elements.
Value Meaning
0x0080 Button
0x0081 Edit
0x0082 Static
Following the class array is a title array that contains the initial text or resource identifier
of the control. If the first element of this array is 0xFFFF, the array has one additional
element that specifies an ordinal value of a resource, such as an icon, in an executable
file. You can use a resource identifier for controls, such as static icon controls, that load
and display an icon or other resource rather than text. If the first element is any value
other than 0xFFFF, the system treats the array as a null-terminated Unicode string that
specifies the initial text.
The creation data array begins at the next WORD boundary after the title array. This
creation data can be of any size and format. If the first word of the creation data array is
nonzero, it indicates the size, in bytes, of the creation data (including the size word). The
control's window procedure must be able to interpret the data. When the system creates
the control, it passes a pointer to this data in the lParam parameter of the WM_CREATE
message that it sends to the control.
If you specify character strings in the class and title arrays, you must use Unicode strings.
Use the MultiByteToWideChar function to generate Unicode strings from ANSI strings.
The x, y, cx, and cy members specify values in dialog box units. You can convert these
values to screen units (pixels) by using the MapDialogRect function.
Requirements
See also
Conceptual
CreateDialogIndirect
CreateDialogIndirectParam
CreateWindowEx
DLGITEMTEMPLATEEX
DLGTEMPLATE
DLGTEMPLATEEX
Dialog Boxes
DialogBoxIndirect
DialogBoxIndirectParam
MapDialogRect
MultiByteToWideChar
Other Resources
Reference
WM_CREATE
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
DLGPROC Dlgproc;
INT_PTR Dlgproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}
Parameters
unnamedParam1
Type: HWND
unnamedParam2
Type: UINT
The message.
unnamedParam3
Type: WPARAM
unnamedParam4
Type: LPARAM
Type: INT_PTR
Typically, the dialog box procedure should return TRUE if it processed the message, and
FALSE if it did not. If the dialog box procedure returns FALSE, the dialog manager
performs the default dialog operation in response to the message.
If the dialog box procedure processes a message that requires a specific return value,
the dialog box procedure should set the desired return value by calling
SetWindowLong(hwndDlg, DWL_MSGRESULT, lResult) immediately before returning
TRUE. Note that you must call SetWindowLong immediately before returning TRUE;
doing so earlier may result in the DWL_MSGRESULT value being overwritten by a nested
dialog box message.
The following messages are exceptions to the general rules stated above. Consult the
documentation for the specific message for details on the semantics of the return value.
WM_CHARTOITEM
WM_COMPAREITEM
WM_CTLCOLORBTN
WM_CTLCOLORDLG
WM_CTLCOLOREDIT
WM_CTLCOLORLISTBOX
WM_CTLCOLORSCROLLBAR
WM_CTLCOLORSTATIC
WM_INITDIALOG
WM_QUERYDRAGICON
WM_VKEYTOITEM
Return value
None
Remarks
You should use the dialog box procedure only if you use the dialog box class for the
dialog box. This is the default class and is used when no explicit class is specified in the
dialog box template. Although the dialog box procedure is similar to a window
procedure, it must not call the DefWindowProc function to process unwanted messages.
Unwanted messages are processed internally by the dialog box window procedure.
Requirements
See also
Conceptual
CreateDialog
CreateDialogIndirect
CreateDialogIndirectParam
CreateDialogParam
DefWindowProc
Dialog Boxes
DialogBox
DialogBoxIndirect
DialogBoxIndirectParam
DialogBoxParam
Reference
SetFocus
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Defines the dimensions and style of a dialog box. This structure, always the first in a
standard template for a dialog box, also specifies the number of controls in the dialog
box and therefore specifies the number of subsequent DLGITEMTEMPLATE structures in
the template.
Syntax
C++
typedef struct {
DWORD style;
DWORD dwExtendedStyle;
WORD cdit;
short x;
short y;
short cx;
short cy;
} DLGTEMPLATE;
Members
style
Type: DWORD
The style of the dialog box. This member can be a combination of window style values
(such as WS_CAPTION and WS_SYSMENU) and dialog box style values (such as
DS_CENTER).
If the style member includes the DS_SETFONT style, the header of the dialog box
template contains additional data specifying the font to use for text in the client area
and controls of the dialog box. The font data begins on the WORD boundary that
follows the title array. The font data specifies a 16-bit point size value and a Unicode
font name string. If possible, the system creates a font according to the specified values.
Then the system sends a WM_SETFONT message to the dialog box and to each control
to provide a handle to the font. If DS_SETFONT is not specified, the dialog box template
does not include the font data.
Type: DWORD
The extended styles for a window. This member is not used to create dialog boxes, but
applications that use dialog box templates can use it to create other types of windows.
For a list of values, see Extended Window Styles.
cdit
Type: WORD
Type: short
The x-coordinate, in dialog box units, of the upper-left corner of the dialog box.
Type: short
The y-coordinate, in dialog box units, of the upper-left corner of the dialog box.
cx
Type: short
cy
Type: short
Remarks
In a standard template for a dialog box, the DLGTEMPLATE structure is always
immediately followed by three variable-length arrays that specify the menu, class, and
title for the dialog box. When the DS_SETFONT style is specified, these arrays are also
followed by a 16-bit value specifying point size and another variable-length array
specifying a typeface name. Each array consists of one or more 16-bit elements. The
menu, class, title, and font arrays must be aligned on WORD boundaries.
Immediately following the DLGTEMPLATE structure is a menu array that identifies a
menu resource for the dialog box. If the first element of this array is 0x0000, the dialog
box has no menu and the array has no other elements. If the first element is 0xFFFF, the
array has one additional element that specifies the ordinal value of a menu resource in
an executable file. If the first element has any other value, the system treats the array as
a null-terminated Unicode string that specifies the name of a menu resource in an
executable file.
Following the menu array is a class array that identifies the window class of the dialog
box. If the first element of the array is 0x0000, the system uses the predefined dialog
box class for the dialog box and the array has no other elements. If the first element is
0xFFFF, the array has one additional element that specifies the ordinal value of a
predefined system window class. If the first element has any other value, the system
treats the array as a null-terminated Unicode string that specifies the name of a
registered window class.
Following the class array is a title array that specifies a null-terminated Unicode string
that contains the title of the dialog box. If the first element of this array is 0x0000, the
dialog box has no title and the array has no other elements.
The 16-bit point size value and the typeface array follow the title array, but only if the
style member specifies the DS_SETFONT style. The point size value specifies the point
size of the font to use for the text in the dialog box and its controls. The typeface array
is a null-terminated Unicode string specifying the name of the typeface for the font.
When these values are specified, the system creates a font having the specified size and
typeface (if possible) and sends a WM_SETFONT message to the dialog box procedure
and the control window procedures as it creates the dialog box and controls.
Following the DLGTEMPLATE header in a standard dialog box template are one or more
DLGITEMTEMPLATE structures that define the dimensions and style of the controls in the
dialog box. The cdit member specifies the number of DLGITEMTEMPLATE structures in
the template. These DLGITEMTEMPLATE structures must be aligned on DWORD
boundaries.
If you specify character strings in the menu, class, title, or typeface arrays, you must use
Unicode strings.
The x, y, cx, and cy members specify values in dialog box units. You can convert these
values to screen units (pixels) by using the MapDialogRect function.
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
See also
Conceptual
CreateDialogIndirect
CreateDialogIndirectParam
DLGITEMTEMPLATE
DLGITEMTEMPLATEEX
DLGTEMPLATEEX
Dialog Boxes
DialogBoxIndirect
DialogBoxIndirectParam
MapDialogRect
MultiByteToWideChar
Other Resources
Reference
Feedback
Was this page helpful? ツ Yes ト No
Destroys a modal dialog box, causing the system to end any processing for the dialog
box.
Syntax
C++
BOOL EndDialog(
[in] HWND hDlg,
[in] INT_PTR nResult
);
Parameters
[in] hDlg
Type: HWND
[in] nResult
Type: INT_PTR
The value to be returned to the application from the function that created the dialog
box.
Return value
Type: BOOL
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
Dialog boxes created by the DialogBox, DialogBoxParam, DialogBoxIndirect, and
DialogBoxIndirectParam functions must be destroyed using the EndDialog function. An
application calls EndDialog from within the dialog box procedure; the function must not
be used for any other purpose.
A dialog box procedure can call EndDialog at any time, even during the processing of
the WM_INITDIALOG message. If your application calls the function while
WM_INITDIALOG is being processed, the dialog box is destroyed before it is shown and
before the input focus is set.
EndDialog does not destroy the dialog box immediately. Instead, it sets a flag and
allows the dialog box procedure to return control to the system. The system checks the
flag before attempting to retrieve the next message from the application queue. If the
flag is set, the system ends the message loop, destroys the dialog box, and uses the
value in nResult as the return value from the function that created the dialog box.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
DialogBox
DialogBoxIndirect
DialogBoxIndirectParam
DialogBoxParam
Reference
WM_INITDIALOG
Feedback
Was this page helpful? ツ Yes ト No
Retrieves the system's dialog base units, which are the average width and height of
characters in the system font. For dialog boxes that use the system font, you can use
these values to convert between dialog template units, as specified in dialog box
templates, and pixels. For dialog boxes that do not use the system font, the conversion
from dialog template units to pixels depends on the font used by the dialog box.
For either type of dialog box, it is easier to use the MapDialogRect function to perform
the conversion. MapDialogRect takes the font into account and correctly converts a
rectangle from dialog template units into pixels.
Syntax
C++
long GetDialogBaseUnits();
Return value
Type: LONG
The function returns the dialog base units. The low-order word of the return value
contains the horizontal dialog box base unit, and the high-order word contains the
vertical dialog box base unit.
Remarks
The horizontal base unit returned by GetDialogBaseUnits is equal to the average width,
in pixels, of the characters in the system font; the vertical base unit is equal to the
height, in pixels, of the font.
The system font is used only if the dialog box template fails to specify a font. Most
dialog box templates specify a font; as a result, this function is not useful for most
dialog boxes.
For a dialog box that does not use the system font, the base units are the average width
and height, in pixels, of the characters in the dialog's font. You can use the
GetTextMetrics and GetTextExtentPoint32 functions to calculate these values for a
selected font. However, by using the MapDialogRect function, you can avoid errors that
might result if your calculations differ from those performed by the system.
Each horizontal base unit is equal to 4 horizontal dialog template units; each vertical
base unit is equal to 8 vertical dialog template units. Therefore, to convert dialog
template units to pixels, use the following formulas:
Similarly, to convert from pixels to dialog template units, use the following formulas:
Examples
For an example, see "Creating a Combo Box Toolbar" in Using Combo Boxes.
Requirements
Library User32.lib
DLL User32.dll
Dialog Boxes
MapDialogRect
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
int GetDlgCtrlID(
[in] HWND hWnd
);
Parameters
[in] hWnd
Type: HWND
Return value
Type: int
If the function succeeds, the return value is the identifier of the control.
If the function fails, the return value is zero. An invalid value for the hwndCtl parameter,
for example, will cause the function to fail. To get extended error information, call
GetLastError.
Remarks
GetDlgCtrlID accepts child window handles as well as handles of controls in dialog
boxes. An application sets the identifier for a child window when it creates the window
by assigning the identifier value to the hmenu parameter when calling the
CreateWindow or CreateWindowEx function.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindow
CreateWindowEx
Dialog Boxes
GetDlgItem
Reference
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
HWND GetDlgItem(
[in, optional] HWND hDlg,
[in] int nIDDlgItem
);
Parameters
[in, optional] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
Return value
Type: HWND
If the function succeeds, the return value is the window handle of the specified control.
If the function fails, the return value is NULL, indicating an invalid dialog box handle or a
nonexistent control. To get extended error information, call GetLastError.
Remarks
You can use the GetDlgItem function with any parent-child window pair, not just with
dialog boxes. As long as the hDlg parameter specifies a parent window and the child
window has a unique identifier (as specified by the hMenu parameter in the
CreateWindow or CreateWindowEx function that created the child window), GetDlgItem
returns a valid handle to the child window.
Examples
For an example, see Initializing a Dialog Box.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
CreateWindow
CreateWindowEx
Dialog Boxes
GetDlgItemInt
GetDlgItemText
Reference
Feedback
Was this page helpful? ツ Yes ト No
Translates the text of a specified control in a dialog box into an integer value.
Syntax
C++
UINT GetDlgItemInt(
[in] HWND hDlg,
[in] int nIDDlgItem,
[out, optional] BOOL *lpTranslated,
[in] BOOL bSigned
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
Type: BOOL*
If this parameter is NULL, the function returns no information about success or failure.
[in] bSigned
Type: BOOL
Indicates whether the function should examine the text for a minus sign at the
beginning and return a signed integer value if it finds one (TRUE specifies this should be
done, FALSE that it should not).
Return value
Type: UINT
If the function succeeds, the variable pointed to by lpTranslated is set to TRUE, and the
return value is the translated value of the control text.
If the function fails, the variable pointed to by lpTranslated is set to FALSE, and the
return value is zero. Note that, because zero is a possible translated value, a return value
of zero does not by itself indicate failure.
Note that, if the bSigned parameter is TRUE and there is a minus sign (–) at the
beginning of the text, GetDlgItemInt translates the text into a signed integer value.
Otherwise, the function creates an unsigned integer value. To obtain the proper value in
this case, cast the return value to an int type.
Remarks
The GetDlgItemInt function retrieves the text of the specified control by sending the
control a WM_GETTEXT message. The function translates the retrieved text by stripping
any extra spaces at the beginning of the text and then converting the decimal digits. The
function stops translating when it reaches the end of the text or encounters a
nonnumeric character.
The GetDlgItemInt function returns zero if the translated value is greater than INT_MAX
(for signed numbers) or UINT_MAX (for unsigned numbers).
Examples
For an example, see Creating a Modeless Dialog Box.
Requirements
Minimum supported Windows 2000 Professional [desktop apps only]
client
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDlgCtrlID
GetDlgItem
GetDlgItemText
Reference
SetDlgItemInt
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
UINT GetDlgItemTextA(
[in] HWND hDlg,
[in] int nIDDlgItem,
[out] LPSTR lpString,
[in] int cchMax
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
[out] lpString
Type: LPTSTR
[in] cchMax
Type: int
The maximum length, in characters, of the string to be copied to the buffer pointed to
by lpString. If the length of the string, including the null character, exceeds the limit, the
string is truncated.
Return value
Type: UINT
If the function succeeds, the return value specifies the number of characters copied to
the buffer, not including the terminating null character.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
If the string is as long or longer than the buffer, the buffer will contain the truncated
string with a terminating null character.
Examples
For an example, see Creating a Modal Dialog Box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDlgItemInt
Reference
SetDlgItemInt
SetDlgItemText
WM_GETTEXT
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
UINT GetDlgItemTextW(
[in] HWND hDlg,
[in] int nIDDlgItem,
[out] LPWSTR lpString,
[in] int cchMax
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
[out] lpString
Type: LPTSTR
[in] cchMax
Type: int
The maximum length, in characters, of the string to be copied to the buffer pointed to
by lpString. If the length of the string, including the null character, exceeds the limit, the
string is truncated.
Return value
Type: UINT
If the function succeeds, the return value specifies the number of characters copied to
the buffer, not including the terminating null character.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
If the string is as long or longer than the buffer, the buffer will contain the truncated
string with a terminating null character.
Examples
For an example, see Creating a Modal Dialog Box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDlgItemInt
Reference
SetDlgItemInt
SetDlgItemText
WM_GETTEXT
Feedback
Was this page helpful? ツ Yes ト No
Retrieves a handle to the first control in a group of controls that precedes (or follows)
the specified control in a dialog box.
Syntax
C++
HWND GetNextDlgGroupItem(
[in] HWND hDlg,
[in, optional] HWND hCtl,
[in] BOOL bPrevious
);
Parameters
[in] hDlg
Type: HWND
Type: HWND
A handle to the control to be used as the starting point for the search. If this parameter
is NULL, the function uses the last (or first) control in the dialog box as the starting point
for the search.
[in] bPrevious
Type: BOOL
Indicates how the function is to search the group of controls in the dialog box. If this
parameter is TRUE, the function searches for the previous control in the group. If it is
FALSE, the function searches for the next control in the group.
Return value
Type: HWND
If the function succeeds, the return value is a handle to the previous (or next) control in
the group of controls.
If the function fails, the return value is NULL. To get extended error information, call
GetLastError.
Remarks
The GetNextDlgGroupItem function searches controls in the order (or reverse order)
they were created in the dialog box template. The first control in the group must have
the WS_GROUP style; all other controls in the group must have been consecutively
created and must not have the WS_GROUP style.
When searching for the previous control, the function returns the first control it locates
that is visible and not disabled. If the control specified by hCtl has the WS_GROUP style,
the function temporarily reverses the search to locate the first control having the
WS_GROUP style, then resumes the search in the original direction, returning the first
control it locates that is visible and not disabled, or returning hCtl if no such control is
found.
When searching for the next control, the function returns the first control it locates that
is visible, not disabled, and does not have the WS_GROUP style. If it encounters a
control having the WS_GROUP style, the function reverses the search, locates the first
control having the WS_GROUP style, and returns this control if it is visible and not
disabled. Otherwise, the function resumes the search in the original direction and
returns the first control it locates that is visible and not disabled, or returns hCtl if no
such control is found.
If the search for the next control in the group encounters a window with the
WS_EX_CONTROLPARENT style, the system recursively searches the window's children.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetNextDlgTabItem
Reference
Feedback
Was this page helpful? ツ Yes ト No
Retrieves a handle to the first control that has the WS_TABSTOP style that precedes (or
follows) the specified control.
Syntax
C++
HWND GetNextDlgTabItem(
[in] HWND hDlg,
[in, optional] HWND hCtl,
[in] BOOL bPrevious
);
Parameters
[in] hDlg
Type: HWND
Type: HWND
A handle to the control to be used as the starting point for the search. If this parameter
is NULL, the function fails.
[in] bPrevious
Type: BOOL
Indicates how the function is to search the dialog box. If this parameter is TRUE, the
function searches for the previous control in the dialog box. If this parameter is FALSE,
the function searches for the next control in the dialog box.
Return value
Type: HWND
If the function succeeds, the return value is the window handle of the previous (or next)
control that has the WS_TABSTOP style set.
If the function fails, the return value is NULL. To get extended error information, call
GetLastError.
Remarks
The GetNextDlgTabItem function searches controls in the order (or reverse order) they
were created in the dialog box template. The function returns the first control it locates
that is visible, not disabled, and has the WS_TABSTOP style. If no such control exists, the
function returns hCtl.
If the search for the next control with the WS_TABSTOP style encounters a window with
the WS_EX_CONTROLPARENT style, the system recursively searches the window's
children.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDlgItem
GetNextDlgGroupItem
Reference
Feedback
Was this page helpful? ツ Yes ト No
Determines whether a message is intended for the specified dialog box and, if it is,
processes the message.
Syntax
C++
BOOL IsDialogMessageA(
[in] HWND hDlg,
[in] LPMSG lpMsg
);
Parameters
[in] hDlg
Type: HWND
[in] lpMsg
Type: LPMSG
Return value
Type: BOOL
If the message has not been processed, the return value is zero.
Remarks
Although the IsDialogMessage function is intended for modeless dialog boxes, you can
use it with any window that contains controls, enabling the windows to provide the
same keyboard selection as is used in a dialog box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-dialogbox-l1-1-3 (introduced in Windows 10,
version 10.0.14393)
See also
Conceptual
DM_GETDEFID
DM_SETDEFID
Dialog Boxes
DispatchMessage
MSG
Reference
TranslateMessage
WM_GETDLGCODE
WM_USER
Feedback
Was this page helpful? ツ Yes ト No
Determines whether a message is intended for the specified dialog box and, if it is,
processes the message.
Syntax
C++
BOOL IsDialogMessageW(
[in] HWND hDlg,
[in] LPMSG lpMsg
);
Parameters
[in] hDlg
Type: HWND
[in] lpMsg
Type: LPMSG
Return value
Type: BOOL
If the message has not been processed, the return value is zero.
Remarks
Although the IsDialogMessage function is intended for modeless dialog boxes, you can
use it with any window that contains controls, enabling the windows to provide the
same keyboard selection as is used in a dialog box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-dialogbox-l1-1-3 (introduced in Windows 10,
version 10.0.14393)
See also
Conceptual
DM_GETDEFID
DM_SETDEFID
Dialog Boxes
DispatchMessage
MSG
Reference
TranslateMessage
WM_GETDLGCODE
WM_USER
Feedback
Was this page helpful? ツ Yes ト No
Converts the specified dialog box units to screen units (pixels). The function replaces the
coordinates in the specified RECT structure with the converted coordinates, which allows
the structure to be used to create a dialog box or position a control within a dialog box.
Syntax
C++
BOOL MapDialogRect(
[in] HWND hDlg,
[in, out] LPRECT lpRect
);
Parameters
[in] hDlg
Type: HWND
A handle to a dialog box. This function accepts only handles returned by one of the
dialog box creation functions; handles for other windows are not valid.
Type: LPRECT
A pointer to a RECT structure that contains the dialog box coordinates to be converted.
Return value
Type: BOOL
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
The MapDialogRect function assumes that the initial coordinates in the RECT structure
represent dialog box units. To convert these coordinates from dialog box units to pixels,
the function retrieves the current horizontal and vertical base units for the dialog box,
then applies the following formulas:
syntax
If the dialog box template has the DS_SETFONT or DS_SHELLFONT style, the base units
are the average width and height, in pixels, of the characters in the font specified by the
template.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDialogBaseUnits
Other Resources
RECT
Reference
Feedback
Was this page helpful? ツ Yes ト No
Displays a modal dialog box that contains a system icon, a set of buttons, and a brief
application-specific message, such as status or error information. The message box
returns an integer value that indicates which button the user clicked.
Syntax
C++
int MessageBox(
[in, optional] HWND hWnd,
[in, optional] LPCTSTR lpText,
[in, optional] LPCTSTR lpCaption,
[in] UINT uType
);
Parameters
[in, optional] hWnd
Type: HWND
A handle to the owner window of the message box to be created. If this parameter is
NULL, the message box has no owner window.
Type: LPCTSTR
The message to be displayed. If the string consists of more than one line, you can
separate the lines using a carriage return and/or linefeed character between each line.
Type: LPCTSTR
The dialog box title. If this parameter is NULL, the default title is Error.
[in] uType
Type: UINT
The contents and behavior of the dialog box. This parameter can be a combination of
flags from the following groups of flags.
To indicate the buttons displayed in the message box, specify one of the following
values.
Value Meaning
MB_HELP Adds a Help button to the message box. When the user
0x00004000L clicks the Help button or presses F1, the system sends a
WM_HELP message to the owner.
MB_OK The message box contains one push button: OK. This is
0x00000000L the default.
MB_RETRYCANCEL The message box contains two push buttons: Retry and
0x00000005L Cancel.
MB_YESNO The message box contains two push buttons: Yes and No.
0x00000004L
MB_YESNOCANCEL The message box contains three push buttons: Yes, No,
0x00000003L and Cancel.
To display an icon in the message box, specify one of the following values.
Value Meaning
Value Meaning
To indicate the modality of the dialog box, specify one of the following values.
Value Meaning
Value Meaning
Return value
Type: int
If a message box has a Cancel button, the function returns the IDCANCEL value if either
the ESC key is pressed or the Cancel button is selected. If the message box has no
Cancel button, pressing ESC will no effect - unless an MB_OK button is present. If an
MB_OK button is displayed and the user presses ESC, the return value will be IDOK.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
If the function succeeds, the return value is one of the following menu-item values.
Remarks
The following system icons can be used in a message box by setting the uType
parameter to the corresponding flag value.
MB_ICONQUESTION
MB_ICONEXCLAMATION or MB_ICONWARNING
MB_ICONASTERISK or MB_ICONINFORMATION
When you use a system-modal message box to indicate that the system is low on
memory, the strings pointed to by the lpText and lpCaption parameters should not be
taken from a resource file because an attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box
as the hWnd parameter. The hWnd parameter should not identify a child window, such
as a control in a dialog box.
Examples
In the following example, the application displays a message box that prompts the user
for an action after an error condition has occurred. The message box displays the
message that describes the error condition and how to resolve it. The
MB_CANCELTRYCONTINUE style directs MessageBox to provide three buttons with
which the user can choose how to proceed. The MB_DEFBUTTON2 style sets the default
focus on the second button of the message box, in this case, the Try Again button.
C++
int DisplayResourceNAMessageBox()
{
int msgboxID = MessageBox(
NULL,
(LPCWSTR)L"Resource not available\nDo you want to try again?",
(LPCWSTR)L"Account Details",
MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2
);
switch (msgboxID)
{
case IDCANCEL:
// TODO: add code
break;
case IDTRYAGAIN:
// TODO: add code
break;
case IDCONTINUE:
// TODO: add code
break;
}
return msgboxID;
}
The following image shows the output from the preceding code example:
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
FlashWindow
MessageBeep
MessageBoxEx
MessageBoxIndirect
Other Resources
Reference
SetForegroundWindow
Feedback
Was this page helpful? ツ Yes ト No
Displays a modal dialog box that contains a system icon, a set of buttons, and a brief
application-specific message, such as status or error information. The message box
returns an integer value that indicates which button the user clicked.
Syntax
C++
int MessageBoxA(
[in, optional] HWND hWnd,
[in, optional] LPCSTR lpText,
[in, optional] LPCSTR lpCaption,
[in] UINT uType
);
Parameters
[in, optional] hWnd
Type: HWND
A handle to the owner window of the message box to be created. If this parameter is
NULL, the message box has no owner window.
Type: LPCTSTR
The message to be displayed. If the string consists of more than one line, you can
separate the lines using a carriage return and/or linefeed character between each line.
Type: LPCTSTR
The dialog box title. If this parameter is NULL, the default title is Error.
[in] uType
Type: UINT
The contents and behavior of the dialog box. This parameter can be a combination of
flags from the following groups of flags.
To indicate the buttons displayed in the message box, specify one of the following
values.
Value Meaning
MB_HELP Adds a Help button to the message box. When the user
0x00004000L clicks the Help button or presses F1, the system sends a
WM_HELP message to the owner.
MB_OK The message box contains one push button: OK. This is
0x00000000L the default.
MB_RETRYCANCEL The message box contains two push buttons: Retry and
0x00000005L Cancel.
MB_YESNO The message box contains two push buttons: Yes and No.
0x00000004L
MB_YESNOCANCEL The message box contains three push buttons: Yes, No,
0x00000003L and Cancel.
To display an icon in the message box, specify one of the following values.
Value Meaning
Value Meaning
To indicate the modality of the dialog box, specify one of the following values.
Value Meaning
Value Meaning
Return value
Type: int
If a message box has a Cancel button, the function returns the IDCANCEL value if either
the ESC key is pressed or the Cancel button is selected. If the message box has no
Cancel button, pressing ESC will no effect - unless an MB_OK button is present. If an
MB_OK button is displayed and the user presses ESC, the return value will be IDOK.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
If the function succeeds, the return value is one of the following menu-item values.
Remarks
The following system icons can be used in a message box by setting the uType
parameter to the corresponding flag value.
MB_ICONQUESTION
MB_ICONEXCLAMATION or MB_ICONWARNING
MB_ICONASTERISK or MB_ICONINFORMATION
When you use a system-modal message box to indicate that the system is low on
memory, the strings pointed to by the lpText and lpCaption parameters should not be
taken from a resource file because an attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box
as the hWnd parameter. The hWnd parameter should not identify a child window, such
as a control in a dialog box.
Examples
In the following example, the application displays a message box that prompts the user
for an action after an error condition has occurred. The message box displays the
message that describes the error condition and how to resolve it. The
MB_CANCELTRYCONTINUE style directs MessageBox to provide three buttons with
which the user can choose how to proceed. The MB_DEFBUTTON2 style sets the default
focus on the second button of the message box, in this case, the Try Again button.
C++
int DisplayResourceNAMessageBox()
{
int msgboxID = MessageBox(
NULL,
(LPCWSTR)L"Resource not available\nDo you want to try again?",
(LPCWSTR)L"Account Details",
MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2
);
switch (msgboxID)
{
case IDCANCEL:
// TODO: add code
break;
case IDTRYAGAIN:
// TODO: add code
break;
case IDCONTINUE:
// TODO: add code
break;
}
return msgboxID;
}
The following image shows the output from the preceding code example:
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
FlashWindow
MessageBeep
MessageBoxEx
MessageBoxIndirect
Other Resources
Reference
SetForegroundWindow
Feedback
Was this page helpful? ツ Yes ト No
Creates, displays, and operates a message box. The message box contains an
application-defined message and title, plus any combination of predefined icons and
push buttons. The buttons are in the language of the system user interface.
Syntax
C++
int MessageBoxExA(
[in, optional] HWND hWnd,
[in, optional] LPCSTR lpText,
[in, optional] LPCSTR lpCaption,
[in] UINT uType,
[in] WORD wLanguageId
);
Parameters
[in, optional] hWnd
Type: HWND
A handle to the owner window of the message box to be created. If this parameter is
NULL, the message box has no owner window.
Type: LPCTSTR
Type: LPCTSTR
The dialog box title. If this parameter is NULL, the default title Error is used.
[in] uType
Type: UINT
The contents and behavior of the dialog box. For information on the supported flags,
see MessageBox.
[in] wLanguageId
Type: WORD
The language for the text displayed in the message box button(s). Specifying a value of
zero (0) indicates to display the button text in the default system language. If this
parameter is MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) , the current language
associated with the calling thread is used.
To specify a language other than the current language, use the MAKELANGID macro to
create this parameter. For more information, see MAKELANGID.
Return value
Type: int
If a message box has a Cancel button, the function returns the IDCANCEL value if either
the ESC key is pressed or the Cancel button is selected. If the message box has no
Cancel button, pressing ESC will no effect - unless an MB_OK button is present. If an
MB_OK button is displayed and the user presses ESC, the return value will be IDOK.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
If the function succeeds, the return value is one of the following menu-item values.
Remarks
When you use a system-modal message box to indicate that the system is low on
memory, the strings pointed to by the lpText and lpCaption parameters should not be
taken from a resource file because an attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box
as the hWnd parameter. The hWnd parameter should not identify a child window, such
as a control in a dialog box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
MAKELANGID
MessageBeep
MessageBox
MessageBoxIndirect
Other Resources
Reference
SetForegroundWindow
Feedback
Was this page helpful? ツ Yes ト No
Creates, displays, and operates a message box. The message box contains an
application-defined message and title, plus any combination of predefined icons and
push buttons. The buttons are in the language of the system user interface.
Syntax
C++
int MessageBoxExW(
[in, optional] HWND hWnd,
[in, optional] LPCWSTR lpText,
[in, optional] LPCWSTR lpCaption,
[in] UINT uType,
[in] WORD wLanguageId
);
Parameters
[in, optional] hWnd
Type: HWND
A handle to the owner window of the message box to be created. If this parameter is
NULL, the message box has no owner window.
Type: LPCTSTR
Type: LPCTSTR
The dialog box title. If this parameter is NULL, the default title Error is used.
[in] uType
Type: UINT
The contents and behavior of the dialog box. For information on the supported flags,
see MessageBox.
[in] wLanguageId
Type: WORD
The language for the text displayed in the message box button(s). Specifying a value of
zero (0) indicates to display the button text in the default system language. If this
parameter is MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) , the current language
associated with the calling thread is used.
To specify a language other than the current language, use the MAKELANGID macro to
create this parameter. For more information, see MAKELANGID.
Return value
Type: int
If a message box has a Cancel button, the function returns the IDCANCEL value if either
the ESC key is pressed or the Cancel button is selected. If the message box has no
Cancel button, pressing ESC will no effect - unless an MB_OK button is present. If an
MB_OK button is displayed and the user presses ESC, the return value will be IDOK.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
If the function succeeds, the return value is one of the following menu-item values.
Remarks
When you use a system-modal message box to indicate that the system is low on
memory, the strings pointed to by the lpText and lpCaption parameters should not be
taken from a resource file because an attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box
as the hWnd parameter. The hWnd parameter should not identify a child window, such
as a control in a dialog box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
MAKELANGID
MessageBeep
MessageBox
MessageBoxIndirect
Other Resources
Reference
SetForegroundWindow
Feedback
Was this page helpful? ツ Yes ト No
Creates, displays, and operates a message box. The message box contains application-
defined message text and title, any icon, and any combination of predefined push
buttons.
Syntax
C++
int MessageBoxIndirectA(
[in] const MSGBOXPARAMSA *lpmbp
);
Parameters
[in] lpmbp
Return value
Type: int
If the function succeeds, the return value is one of the following menu-item values.
If a message box has a Cancel button, the function returns the IDCANCEL value if either
the ESC key is pressed or the Cancel button is selected. If the message box has no
Cancel button, pressing ESC has no effect.
If there is not enough memory to create the message box, the return value is zero.
Remarks
When you use a system-modal message box to indicate that the system is low on
memory, the strings pointed to by the lpszText and lpszCaption members of the
MSGBOXPARAMS structure should not be taken from a resource file, because an
attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box
as the hWnd parameter. The hWnd parameter should not identify a child window, such
as a control in a dialog box.
7 Note
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
MSGBOXPARAMS
MessageBox
MessageBoxEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Creates, displays, and operates a message box. The message box contains application-
defined message text and title, any icon, and any combination of predefined push
buttons.
Syntax
C++
int MessageBoxIndirectW(
[in] const MSGBOXPARAMSW *lpmbp
);
Parameters
[in] lpmbp
Return value
Type: int
If the function succeeds, the return value is one of the following menu-item values.
If a message box has a Cancel button, the function returns the IDCANCEL value if either
the ESC key is pressed or the Cancel button is selected. If the message box has no
Cancel button, pressing ESC has no effect.
If there is not enough memory to create the message box, the return value is zero.
Remarks
When you use a system-modal message box to indicate that the system is low on
memory, the strings pointed to by the lpszText and lpszCaption members of the
MSGBOXPARAMS structure should not be taken from a resource file, because an
attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box
as the hWnd parameter. The hWnd parameter should not identify a child window, such
as a control in a dialog box.
7 Note
Requirements
Minimum supported client Windows 2000 Professional [desktop apps only]
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
MSGBOXPARAMS
MessageBox
MessageBoxEx
Reference
Feedback
Was this page helpful? ツ Yes ト No
Displays a modal dialog box that contains a system icon, a set of buttons, and a brief
application-specific message, such as status or error information. The message box
returns an integer value that indicates which button the user clicked.
Syntax
C++
int MessageBoxW(
[in, optional] HWND hWnd,
[in, optional] LPCWSTR lpText,
[in, optional] LPCWSTR lpCaption,
[in] UINT uType
);
Parameters
[in, optional] hWnd
Type: HWND
A handle to the owner window of the message box to be created. If this parameter is
NULL, the message box has no owner window.
Type: LPCTSTR
The message to be displayed. If the string consists of more than one line, you can
separate the lines using a carriage return and/or linefeed character between each line.
Type: LPCTSTR
The dialog box title. If this parameter is NULL, the default title is Error.
[in] uType
Type: UINT
The contents and behavior of the dialog box. This parameter can be a combination of
flags from the following groups of flags.
To indicate the buttons displayed in the message box, specify one of the following
values.
Value Meaning
MB_HELP Adds a Help button to the message box. When the user
0x00004000L clicks the Help button or presses F1, the system sends a
WM_HELP message to the owner.
MB_OK The message box contains one push button: OK. This is
0x00000000L the default.
MB_RETRYCANCEL The message box contains two push buttons: Retry and
0x00000005L Cancel.
MB_YESNO The message box contains two push buttons: Yes and No.
0x00000004L
MB_YESNOCANCEL The message box contains three push buttons: Yes, No,
0x00000003L and Cancel.
To display an icon in the message box, specify one of the following values.
Value Meaning
Value Meaning
To indicate the modality of the dialog box, specify one of the following values.
Value Meaning
Value Meaning
Return value
Type: int
If a message box has a Cancel button, the function returns the IDCANCEL value if either
the ESC key is pressed or the Cancel button is selected. If the message box has no
Cancel button, pressing ESC will no effect - unless an MB_OK button is present. If an
MB_OK button is displayed and the user presses ESC, the return value will be IDOK.
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
If the function succeeds, the return value is one of the following menu-item values.
Remarks
The following system icons can be used in a message box by setting the uType
parameter to the corresponding flag value.
MB_ICONQUESTION
MB_ICONEXCLAMATION or MB_ICONWARNING
MB_ICONASTERISK or MB_ICONINFORMATION
When you use a system-modal message box to indicate that the system is low on
memory, the strings pointed to by the lpText and lpCaption parameters should not be
taken from a resource file because an attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box
as the hWnd parameter. The hWnd parameter should not identify a child window, such
as a control in a dialog box.
Examples
In the following example, the application displays a message box that prompts the user
for an action after an error condition has occurred. The message box displays the
message that describes the error condition and how to resolve it. The
MB_CANCELTRYCONTINUE style directs MessageBox to provide three buttons with
which the user can choose how to proceed. The MB_DEFBUTTON2 style sets the default
focus on the second button of the message box, in this case, the Try Again button.
C++
int DisplayResourceNAMessageBox()
{
int msgboxID = MessageBox(
NULL,
(LPCWSTR)L"Resource not available\nDo you want to try again?",
(LPCWSTR)L"Account Details",
MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2
);
switch (msgboxID)
{
case IDCANCEL:
// TODO: add code
break;
case IDTRYAGAIN:
// TODO: add code
break;
case IDCONTINUE:
// TODO: add code
break;
}
return msgboxID;
}
The following image shows the output from the preceding code example:
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
FlashWindow
MessageBeep
MessageBoxEx
MessageBoxIndirect
Other Resources
Reference
SetForegroundWindow
Feedback
Was this page helpful? ツ Yes ト No
A callback function, which you define in your application, that processes help events for
the message box. The MSGBOXCALLBACK type defines a pointer to this callback
function. The MsgBoxCallback name is a placeholder for the name of the function that
you define in your application.
Syntax
C++
MSGBOXCALLBACK Msgboxcallback;
void Msgboxcallback(
LPHELPINFO lpHelpInfo
)
{...}
Parameters
lpHelpInfo
Type: LPHELPINFO
Information about the item for which context-sensitive help has been requested.
Return value
None
Requirements
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
Members
cbSize
Type: UINT
hwndOwner
Type: HWND
hInstance
Type: HINSTANCE
A handle to the module that contains the icon resource identified by the lpszIcon
member, and the string resource identified by the lpszText or lpszCaption member.
lpszText
Type: LPCTSTR
A null-terminated string, or the identifier of a string resource, that contains the message
to be displayed.
lpszCaption
Type: LPCTSTR
A null-terminated string, or the identifier of a string resource, that contains the message
box title. If this member is NULL, the default title Error is used.
dwStyle
Type: DWORD
The contents and behavior of the dialog box. This member can be a combination of
flags described for the uType parameter of the MessageBoxEx function.
In addition, you can specify the MB_USERICON flag (0x00000080L) if you want the
message box to display the icon specified by the lpszIcon member.
lpszIcon
Type: LPCTSTR
To load one of the standard system-defined icons, set the hInstance member to NULL
and set lpszIcon to one of the values listed with the LoadIcon function.
This member is ignored if the dwStyle member does not specify the MB_USERICON
flag.
dwContextHelpId
Type: DWORD_PTR
Identifies a help context. If a help event occurs, this value is specified in the HELPINFO
structure that the message box sends to the owner window or callback function.
lpfnMsgBoxCallback
Type: MSGBOXCALLBACK
A pointer to the callback function that processes help events for the message box. The
callback function has the following form:
If this member is NULL, then the message box sends WM_HELP messages to the owner
window when help events occur.
dwLanguageId
Type: DWORD
The language in which to display the text contained in the predefined push buttons. This
value must be in the form returned by the MAKELANGID macro.
For a list of supported language identifiers, see Language Identifiers. Note that each
localized release of Windows typically contains resources only for a limited set of
languages. Thus, for example, the U.S. version offers LANG_ENGLISH, the French version
offers LANG_FRENCH, the German version offers LANG_GERMAN, and the Japanese
version offers LANG_JAPANESE. Each version offers LANG_NEUTRAL. This limits the set
of values that can be used with the dwLanguageId parameter. Before specifying a
language identifier, you should enumerate the locales that are installed on a system.
Remarks
7 Note
Requirements
Dialog Boxes
HELPINFO
LoadIcon
MAKEINTRESOURCE
MAKELANGID
MessageBoxEx
MessageBoxIndirect
Other Resources
Reference
WM_HELP
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
Members
cbSize
Type: UINT
hwndOwner
Type: HWND
hInstance
Type: HINSTANCE
A handle to the module that contains the icon resource identified by the lpszIcon
member, and the string resource identified by the lpszText or lpszCaption member.
lpszText
Type: LPCTSTR
A null-terminated string, or the identifier of a string resource, that contains the message
to be displayed.
lpszCaption
Type: LPCTSTR
A null-terminated string, or the identifier of a string resource, that contains the message
box title. If this member is NULL, the default title Error is used.
dwStyle
Type: DWORD
The contents and behavior of the dialog box. This member can be a combination of
flags described for the uType parameter of the MessageBoxEx function.
In addition, you can specify the MB_USERICON flag (0x00000080L) if you want the
message box to display the icon specified by the lpszIcon member.
lpszIcon
Type: LPCTSTR
To load one of the standard system-defined icons, set the hInstance member to NULL
and set lpszIcon to one of the values listed with the LoadIcon function.
This member is ignored if the dwStyle member does not specify the MB_USERICON
flag.
dwContextHelpId
Type: DWORD_PTR
Identifies a help context. If a help event occurs, this value is specified in the HELPINFO
structure that the message box sends to the owner window or callback function.
lpfnMsgBoxCallback
Type: MSGBOXCALLBACK
A pointer to the callback function that processes help events for the message box. The
callback function has the following form:
If this member is NULL, then the message box sends WM_HELP messages to the owner
window when help events occur.
dwLanguageId
Type: DWORD
The language in which to display the text contained in the predefined push buttons. This
value must be in the form returned by the MAKELANGID macro.
For a list of supported language identifiers, see Language Identifiers. Note that each
localized release of Windows typically contains resources only for a limited set of
languages. Thus, for example, the U.S. version offers LANG_ENGLISH, the French version
offers LANG_FRENCH, the German version offers LANG_GERMAN, and the Japanese
version offers LANG_JAPANESE. Each version offers LANG_NEUTRAL. This limits the set
of values that can be used with the dwLanguageId parameter. Before specifying a
language identifier, you should enumerate the locales that are installed on a system.
Remarks
7 Note
Requirements
See also
Conceptual
Dialog Boxes
HELPINFO
LoadIcon
MAKEINTRESOURCE
MAKELANGID
MessageBoxEx
MessageBoxIndirect
Other Resources
Reference
WM_HELP
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
LRESULT SendDlgItemMessageA(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] UINT Msg,
[in] WPARAM wParam,
[in] LPARAM lParam
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
[in] Msg
Type: UINT
[in] wParam
Type: WPARAM
Additional message-specific information.
[in] lParam
Type: LPARAM
Return value
Type: LRESULT
The return value specifies the result of the message processing and depends on the
message sent.
Remarks
The SendDlgItemMessage function does not return until the message has been
processed.
Examples
For an example, see Creating a Modeless Dialog Box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
Reference
SendMessage
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
LRESULT SendDlgItemMessageW(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] UINT Msg,
[in] WPARAM wParam,
[in] LPARAM lParam
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
[in] Msg
Type: UINT
[in] wParam
Type: WPARAM
Additional message-specific information.
[in] lParam
Type: LPARAM
Return value
Type: LRESULT
The return value specifies the result of the message processing and depends on the
message sent.
Remarks
The SendDlgItemMessage function does not return until the message has been
processed.
Examples
For an example, see Creating a Modeless Dialog Box.
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
Reference
SendMessage
Feedback
Was this page helpful? ツ Yes ト No
Sets the text of a control in a dialog box to the string representation of a specified
integer value.
Syntax
C++
BOOL SetDlgItemInt(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] UINT uValue,
[in] BOOL bSigned
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
[in] uValue
Type: UINT
[in] bSigned
Type: BOOL
Indicates whether the uValue parameter is signed or unsigned. If this parameter is TRUE,
uValue is signed. If this parameter is TRUE and uValue is less than zero, a minus sign is
placed before the first digit in the string. If this parameter is FALSE, uValue is unsigned.
Return value
Type: BOOL
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
To set the new text, this function sends a WM_SETTEXT message to the specified control.
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDlgItemInt
Reference
SetDlgItemText
WM_SETTEXT
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
BOOL SetDlgItemTextA(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] LPCSTR lpString
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
[in] lpString
Type: LPCTSTR
Return value
Type: BOOL
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
The SetDlgItemText function sends a WM_SETTEXT message to the specified control.
Examples
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDlgItemInt
GetDlgItemText
Reference
SetDlgItemInt
WM_SETTEXT
Feedback
Was this page helpful? ツ Yes ト No
Syntax
C++
BOOL SetDlgItemTextW(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] LPCWSTR lpString
);
Parameters
[in] hDlg
Type: HWND
[in] nIDDlgItem
Type: int
[in] lpString
Type: LPCTSTR
Return value
Type: BOOL
If the function fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
The SetDlgItemText function sends a WM_SETTEXT message to the specified control.
Examples
7 Note
Requirements
Library User32.lib
DLL User32.dll
See also
Conceptual
Dialog Boxes
GetDlgItemInt
GetDlgItemText
Reference
SetDlgItemInt
WM_SETTEXT
Feedback
Was this page helpful? ツ Yes ト No