Thanks to visit codestin.com
Credit goes to www.scribd.com

100% found this document useful (1 vote)
52 views553 pages

Windows Win32 API Dlgbox

Uploaded by

mgarciale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
52 views553 pages

Windows Win32 API Dlgbox

Uploaded by

mgarciale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 553

Tell us about your PDF experience.

Dialog Boxes
Article03/13/2023

Overview of the Dialog Boxes technology.

To develop Dialog Boxes, you need these headers:

commdlg.h

For programming guidance for this technology, see:

Dialog Boxes

Functions

AddRef

The IPrintDialogCallback::AddRef method (commdlg.h) is IUnknown's AddRef method, which


decrements the reference count for an interface on a COM object.

AddRef

The IPrintDialogServices::AddRef method (commdlg.h) is IUnknown's AddRef method, which


decrements the reference count for an interface on a COM object.

CDSIZEOF_STRUCT

Gets the size of a struct up to the specified member

ChooseColorA

The CHOOSECOLORA (ANSI) function (commdlg.h) contains information the ChooseColor


function uses to initialize the Color dialog box.

ChooseColorW

Wide string version of ChooseColor

ChooseFontA

ASCII version of ChooseFont

ChooseFontW

Wide string version of ChooseFont


CommDlg_OpenSave_GetFilePathA

ASCII version of CommDlg_OpenSave_GetFilePath

CommDlg_OpenSave_GetFilePathW

Wide string version of CommDlg_OpenSave_GetFilePath

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

ASCII version of CommDlg_OpenSave_GetFolderPath

CommDlg_OpenSave_GetFolderPathW

Wide string version of CommDlg_OpenSave_GetFolderPath

CommDlg_OpenSave_GetSpecA

ASCII version of CommDlg_OpenSave_GetSpec

CommDlg_OpenSave_GetSpecW

Wide string version of CommDlg_OpenSave_GetSpec

CommDlg_OpenSave_HideControl

Hides the specified control in an Explorer-style Open or Save As dialog box.

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

Retrieves the identifier of the specified control.

GetDlgItem

Retrieves a handle to a control in the specified dialog box.

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

Retrieves the name of the specified file. (ANSI)

GetFileTitleW

Retrieves the name of the specified file. (Unicode)


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.

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

Receives notification messages sent from the dialog box.

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

Converts the specified dialog box units to screen units (pixels).


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

Creates, displays, and operates a message box. (Unicode)

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

ASCII version of PageSetupDlg

PageSetupDlgW

Wide string version of PageSetupDlg

PrintDlgA
ASCII version of PrintDlg

PrintDlgExA

ASCII version of PrintDlgEx

PrintDlgExW

Wide string version of PrintDlgEx

PrintDlgW

Wide string version of PrintDlg

QueryInterface

The IPrintDialogCallback::QueryInterface method (commdlg.h) is IUnknown's QueryInterface


method, which queries a COM object for a pointer.

QueryInterface

The IPrintDialogServices::QueryInterface method (commdlg.h) is IUnknown's QueryInterface


method, which queries a COM object for a pointer.

Release

The IPrintDialogCallback::Release method (commdlg.h) is IUnknown's Release method, which


decrements the reference count for an interface on a COM object.

Release

The IPrintDialogServices::Release method (commdlg.h) is IUnknown's Release method, which


decrements the reference count for an interface on a COM object.

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

Sends a message to the specified control in a dialog box. (ANSI)

SendDlgItemMessageW

Sends a message to the specified control in a dialog box. (Unicode)

SetDlgItemInt

Sets the text of a control in a dialog box to the string representation of a specified integer value.

SetDlgItemTextA

Sets the title or text of a control in a dialog box. (ANSI)

SetDlgItemTextW

Sets the title or text of a control in a dialog box. (Unicode)

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

Defines the dimensions and style of a dialog box.

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

Contains information about a CDN_INCLUDEITEM notification message. (ANSI)


OFNOTIFYEXW

Contains information about a CDN_INCLUDEITEM notification message. (Unicode)

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

The OPENFILENAME_NT4 structure is identical to OPENFILENAME with _WIN32_WINNT set to


0x0400. (Unicode)

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

Get help at Microsoft Q&A


commdlg.h header
Article03/13/2023

This header is used by Dialog Boxes. For more information, see:

Dialog Boxes

commdlg.h contains the following programming interfaces:

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

Gets the size of a struct up to the specified member

CommDlg_OpenSave_GetFilePathA

ASCII version of CommDlg_OpenSave_GetFilePath

CommDlg_OpenSave_GetFilePathW

Wide string version of CommDlg_OpenSave_GetFilePath

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

ASCII version of CommDlg_OpenSave_GetFolderPath

CommDlg_OpenSave_GetFolderPathW

Wide string version of CommDlg_OpenSave_GetFolderPath

CommDlg_OpenSave_GetSpecA

ASCII version of CommDlg_OpenSave_GetSpec

CommDlg_OpenSave_GetSpecW

Wide string version of CommDlg_OpenSave_GetSpec

CommDlg_OpenSave_HideControl

Hides the specified control in an Explorer-style Open or Save As dialog box.

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

Retrieves the name of the specified file. (ANSI)

GetFileTitleW

Retrieves the name of the specified file. (Unicode)


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)

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

The CHOOSECOLORA (ANSI) function (commdlg.h) contains information the ChooseColor


function uses to initialize the Color dialog box.

ChooseColorW

Wide string version of ChooseColor

ChooseFontA

ASCII version of ChooseFont


ChooseFontW

Wide string version of ChooseFont

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

Receives notification messages sent from the dialog box.

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

ASCII version of PageSetupDlg

PageSetupDlgW

Wide string version of PageSetupDlg

PrintDlgA

ASCII version of PrintDlg

PrintDlgExA

ASCII version of PrintDlgEx

PrintDlgExW

Wide string version of PrintDlgEx

PrintDlgW

Wide string version of PrintDlg

Structures

CHOOSECOLORA

The CHOOSECOLORA (ANSI) structure (commdlg.h) contains information the ChooseColor


function uses to initialize the Color dialog box.

CHOOSECOLORA

The CHOOSECOLORA (ANSI) structure r1 (commdlg.h) contains information the ChooseColor


function uses to initialize the Color dialog box.

CHOOSECOLORW

The CHOOSECOLORW (Unicode) structure (commdlg.h) contains information the ChooseColor


function uses to initialize the Color dialog box.

CHOOSECOLORW

The CHOOSECOLORW (Unicode) structure r1 (commdlg.h) contains information the ChooseColor


function uses to initialize the Color dialog box.
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.

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

Contains information about a CDN_INCLUDEITEM notification message. (ANSI)

OFNOTIFYEXW

Contains information about a CDN_INCLUDEITEM notification message. (Unicode)

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

The OPENFILENAME_NT4 structure is identical to OPENFILENAME with _WIN32_WINNT set to


0x0400. (Unicode)

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

Get help at Microsoft Q&A


CDSIZEOF_STRUCT macro (commdlg.h)
Article06/28/2022

Gets the size of a struct up to the specified member

Syntax
C++

void CDSIZEOF_STRUCT(
structname,
member
);

Parameters
structname

The struct for which a size will be calculated

member

The member at which to stop calculating size

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

ASCII version of ChooseColor

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

Get help at Microsoft Q&A


ChooseColorW callback function
(commdlg.h)
Article06/28/2022

Wide string version of ChooseColor

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

Get help at Microsoft Q&A


ChooseFontA callback function
(commdlg.h)
Article06/28/2022

ASCII version of ChooseFont

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

Get help at Microsoft Q&A


CHOOSEFONTA structure (commdlg.h)
Article07/27/2022

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++

typedef struct tagCHOOSEFONTA {


DWORD lStructSize;
HWND hwndOwner;
HDC hDC;
LPLOGFONTA lpLogFont;
INT iPointSize;
DWORD Flags;
COLORREF rgbColors;
LPARAM lCustData;
LPCFHOOKPROC lpfnHook;
LPCSTR lpTemplateName;
HINSTANCE hInstance;
LPSTR lpszStyle;
WORD nFontType;
WORD ___MISSING_ALIGNMENT__;
INT nSizeMin;
INT nSizeMax;
} CHOOSEFONTA;

Members
lStructSize

Type: DWORD

The length of the structure, in bytes.

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

This member is ignored by the ChooseFont function.

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

A pointer to a LOGFONT structure. If you set the CF_INITTOLOGFONTSTRUCT flag in the


Flags member and initialize the other members, the ChooseFont function initializes the
dialog box with a font that matches the LOGFONT members. If the user clicks the OK
button, ChooseFont sets the members of the LOGFONT structure based on the user's
selections.

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_ANSIONLY This flag is obsolete. To limit font selections to all scripts


0x00000400L except those that use the OEM or Symbol character sets,
use CF_SCRIPTSONLY. To get the original CF_ANSIONLY
behavior, use CF_SELECTSCRIPT and specify
ANSI_CHARSET in the lfCharSet member of the
LOGFONT structure pointed to by lpLogFont.

CF_BOTH This flag is ignored for font enumeration.


0x00000003 Windows Vista and Windows XP/2000: Causes the
dialog box to list the available printer and screen fonts.
The hDC member is a handle to the device context or
information context associated with the printer. This flag
is a combination of the CF_SCREENFONTS and
CF_PRINTERFONTS flags.

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_ENABLEHOOK Enables the hook procedure specified in the lpfnHook


0x00000008L member of this structure.

CF_ENABLETEMPLATE Indicates that the hInstance and lpTemplateName


0x00000010L members specify a dialog box template to use in place of
the default template.

CF_ENABLETEMPLATEHANDLE Indicates that the hInstance member identifies a data


0x00000020L block that contains a preloaded dialog box template. The
system ignores the lpTemplateName member if this flag
is specified.

CF_FIXEDPITCHONLY ChooseFont should enumerate and allow selection of


0x00004000L only fixed-pitch fonts.

CF_FORCEFONTEXIST ChooseFont should indicate an error condition if the user


0x00010000L attempts to select a font or style that is not listed in the
dialog box.

CF_INACTIVEFONTS ChooseFont should additionally display fonts that are set


0x02000000L to Hide in Fonts Control Panel.

Windows Vista and Windows XP/2000: This flag is not


supported until Windows 7.

CF_INITTOLOGFONTSTRUCT ChooseFont should use the structure pointed to by the


0x00000040L lpLogFont member to initialize the dialog box controls.

CF_LIMITSIZE ChooseFont should select only font sizes within the range
0x00002000L specified by the nSizeMin and nSizeMax members.

CF_NOOEMFONTS Same as the CF_NOVECTORFONTS flag.


0x00000800L

CF_NOFACESEL When using a LOGFONT structure to initialize the dialog


0x00080000L box controls, use this flag to prevent the dialog box from
displaying an initial selection for the font name combo
box. This is useful when there is no single font name that
applies to the text selection.

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_NOSIMULATIONS ChooseFont should not display or allow selection of font


0x00001000L simulations.

CF_NOSIZESEL When using a structure to initialize the dialog box


0x00200000L controls, use this flag to prevent the dialog box from
displaying an initial selection for the Font Size combo
box. This is useful when there is no single font size that
applies to the text selection.

CF_NOSTYLESEL When using a LOGFONT structure to initialize the dialog


0x00100000L box controls, use this flag to prevent the dialog box from
displaying an initial selection for the Font Style combo
box. This is useful when there is no single font style that
applies to the text selection.

CF_NOVECTORFONTS ChooseFont should not allow vector font selections.


0x00000800L

CF_NOVERTFONTS Causes the Font dialog box to list only horizontally


0x01000000L oriented fonts.

CF_PRINTERFONTS This flag is ignored for font enumeration.


0x00000002 Windows Vista and Windows XP/2000: Causes the
dialog box to list only the fonts supported by the printer
associated with the device context or information context
identified by the hDC member. It also causes the font
type description label to appear at the bottom of the
Font dialog box.

CF_SCALABLEONLY Specifies that ChooseFont should allow only the selection


0x00020000L of scalable fonts. Scalable fonts include vector fonts,
scalable printer fonts, TrueType fonts, and fonts scaled by
other technologies.

CF_SCREENFONTS This flag is ignored for font enumeration.


0x00000001
Windows Vista and Windows XP/2000: Causes the
dialog box to list only the screen fonts supported by the
system.

CF_SCRIPTSONLY ChooseFont should allow selection of fonts for all non-


0x00000400L OEM and Symbol character sets, as well as the ANSI
character set. This supersedes the CF_ANSIONLY value.

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.

CF_TTONLY ChooseFont should only enumerate and allow the


0x00040000L selection of TrueType fonts.

CF_USESTYLE The lpszStyle member is a pointer to a buffer that


0x00000080L contains style data that ChooseFont should use to
initialize the Font Style combo box. When the user closes
the dialog box, ChooseFont copies style data for the
user's selection to this buffer.

Note To globalize your application, you


should specify the style by using the lfWeight
and lfItalic members of the LOGFONT
structure pointed to by lpLogFont. The style
name may change depending on the system
user interface language.

CF_WYSIWYG Obsolete. ChooseFont ignores this flag.


0x00008000L
Windows Vista and Windows XP/2000: ChooseFont
should allow only the selection of fonts available on both
the printer and the display. If this flag is specified, the
CF_SCREENSHOTS and CF_PRINTERFONTS, or CF_BOTH
flags should also be specified.

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

If the CF_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a


handle to a memory object containing a dialog box template. If the
CF_ENABLETEMPLATE flag is set, hInstance is a handle to a module that contains a
dialog box template named by the lpTemplateName member. If neither
CF_ENABLETEMPLATEHANDLE nor CF_ENABLETEMPLATE is set, this member is
ignored.

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

BOLD_FONTTYPE The font weight is bold. This information is duplicated in


0x0100 the lfWeight member of the LOGFONT structure and is
equivalent to FW_BOLD.

ITALIC_FONTTYPE The italic font attribute is set. This information is


0x0200 duplicated in the lfItalic member of the LOGFONT
structure.

PRINTER_FONTTYPE The font is a printer font.


0x4000

REGULAR_FONTTYPE The font weight is normal. This information is duplicated


0x0400 in the lfWeight member of the LOGFONT structure and is
equivalent to FW_REGULAR.

SCREEN_FONTTYPE The font is a screen font.


0x2000

SIMULATED_FONTTYPE The font is simulated by the graphics device interface


0x8000 (GDI).

___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

The commdlg.h header defines CHOOSEFONT 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h

See also
ChooseFont

Common Dialog Box Library

Conceptual

MAKEINTRESOURCE

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


ChooseFontW callback function
(commdlg.h)
Article06/28/2022

Wide string version of ChooseFont

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

Get help at Microsoft Q&A


CHOOSEFONTW structure (commdlg.h)
Article07/27/2022

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++

typedef struct tagCHOOSEFONTW {


DWORD lStructSize;
HWND hwndOwner;
HDC hDC;
LPLOGFONTW lpLogFont;
INT iPointSize;
DWORD Flags;
COLORREF rgbColors;
LPARAM lCustData;
LPCFHOOKPROC lpfnHook;
LPCWSTR lpTemplateName;
HINSTANCE hInstance;
LPWSTR lpszStyle;
WORD nFontType;
WORD ___MISSING_ALIGNMENT__;
INT nSizeMin;
INT nSizeMax;
} CHOOSEFONTW;

Members
lStructSize

Type: DWORD

The length of the structure, in bytes.

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

This member is ignored by the ChooseFont function.

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

A pointer to a LOGFONT structure. If you set the CF_INITTOLOGFONTSTRUCT flag in the


Flags member and initialize the other members, the ChooseFont function initializes the
dialog box with a font that matches the LOGFONT members. If the user clicks the OK
button, ChooseFont sets the members of the LOGFONT structure based on the user's
selections.

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_ANSIONLY This flag is obsolete. To limit font selections to all scripts


0x00000400L except those that use the OEM or Symbol character sets,
use CF_SCRIPTSONLY. To get the original CF_ANSIONLY
behavior, use CF_SELECTSCRIPT and specify
ANSI_CHARSET in the lfCharSet member of the
LOGFONT structure pointed to by lpLogFont.

CF_BOTH This flag is ignored for font enumeration.


0x00000003 Windows Vista and Windows XP/2000: Causes the
dialog box to list the available printer and screen fonts.
The hDC member is a handle to the device context or
information context associated with the printer. This flag
is a combination of the CF_SCREENFONTS and
CF_PRINTERFONTS flags.

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_ENABLEHOOK Enables the hook procedure specified in the lpfnHook


0x00000008L member of this structure.

CF_ENABLETEMPLATE Indicates that the hInstance and lpTemplateName


0x00000010L members specify a dialog box template to use in place of
the default template.

CF_ENABLETEMPLATEHANDLE Indicates that the hInstance member identifies a data


0x00000020L block that contains a preloaded dialog box template. The
system ignores the lpTemplateName member if this flag
is specified.

CF_FIXEDPITCHONLY ChooseFont should enumerate and allow selection of


0x00004000L only fixed-pitch fonts.

CF_FORCEFONTEXIST ChooseFont should indicate an error condition if the user


0x00010000L attempts to select a font or style that is not listed in the
dialog box.

CF_INACTIVEFONTS ChooseFont should additionally display fonts that are set


0x02000000L to Hide in Fonts Control Panel.

Windows Vista and Windows XP/2000: This flag is not


supported until Windows 7.

CF_INITTOLOGFONTSTRUCT ChooseFont should use the structure pointed to by the


0x00000040L lpLogFont member to initialize the dialog box controls.

CF_LIMITSIZE ChooseFont should select only font sizes within the range
0x00002000L specified by the nSizeMin and nSizeMax members.

CF_NOOEMFONTS Same as the CF_NOVECTORFONTS flag.


0x00000800L

CF_NOFACESEL When using a LOGFONT structure to initialize the dialog


0x00080000L box controls, use this flag to prevent the dialog box from
displaying an initial selection for the font name combo
box. This is useful when there is no single font name that
applies to the text selection.

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_NOSIMULATIONS ChooseFont should not display or allow selection of font


0x00001000L simulations.

CF_NOSIZESEL When using a structure to initialize the dialog box


0x00200000L controls, use this flag to prevent the dialog box from
displaying an initial selection for the Font Size combo
box. This is useful when there is no single font size that
applies to the text selection.

CF_NOSTYLESEL When using a LOGFONT structure to initialize the dialog


0x00100000L box controls, use this flag to prevent the dialog box from
displaying an initial selection for the Font Style combo
box. This is useful when there is no single font style that
applies to the text selection.

CF_NOVECTORFONTS ChooseFont should not allow vector font selections.


0x00000800L

CF_NOVERTFONTS Causes the Font dialog box to list only horizontally


0x01000000L oriented fonts.

CF_PRINTERFONTS This flag is ignored for font enumeration.


0x00000002 Windows Vista and Windows XP/2000: Causes the
dialog box to list only the fonts supported by the printer
associated with the device context or information context
identified by the hDC member. It also causes the font
type description label to appear at the bottom of the
Font dialog box.

CF_SCALABLEONLY Specifies that ChooseFont should allow only the selection


0x00020000L of scalable fonts. Scalable fonts include vector fonts,
scalable printer fonts, TrueType fonts, and fonts scaled by
other technologies.

CF_SCREENFONTS This flag is ignored for font enumeration.


0x00000001
Windows Vista and Windows XP/2000: Causes the
dialog box to list only the screen fonts supported by the
system.

CF_SCRIPTSONLY ChooseFont should allow selection of fonts for all non-


0x00000400L OEM and Symbol character sets, as well as the ANSI
character set. This supersedes the CF_ANSIONLY value.

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.

CF_TTONLY ChooseFont should only enumerate and allow the


0x00040000L selection of TrueType fonts.

CF_USESTYLE The lpszStyle member is a pointer to a buffer that


0x00000080L contains style data that ChooseFont should use to
initialize the Font Style combo box. When the user closes
the dialog box, ChooseFont copies style data for the
user's selection to this buffer.

Note To globalize your application, you


should specify the style by using the lfWeight
and lfItalic members of the LOGFONT
structure pointed to by lpLogFont. The style
name may change depending on the system
user interface language.

CF_WYSIWYG Obsolete. ChooseFont ignores this flag.


0x00008000L
Windows Vista and Windows XP/2000: ChooseFont
should allow only the selection of fonts available on both
the printer and the display. If this flag is specified, the
CF_SCREENSHOTS and CF_PRINTERFONTS, or CF_BOTH
flags should also be specified.

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

If the CF_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a


handle to a memory object containing a dialog box template. If the
CF_ENABLETEMPLATE flag is set, hInstance is a handle to a module that contains a
dialog box template named by the lpTemplateName member. If neither
CF_ENABLETEMPLATEHANDLE nor CF_ENABLETEMPLATE is set, this member is
ignored.

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

BOLD_FONTTYPE The font weight is bold. This information is duplicated in


0x0100 the lfWeight member of the LOGFONT structure and is
equivalent to FW_BOLD.

ITALIC_FONTTYPE The italic font attribute is set. This information is


0x0200 duplicated in the lfItalic member of the LOGFONT
structure.

PRINTER_FONTTYPE The font is a printer font.


0x4000

REGULAR_FONTTYPE The font weight is normal. This information is duplicated


0x0400 in the lfWeight member of the LOGFONT structure and is
equivalent to FW_REGULAR.

SCREEN_FONTTYPE The font is a screen font.


0x2000

SIMULATED_FONTTYPE The font is simulated by the graphics device interface


0x8000 (GDI).

___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

The commdlg.h header defines CHOOSEFONT 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h

See also
ChooseFont

Common Dialog Box Library

Conceptual

MAKEINTRESOURCE

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


CommDlg_OpenSave_GetFilePathA
macro (commdlg.h)
Article06/28/2022

ASCII version of CommDlg_OpenSave_GetFilePath

2 Warning

Apps should generally call CommDlg_OpenSave_GetFilePath instead of calling this


method directly.

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

Get help at Microsoft Q&A


CommDlg_OpenSave_GetFilePathW
macro (commdlg.h)
Article06/28/2022

Wide string version of CommDlg_OpenSave_GetFilePath

2 Warning

Apps should generally call CommDlg_OpenSave_GetFilePath instead of calling this


method directly.

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

Get help at Microsoft Q&A


CommDlg_OpenSave_GetFolderIDList
macro (commdlg.h)
Article06/28/2022

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

Get help at Microsoft Q&A


CommDlg_OpenSave_GetFolderPathA
macro (commdlg.h)
Article06/28/2022

ASCII version of CommDlg_OpenSave_GetFolderPath

2 Warning

Apps should generally call CommDlg_OpenSave_GetFolderPath instead of calling


this method directly.

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

Get help at Microsoft Q&A


CommDlg_OpenSave_GetFolderPathW
macro (commdlg.h)
Article06/28/2022

Wide string version of CommDlg_OpenSave_GetFolderPath

2 Warning

Apps should generally call CommDlg_OpenSave_GetFolderPath instead of calling


this method directly.

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

Get help at Microsoft Q&A


CommDlg_OpenSave_GetSpecA macro
(commdlg.h)
Article06/28/2022

ASCII version of CommDlg_OpenSave_GetSpec

2 Warning

Apps should generally call CommDlg_OpenSave_GetSpec instead of calling this


method directly.

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

Get help at Microsoft Q&A


CommDlg_OpenSave_GetSpecW macro
(commdlg.h)
Article06/28/2022

Wide string version of CommDlg_OpenSave_GetSpec

2 Warning

Apps should generally call CommDlg_OpenSave_GetSpec instead of calling this


method directly.

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

Get help at Microsoft Q&A


CommDlg_OpenSave_HideControl
macro (commdlg.h)
Article06/28/2022

Hides the specified control in an Explorer-style Open or Save As dialog box.

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

Get help at Microsoft Q&A


CommDlg_OpenSave_SetControlText
macro (commdlg.h)
Article06/28/2022

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

Get help at Microsoft Q&A


CommDlg_OpenSave_SetDefExt macro
(commdlg.h)
Article06/28/2022

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

Get help at Microsoft Q&A


CommDlgExtendedError function
(commdlg.h)
Article03/13/2023

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.

Return code/value Description

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_FINDRESFAILURE The common dialog box function failed to find a specified


0x0006 resource.

CDERR_INITIALIZATION The common dialog box function failed during


0x0002 initialization. This error often occurs when sufficient
memory is not available.
CDERR_LOADRESFAILURE The common dialog box function failed to load a
0x0007 specified resource.

CDERR_LOADSTRFAILURE The common dialog box function failed to load a


0x0005 specified string.

CDERR_LOCKRESFAILURE The common dialog box function failed to lock a


0x0008 specified resource.

CDERR_MEMALLOCFAILURE The common dialog box function was unable to allocate


0x0009 memory for internal structures.

CDERR_MEMLOCKFAILURE The common dialog box function was unable to lock the
0x000A memory associated with a handle.

CDERR_NOHINSTANCE The ENABLETEMPLATE flag was set in the Flags member


0x0004 of the initialization structure for the corresponding
common dialog box, but you failed to provide a
corresponding instance handle.

CDERR_NOHOOK The ENABLEHOOK flag was set in the Flags member of


0x000B the initialization structure for the corresponding common
dialog box, but you failed to provide a pointer to a
corresponding hook procedure.

CDERR_NOTEMPLATE The ENABLETEMPLATE flag was set in the Flags member


0x0003 of the initialization structure for the corresponding
common dialog box, but you failed to provide a
corresponding template.

CDERR_REGISTERMSGFAIL The RegisterWindowMessage function returned an error


0x000C code when it was called by the common dialog box
function.

CDERR_STRUCTSIZE The lStructSize member of the initialization structure for


0x0001 the corresponding common dialog box is invalid.

The following error codes can be returned for the PrintDlg function.

Return code/value Description

PDERR_CREATEICFAILURE The PrintDlg function failed when it attempted to create


0x100A an information context.

PDERR_DEFAULTDIFFERENT You called the PrintDlg function with the


0x100C DN_DEFAULTPRN flag specified in the wDefault member
of the DEVNAMES structure, but the printer described by
the other structure members did not match the current
default printer. This error occurs when you store the
DEVNAMES structure, and the user changes the default
printer by using the Control Panel.

To use the printer described by the DEVNAMES structure,


clear the DN_DEFAULTPRN flag and call PrintDlg again.

To use the default printer, replace the DEVNAMES


structure (and the structure, if one exists) with NULL; and
call PrintDlg again.

PDERR_DNDMMISMATCH The data in the DEVMODE and DEVNAMES structures


0x1009 describes two different printers.

PDERR_GETDEVMODEFAIL The printer driver failed to initialize a DEVMODE


0x1005 structure.

PDERR_INITFAILURE The PrintDlg function failed during initialization, and


0x1006 there is no more specific extended error code to describe
the failure. This is the generic default error code for the
function.

PDERR_LOADDRVFAILURE The PrintDlg function failed to load the device driver for
0x1004 the specified printer.

PDERR_NODEFAULTPRN A default printer does not exist.


0x1008

PDERR_NODEVICES No printer drivers were found.


0x1007

PDERR_PARSEFAILURE The PrintDlg function failed to parse the strings in the


0x1002 [devices] section of the WIN.INI file.

PDERR_PRINTERNOTFOUND The [devices] section of the WIN.INI file did not contain
0x100B an entry for the requested printer.

PDERR_RETDEFFAILURE The PD_RETURNDEFAULT flag was specified in the Flags


0x1003 member of the PRINTDLG structure, but the hDevMode
or hDevNames member was not NULL.

PDERR_SETUPFAILURE The PrintDlg function failed to load the required


0x1001 resources.

The following error codes can be returned for the ChooseFont function.

Return code/value Description

CFERR_MAXLESSTHANMIN The size specified in the nSizeMax member of the


0x2002 CHOOSEFONT structure is less than the size specified in
the nSizeMin member.
CFERR_NOFONTS No fonts exist.
0x2001

The following error codes can be returned for the GetOpenFileName and
GetSaveFileName functions.

Return code/value Description

FNERR_BUFFERTOOSMALL The buffer pointed to by the lpstrFile member of the


0x3003 OPENFILENAME structure is too small for the file name
specified by the user. The first two bytes of the lpstrFile
buffer contain an integer value specifying the size
required to receive the full name, in characters.

FNERR_INVALIDFILENAME A file name is invalid.


0x3002

FNERR_SUBCLASSFAILURE An attempt to subclass a list box failed because sufficient


0x3001 memory was not available.

The following error code can be returned for the FindText and ReplaceText functions.

Return code/value Description

FRERR_BUFFERLENGTHZERO A member of the FINDREPLACE structure points to an


0x4001 invalid buffer.

Requirements

Minimum supported Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header commdlg.h (include Windows.h)

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

Common Dialog Box Library

Conceptual

DEVNAMES

DialogBox

FINDREPLACE

FindText

GetOpenFileName

GetSaveFileName

OPENFILENAME

PAGESETUPDLG

PRINTDLG

PageSetupDlg

PrintDlg

Reference

RegisterWindowMessage

ReplaceText
Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


DEVNAMES structure (commdlg.h)
Article04/02/2021

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++

typedef struct tagDEVNAMES {


WORD wDriverOffset;
WORD wDeviceOffset;
WORD wOutputOffset;
WORD wDefault;
} DEVNAMES;

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

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++

typedef struct tagFINDREPLACEA {


DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
DWORD Flags;
LPSTR lpstrFindWhat;
LPSTR lpstrReplaceWith;
WORD wFindWhatLen;
WORD wReplaceWithLen;
LPARAM lCustData;
LPFRHOOKPROC lpfnHook;
LPCSTR lpTemplateName;
} FINDREPLACEA, *LPFINDREPLACEA;

Members
lStructSize

Type: DWORD

The length, in bytes, of the structure.

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

If the FR_ENABLETEMPLATEHANDLE flag is set in the Flags, hInstance is a handle to a


memory object containing a dialog box template. If the FR_ENABLETEMPLATE flag is
set, hInstance is a handle to a module that contains a dialog box template named by
the lpTemplateName member. If neither flag is set, this member is ignored.

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_DIALOGTERM If set in a FINDMSGSTRING message, indicates that the


0x00000040 dialog box is closing. When you receive a message with
this flag set, the dialog box handle returned by the
FindText or ReplaceText function is no longer valid.

FR_DOWN If set, the Down button of the direction radio buttons in a


0x00000001 Find dialog box is selected indicating that you should
search from the current location to the end of the
document. If not set, the Up button is selected so you
should search to the beginning of the document. You can
set this flag to initialize the dialog box. If set in a
FINDMSGSTRING message, indicates the user's selection.

FR_ENABLEHOOK Enables the hook function specified in the lpfnHook


0x00000100 member. This flag is used only to initialize the dialog box.

FR_ENABLETEMPLATE Indicates that the hInstance and lpTemplateName


0x00000200 members specify a dialog box template to use in place of
the default template. This flag is used only to initialize the
dialog box.

FR_ENABLETEMPLATEHANDLE Indicates that the hInstance member identifies a data


0x00002000 block that contains a preloaded dialog box template. The
system ignores the lpTemplateName member if this flag
is specified.

FR_FINDNEXT If set in a FINDMSGSTRING message, indicates that the


0x00000008 user clicked the Find Next button in a Find or Replace
dialog box. The lpstrFindWhat member specifies the
string to search for.

FR_HIDEUPDOWN If set when initializing a Find dialog box, hides the search
0x00004000 direction radio buttons.

FR_HIDEMATCHCASE If set when initializing a Find or Replace dialog box, hides


0x00008000 the Match Case check box.

FR_HIDEWHOLEWORD If set when initializing a Find or Replace dialog box, hides


0x00010000 the Match Whole Word Only check box.

FR_MATCHCASE If set, the Match Case check box is selected indicating


0x00000004 that the search should be case-sensitive. If not set, the
check box is unselected so the search should be case-
insensitive. You can set this flag to initialize the dialog
box. If set in a FINDMSGSTRING message, indicates the
user's selection.

FR_NOMATCHCASE If set when initializing a Find or Replace dialog box,


0x00000800 disables the Match Case check box.

FR_NOUPDOWN If set when initializing a Find dialog box, disables the


0x00000400 search direction radio buttons.

FR_NOWHOLEWORD If set when initializing a Find or Replace dialog box,


0x00001000 disables the Whole Word check box.

FR_REPLACE If set in a FINDMSGSTRING message, indicates that the


0x00000010 user clicked the Replace button in a Replace dialog box.
The lpstrFindWhat member specifies the string to be
replaced and the lpstrReplaceWith member specifies the
replacement string.

FR_REPLACEALL If set in a FINDMSGSTRING message, indicates that the


0x00000020 user clicked the Replace All button in a Replace dialog
box. The lpstrFindWhat member specifies the string to be
replaced and the lpstrReplaceWith member specifies the
replacement string.

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.

If a FINDMSGSTRING message specifies the FR_REPLACE or FR_REPLACEALL flags,


lpstrReplaceWith contains the replacement string .

The FindText function ignores this member.

wFindWhatLen

Type: WORD

The length, in bytes, of the buffer pointed to by the lpstrFindWhat member.

wReplaceWithLen

Type: WORD

The length, in bytes, of the buffer pointed to by the lpstrReplaceWith member.

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

The commdlg.h header defines FINDREPLACE 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]

Minimum supported server Windows 2000 Server [desktop apps only]


Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

FRHookProc

FindText

MAKEINTRESOURCE

Reference

ReplaceText

ShowWindow

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


FINDREPLACEW 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++

typedef struct tagFINDREPLACEW {


DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
DWORD Flags;
LPWSTR lpstrFindWhat;
LPWSTR lpstrReplaceWith;
WORD wFindWhatLen;
WORD wReplaceWithLen;
LPARAM lCustData;
LPFRHOOKPROC lpfnHook;
LPCWSTR lpTemplateName;
} FINDREPLACEW, *LPFINDREPLACEW;

Members
lStructSize

Type: DWORD

The length, in bytes, of the structure.

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

If the FR_ENABLETEMPLATEHANDLE flag is set in the Flags, hInstance is a handle to a


memory object containing a dialog box template. If the FR_ENABLETEMPLATE flag is
set, hInstance is a handle to a module that contains a dialog box template named by
the lpTemplateName member. If neither flag is set, this member is ignored.

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_DIALOGTERM If set in a FINDMSGSTRING message, indicates that the


0x00000040 dialog box is closing. When you receive a message with
this flag set, the dialog box handle returned by the
FindText or ReplaceText function is no longer valid.

FR_DOWN If set, the Down button of the direction radio buttons in a


0x00000001 Find dialog box is selected indicating that you should
search from the current location to the end of the
document. If not set, the Up button is selected so you
should search to the beginning of the document. You can
set this flag to initialize the dialog box. If set in a
FINDMSGSTRING message, indicates the user's selection.

FR_ENABLEHOOK Enables the hook function specified in the lpfnHook


0x00000100 member. This flag is used only to initialize the dialog box.

FR_ENABLETEMPLATE Indicates that the hInstance and lpTemplateName


0x00000200 members specify a dialog box template to use in place of
the default template. This flag is used only to initialize the
dialog box.

FR_ENABLETEMPLATEHANDLE Indicates that the hInstance member identifies a data


0x00002000 block that contains a preloaded dialog box template. The
system ignores the lpTemplateName member if this flag
is specified.

FR_FINDNEXT If set in a FINDMSGSTRING message, indicates that the


0x00000008 user clicked the Find Next button in a Find or Replace
dialog box. The lpstrFindWhat member specifies the
string to search for.

FR_HIDEUPDOWN If set when initializing a Find dialog box, hides the search
0x00004000 direction radio buttons.

FR_HIDEMATCHCASE If set when initializing a Find or Replace dialog box, hides


0x00008000 the Match Case check box.

FR_HIDEWHOLEWORD If set when initializing a Find or Replace dialog box, hides


0x00010000 the Match Whole Word Only check box.

FR_MATCHCASE If set, the Match Case check box is selected indicating


0x00000004 that the search should be case-sensitive. If not set, the
check box is unselected so the search should be case-
insensitive. You can set this flag to initialize the dialog
box. If set in a FINDMSGSTRING message, indicates the
user's selection.

FR_NOMATCHCASE If set when initializing a Find or Replace dialog box,


0x00000800 disables the Match Case check box.

FR_NOUPDOWN If set when initializing a Find dialog box, disables the


0x00000400 search direction radio buttons.

FR_NOWHOLEWORD If set when initializing a Find or Replace dialog box,


0x00001000 disables the Whole Word check box.

FR_REPLACE If set in a FINDMSGSTRING message, indicates that the


0x00000010 user clicked the Replace button in a Replace dialog box.
The lpstrFindWhat member specifies the string to be
replaced and the lpstrReplaceWith member specifies the
replacement string.

FR_REPLACEALL If set in a FINDMSGSTRING message, indicates that the


0x00000020 user clicked the Replace All button in a Replace dialog
box. The lpstrFindWhat member specifies the string to be
replaced and the lpstrReplaceWith member specifies the
replacement string.

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.

If a FINDMSGSTRING message specifies the FR_REPLACE or FR_REPLACEALL flags,


lpstrReplaceWith contains the replacement string .

The FindText function ignores this member.

wFindWhatLen

Type: WORD

The length, in bytes, of the buffer pointed to by the lpstrFindWhat member.

wReplaceWithLen

Type: WORD

The length, in bytes, of the buffer pointed to by the lpstrReplaceWith member.

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

The commdlg.h header defines FINDREPLACE 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]

Minimum supported server Windows 2000 Server [desktop apps only]


Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

FRHookProc

FindText

MAKEINTRESOURCE

Reference

ReplaceText

ShowWindow

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


FindTextA function (commdlg.h)
Article02/09/2023

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

A pointer to a FINDREPLACE structure that contains information used to initialize the


dialog box. The dialog box uses this structure to send information about the user's input
to your application. For more information, see the following Remarks section.

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

For an example, see Finding Text.

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

Minimum supported Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server
Target Platform Windows

Header commdlg.h (include Windows.h)

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

Common Dialog Box Library

Conceptual

FINDMSGSTRING

FINDREPLACE

FRHookProc

IsDialogMessage

Reference

RegisterWindowMessage

ReplaceText

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


FindTextW function (commdlg.h)
Article02/09/2023

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

A pointer to a FINDREPLACE structure that contains information used to initialize the


dialog box. The dialog box uses this structure to send information about the user's input
to your application. For more information, see the following Remarks section.

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

For an example, see Finding Text.

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

Minimum supported Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server
Target Platform Windows

Header commdlg.h (include Windows.h)

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

Common Dialog Box Library

Conceptual

FINDMSGSTRING

FINDREPLACE

FRHookProc

IsDialogMessage

Reference

RegisterWindowMessage

ReplaceText

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetFileTitleA function (commdlg.h)
Article02/09/2023

Retrieves the name of the specified file.

Syntax
C++

short GetFileTitleA(
[in] LPCSTR unnamedParam1,
[out] LPSTR Buf,
[in] WORD cchSize
);

Parameters
[in] unnamedParam1

Type: LPCTSTR

The name and location of a file.

[out] Buf

Type: LPTSTR

The buffer that receives the name of the file.

[in] cchSize

Type: WORD

The length, in characters, of the buffer pointed to by the lpszTitle parameter.

Return value
Type: short

If the function succeeds, the return value is zero.

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

The commdlg.h header defines GetFileTitle 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 Windows 2000 Professional [desktop apps only]


client
Minimum supported Windows 2000 Server [desktop apps only]
server

Target Platform Windows

Header commdlg.h (include Windows.h)

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
Common Dialog Box Library

Conceptual

GetOpenFileName

GetSaveFileName

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetFileTitleW function (commdlg.h)
Article02/09/2023

Retrieves the name of the specified file.

Syntax
C++

short GetFileTitleW(
[in] LPCWSTR unnamedParam1,
[out] LPWSTR Buf,
[in] WORD cchSize
);

Parameters
[in] unnamedParam1

Type: LPCTSTR

The name and location of a file.

[out] Buf

Type: LPTSTR

The buffer that receives the name of the file.

[in] cchSize

Type: WORD

The length, in characters, of the buffer pointed to by the lpszTitle parameter.

Return value
Type: short

If the function succeeds, the return value is zero.

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

The commdlg.h header defines GetFileTitle 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 Windows 2000 Professional [desktop apps only]


client
Minimum supported Windows 2000 Server [desktop apps only]
server

Target Platform Windows

Header commdlg.h (include Windows.h)

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
Common Dialog Box Library

Conceptual

GetOpenFileName

GetSaveFileName

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetOpenFileNameA function
(commdlg.h)
Article02/09/2023

[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

A pointer to an OPENFILENAME structure that contains information used to initialize the


dialog box. When GetOpenFileName returns, this structure contains information about
the user's file selection.

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.

ANSI: 32k limit


Unicode: no restriction

Examples

For an example, see Opening a File.

7 Note

The commdlg.h header defines GetOpenFileName 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 Windows 2000 Professional [desktop apps only]


client
Minimum supported Windows 2000 Server [desktop apps only]
server

Target Platform Windows

Header commdlg.h (include Windows.h)

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

Common Dialog Box Library

Conceptual

GetSaveFileName

OFNHookProc

OFNHookProcOldStyle

OPENFILENAME

Other Resources

Reference

SHBrowseForFolder

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetOpenFileNameW function
(commdlg.h)
Article02/09/2023

[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

A pointer to an OPENFILENAME structure that contains information used to initialize the


dialog box. When GetOpenFileName returns, this structure contains information about
the user's file selection.

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.

ANSI: 32k limit


Unicode: no restriction

Examples

For an example, see Opening a File.

7 Note

The commdlg.h header defines GetOpenFileName 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 Windows 2000 Professional [desktop apps only]


client
Minimum supported Windows 2000 Server [desktop apps only]
server

Target Platform Windows

Header commdlg.h (include Windows.h)

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

Common Dialog Box Library

Conceptual

GetSaveFileName

OFNHookProc

OFNHookProcOldStyle

OPENFILENAME

Other Resources

Reference

SHBrowseForFolder

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetSaveFileNameA function
(commdlg.h)
Article02/09/2023

[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

A pointer to an OPENFILENAME structure that contains information used to initialize the


dialog box. When GetSaveFileName returns, this structure contains information about
the user's file selection.

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

The commdlg.h header defines GetSaveFileName 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 Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header commdlg.h (include Windows.h)

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

Common Dialog Box Library

Conceptual

GetOpenFileName

OFNHookProc

OFNHookProcOldStyle

OPENFILENAME

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetSaveFileNameW function
(commdlg.h)
Article02/09/2023

[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

A pointer to an OPENFILENAME structure that contains information used to initialize the


dialog box. When GetSaveFileName returns, this structure contains information about
the user's file selection.

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

The commdlg.h header defines GetSaveFileName 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 Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header commdlg.h (include Windows.h)

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

Common Dialog Box Library

Conceptual

GetOpenFileName

OFNHookProc

OFNHookProcOldStyle

OPENFILENAME

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogCallback interface
(commdlg.h)
Article03/13/2023

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

The IPrintDialogCallback::AddRef method (commdlg.h) is IUnknown's AddRef method, which


decrements the reference count for an interface on a COM object.

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

The IPrintDialogCallback::QueryInterface method (commdlg.h) is IUnknown's QueryInterface


method, which queries a COM object for a pointer.

IPrintDialogCallback::Release

The IPrintDialogCallback::Release method (commdlg.h) is IUnknown's Release method, which


decrements the reference count for an interface on a COM object.
IPrintDialogCallback::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.

Requirements

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

See also
IPrintDialogServices

PRINTDLGEX

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogCallback::AddRef method
(commdlg.h)
Article03/13/2023

IUnknown's AddRef method

Syntax
C++

ULONG AddRef();

Requirements

Header commdlg.h

See also
IUnknown::AddRef

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogCallback::HandleMessage
method (commdlg.h)
Article04/02/2021

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. The child dialog box contains controls similar to those of the Print dialog box.

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

The identifier of the message being received.

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.

If the uMsg parameter indicates the WM_INITDIALOG message, lParam is a pointer to a


PRINTDLGEX structure containing the values specified when the property sheet was
created.

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_OK if your IPrintDialogCallback::HandleMessage implementation handled the


message. In this case, the PrintDlgEx function does not perform any default message
handling.

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.

If HandleMessage processes the WM_CTLCOLORDLG message, it must return a valid


brush handle to painting the background of the dialog box. In general, if
HandleMessage 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 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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

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

Get help at Microsoft Q&A


IPrintDialogCallback::InitDone method
(commdlg.h)
Article06/28/2022

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]


Target Platform Windows

Header commdlg.h (include Windows.h)

DLL Comdlg32.dll

See also
Common Dialog Box Library

Conceptual

IPrintDialogCallback

IPrintDialogServices

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogCallback::QueryInterface
method (commdlg.h)
Article03/13/2023

IUnknown's QueryInterface method

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

Get help at Microsoft Q&A


IPrintDialogCallback::Release method
(commdlg.h)
Article03/13/2023

IUnknown's Release method

Syntax
C++

ULONG Release();

Requirements

Header commdlg.h

See also
IUnknown::Release

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogCallback::SelectionChange
method (commdlg.h)
Article06/28/2022

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

DLL Comdlg32.dll

See also
Common Dialog Box Library
Conceptual

IPrintDialogCallback

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogServices interface
(commdlg.h)
Article03/13/2023

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

The IPrintDialogServices::AddRef method (commdlg.h) is IUnknown's AddRef method, which


decrements the reference count for an interface on a COM object.

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

The IPrintDialogServices::QueryInterface method (commdlg.h) is IUnknown's QueryInterface


method, which queries a COM object for a pointer.
IPrintDialogServices::Release

The IPrintDialogServices::Release method (commdlg.h) is IUnknown's Release method, which


decrements the reference count for an interface on a COM object.

Remarks
This printer is indicated on the list of installed printers on the General page of the Print
Property Sheet.

Requirements

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogServices::AddRef method
(commdlg.h)
Article03/13/2023

IUnknown's AddRef method

Syntax
C++

ULONG AddRef();

Requirements

Header commdlg.h

See also
IUnknown::AddRef

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogServices::GetCurrentDevMo
de method (commdlg.h)
Article04/02/2021

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

A pointer to a buffer that receives a DEVMODE structure containing information about


the currently selected printer.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

DLL Comdlg32.dll

See also
Common Dialog Box Library

Conceptual

DEVMODE

IPrintDialogServices

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogServices::GetCurrentPortNa
me method (commdlg.h)
Article04/02/2021

Retrieves the name of the current port for use with PrintDlgEx.

Syntax
C++

HRESULT GetCurrentPortName(
LPWSTR pPortName,
UINT *pcchSize
);

Parameters
pPortName

Type: LPTSTR

The name of the current port.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

DLL Comdlg32.dll

See also
Common Dialog Box Library

Conceptual

IPrintDialogServices

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogServices::GetCurrentPrinter
Name method (commdlg.h)
Article04/02/2021

Retrieves the name of the currently selected printer, for use with PrintDlgEx.

Syntax
C++

HRESULT GetCurrentPrinterName(
LPWSTR pPrinterName,
UINT *pcchSize
);

Parameters
pPrinterName

Type: LPTSTR

The name of the currently selected printer.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

DLL Comdlg32.dll

See also
Common Dialog Box Library

Conceptual

IPrintDialogServices

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IPrintDialogServices::QueryInterface
method (commdlg.h)
Article03/13/2023

IUnknown's QueryInterface method

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

Get help at Microsoft Q&A


IPrintDialogServices::Release method
(commdlg.h)
Article03/13/2023

IUnknown's Release method

Syntax
C++

ULONG Release();

Requirements

Header commdlg.h

See also
IUnknown::Release

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


LPCCHOOKPROC callback function
(commdlg.h)
Article04/02/2021

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.

The LPCCHOOKPROC type defines a pointer to this callback function. CCHookProc is a


placeholder for the application-defined function name.

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

The identifier of the message being received.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

See also
CHOOSECOLOR

ChooseColor

Common Dialog Box Library

Conceptual

EndDialog

PostMessage

Reference

WM_CTLCOLORDLG

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


LPCFHOOKPROC callback function
(commdlg.h)
Article04/02/2021

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.

The LPCFHOOKPROC type defines a pointer to this callback function. CFHookProc is a


placeholder for the application-defined function name.

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

The identifier of the message being received.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

See also
CHOOSEFONT

ChooseFont

Common Dialog Box Library

Conceptual

EndDialog

PostMessage

Reference

WM_CTLCOLORDLG

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


LPFRHOOKPROC callback function
(commdlg.h)
Article04/02/2021

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.

The LPFRHOOKPROC type defines a pointer to this callback function. FRHookProc is a


placeholder for the application-defined function name.

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

The identifier of the message being received.

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 FINDREPLACE 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 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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

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.

The LPOFNHOOKPROC type defines a pointer to this callback function. OFNHookProc is


a placeholder for the application-defined function name.

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

The identifier of the message being received.

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.

For the CDN_SHAREVIOLATION and CDN_FILEOK notification messages, the hook


procedure should return a nonzero value to indicate that it has used the
SetWindowLong function to set a nonzero DWL_MSGRESULT value.

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.

When you use the GetOpenFileName or GetSaveFileName functions to create an


Explorer-style Open or Save As dialog box, you can provide an OFNHookProc hook
procedure. To enable the hook procedure, use the OPENFILENAME structure that you
passed to the dialog creation function. Specify the pointer to the hook procedure in the
lpfnHook member and specify the OFN_ENABLEHOOK flag in the Flags member.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

GetOpenFileName

GetSaveFileName
OFNHookProcOldStyle

OPENFILENAME

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


LPPAGEPAINTHOOK callback function
(commdlg.h)
Article04/02/2021

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.

The LPPAGEPAINTHOOK type defines a pointer to this callback function. PagePaintHook


is a placeholder for the application-defined or library-defined function name.

Syntax
C++

LPPAGEPAINTHOOK Lppagepainthook;

UINT_PTR Lppagepainthook(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}

Parameters
unnamedParam1

A handle to the Page Setup dialog box.

unnamedParam2

The identifier of the message being received.

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_MARGINRECT The dialog box is about to draw the margin rectangle.

WM_PSD_GREEKTEXTRECT The dialog box is about to draw the Greek text inside the margin
rectangle.

WM_PSD_ENVSTAMPRECT The dialog box is about to draw in the envelope-stamp rectangle


of an envelope sample page. This message is sent for envelopes
only.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

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.

The LPPAGESETUPHOOK type defines a pointer to this callback function.


PageSetupHook is a placeholder for the application-defined or library-defined function
name.

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

The identifier of the message being received.

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 PAGESETUPDLG 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 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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

EndDialog

PAGESETUPDLG

PageSetupDlg

PostMessage

Reference

WM_CTLCOLORDLG

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


LPPRINTHOOKPROC callback function
(commdlg.h)
Article04/02/2021

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.

The LPPRINTHOOKPROC type defines a pointer to this callback function. PrintHookProc


is a placeholder for the application-defined or library-defined function name.

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

The identifier of the message being received.

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 PRINTDLG 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 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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

EndDialog

PRINTDLG

PostMessage

PrintDlg

Reference

WM_CTLCOLORDLG

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


LPSETUPHOOKPROC callback function
(commdlg.h)
Article04/02/2021

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.

The LPSETUPHOOKPROC type defines a pointer to this callback function.


SetupHookProc is a placeholder for the application-defined or library-defined function
name.

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

The identifier of the message being received.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

EndDialog

PRINTDLG

PostMessage

PrintDlg

Reference

WM_CTLCOLORDLG

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OFNOTIFYA structure (commdlg.h)
Article07/27/2022

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.

Syntax
C++

typedef struct _OFNOTIFYA {


NMHDR hdr;
LPOPENFILENAMEA lpOFN;
LPSTR pszFile;
} OFNOTIFYA, *LPOFNOTIFYA;

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

The commdlg.h header defines OFNOTIFY 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
CDN_FILEOK

CDN_FOLDERCHANGE

CDN_HELP

CDN_INITDONE

CDN_SELCHANGE

CDN_SHAREVIOLATION

CDN_TYPECHANGE

Common Dialog Box Library

Conceptual

OFNOTIFYEX
OPENFILENAME

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OFNOTIFYEXA structure (commdlg.h)
Article07/27/2022

Contains information about a CDN_INCLUDEITEM notification message.

Syntax
C++

typedef struct _OFNOTIFYEXA {


NMHDR hdr;
LPOPENFILENAMEA lpOFN;
LPVOID psf;
LPVOID pidl;
} OFNOTIFYEXA, *LPOFNOTIFYEXA;

Members
hdr

Type: NMHDR

The code member of this structure identifies the notification message being sent.

lpOFN

Type: LPOPENFILENAME

A pointer to an OPENFILENAME structure containing the values specified when the


Open or Save As dialog box was created.

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

The commdlg.h header defines OFNOTIFYEX 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
CDN_INCLUDEITEM

Common Dialog Box Library

Conceptual

OFNHookProc

OFNOTIFY

OPENFILENAME

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OFNOTIFYEXW structure (commdlg.h)
Article07/27/2022

Contains information about a CDN_INCLUDEITEM notification message.

Syntax
C++

typedef struct _OFNOTIFYEXW {


NMHDR hdr;
LPOPENFILENAMEW lpOFN;
LPVOID psf;
LPVOID pidl;
} OFNOTIFYEXW, *LPOFNOTIFYEXW;

Members
hdr

Type: NMHDR

The code member of this structure identifies the notification message being sent.

lpOFN

Type: LPOPENFILENAME

A pointer to an OPENFILENAME structure containing the values specified when the


Open or Save As dialog box was created.

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

The commdlg.h header defines OFNOTIFYEX 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
CDN_INCLUDEITEM

Common Dialog Box Library

Conceptual

OFNHookProc

OFNOTIFY

OPENFILENAME

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OFNOTIFYW structure (commdlg.h)
Article07/27/2022

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.

Syntax
C++

typedef struct _OFNOTIFYW {


NMHDR hdr;
LPOPENFILENAMEW lpOFN;
LPWSTR pszFile;
} OFNOTIFYW, *LPOFNOTIFYW;

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

The commdlg.h header defines OFNOTIFY 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
CDN_FILEOK

CDN_FOLDERCHANGE

CDN_HELP

CDN_INITDONE

CDN_SELCHANGE

CDN_SHAREVIOLATION

CDN_TYPECHANGE

Common Dialog Box Library

Conceptual

OFNOTIFYEX
OPENFILENAME

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OPENFILENAME_NT4A structure
(commdlg.h)
Article07/27/2022

The OPENFILENAME_NT4 structure is identical to OPENFILENAME with _WIN32_WINNT


set to 0x0400. It allows an application to take advantage of other post-Microsoft
Windows NT 4.0 features while running on Microsoft Windows NT 4.0. Also, MFC42
applications must use OPENFILENAME_NT4 to avoid heap corruption. This is because
Microsoft Foundation Classes (MFC) has classes with embedded OPENFILENAME
structures, and you must use the same structure size.

Note This structure is provided only for compatibility.

Syntax
C++

typedef struct tagOFN_NT4A {


DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCSTR lpstrFilter;
LPSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPSTR lpstrFile;
DWORD nMaxFile;
LPSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCSTR lpstrInitialDir;
LPCSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCSTR lpTemplateName;
} OPENFILENAME_NT4A, *LPOPENFILENAME_NT4A;

Members
lStructSize

hwndOwner

hInstance

lpstrFilter

lpstrCustomFilter

nMaxCustFilter

nFilterIndex

lpstrFile

nMaxFile

lpstrFileTitle

nMaxFileTitle

lpstrInitialDir

lpstrTitle

Flags

nFileOffset

nFileExtension

lpstrDefExt

lCustData

lpfnHook

lpTemplateName

Requirements

Header commdlg.h (include Windows.h)


Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OPENFILENAME_NT4W structure
(commdlg.h)
Article07/27/2022

The OPENFILENAME_NT4 structure is identical to OPENFILENAME with _WIN32_WINNT


set to 0x0400. It allows an application to take advantage of other post-Microsoft
Windows NT 4.0 features while running on Microsoft Windows NT 4.0. Also, MFC42
applications must use OPENFILENAME_NT4 to avoid heap corruption. This is because
Microsoft Foundation Classes (MFC) has classes with embedded OPENFILENAME
structures, and you must use the same structure size.

Note This structure is provided only for compatibility.

Syntax
C++

typedef struct tagOFN_NT4W {


DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCWSTR lpstrFilter;
LPWSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPWSTR lpstrFile;
DWORD nMaxFile;
LPWSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCWSTR lpstrInitialDir;
LPCWSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCWSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCWSTR lpTemplateName;
} OPENFILENAME_NT4W, *LPOPENFILENAME_NT4W;

Members
lStructSize

hwndOwner

hInstance

lpstrFilter

lpstrCustomFilter

nMaxCustFilter

nFilterIndex

lpstrFile

nMaxFile

lpstrFileTitle

nMaxFileTitle

lpstrInitialDir

lpstrTitle

Flags

nFileOffset

nFileExtension

lpstrDefExt

lCustData

lpfnHook

lpTemplateName

Requirements

Header commdlg.h (include Windows.h)


Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OPENFILENAMEA structure (commdlg.h)
Article07/27/2022

[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.]

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.

Syntax
C++

typedef struct tagOFNA {


DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCSTR lpstrFilter;
LPSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPSTR lpstrFile;
DWORD nMaxFile;
LPSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCSTR lpstrInitialDir;
LPCSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCSTR lpTemplateName;
LPEDITMENU lpEditInfo;
LPCSTR lpstrPrompt;
void *pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
} OPENFILENAMEA, *LPOPENFILENAMEA;

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

If the OFN_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a


handle to a memory object containing a dialog box template. If the
OFN_ENABLETEMPLATE flag is set, hInstance is a handle to a module that contains a
dialog box template named by the lpTemplateName member. If neither flag is set, this
member is ignored. 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.

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:

1. If lpstrFile contains a path, that path is the initial directory.


2. Otherwise, lpstrInitialDir specifies the initial directory.
3. Otherwise, if the application has used an Open or Save As dialog box in the past,
the path most recently used is selected as the initial directory. However, if an
application is not run for a long time, its saved selected path is discarded.
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.

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.

If you specify a custom template for an old-style dialog


box, the definition of the File Name list box must contain
the LBS_EXTENDEDSEL value.

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_DONTADDTORECENT Prevents the system from adding a link to the selected


0x02000000 file in the file system directory that contains the user's
most recently used documents. To retrieve the location of
this directory, call the SHGetSpecialFolderLocation
function with the CSIDL_RECENT flag.

OFN_ENABLEHOOK Enables the hook function specified in the lpfnHook


0x00000020 member.

OFN_ENABLEINCLUDENOTIFY Causes the dialog box to send CDN_INCLUDEITEM


0x00400000 notification messages to your OFNHookProc hook
procedure when the user opens a folder. The dialog box
sends a notification for each item in the newly opened
folder. These messages enable you to control which items
the dialog box displays in the folder's item list.

OFN_ENABLESIZING Enables the Explorer-style dialog box to be resized using


0x00800000 either the mouse or the keyboard. By default, the
Explorer-style Open and Save As dialog boxes allow the
dialog box to be resized regardless of whether this flag is
set. This flag is necessary only if you provide a hook
procedure or custom template. The old-style dialog box
does not permit resizing.

OFN_ENABLETEMPLATE The lpTemplateName member is a pointer to the name


0x00000040 of a dialog template resource in the module identified by
the hInstance 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.

OFN_ENABLETEMPLATEHANDLE The hInstance member identifies a data block that


0x00000080 contains a preloaded dialog box template. The system
ignores lpTemplateName if this flag is specified. 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.

OFN_EXPLORER Indicates that any customizations made to the Open or


0x00080000 Save As dialog box use the Explorer-style customization
methods. For more information, see Explorer-Style Hook
Procedures and Explorer-Style Custom Templates.

By default, the Open and Save As dialog boxes use the


Explorer-style user interface regardless of whether this
flag is set. This flag is necessary only if you provide a
hook procedure or custom template, or set the
OFN_ALLOWMULTISELECT flag.

If you want the old-style user interface, omit the


OFN_EXPLORER flag and provide a replacement old-style
template or hook procedure. If you want the old style but
do not need a custom template or hook procedure,
simply provide a hook procedure that always returns
FALSE.

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_FORCESHOWHIDDEN Forces the showing of system and hidden files, thus


0x10000000 overriding the user setting to show or not show hidden
files. However, a file that is marked both system and
hidden is not shown.

OFN_HIDEREADONLY Hides the Read Only check box.


0x00000004

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_NOCHANGEDIR Restores the current directory to its original value if the


0x00000008 user changed the directory while searching for files.
This flag is ineffective for GetOpenFileName.

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_NONETWORKBUTTON Hides and disables the Network button.


0x00020000

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_NOVALIDATE The common dialog boxes allow invalid characters in the


0x00000100 returned file name. Typically, the calling application uses
a hook procedure that checks the file name by using the
FILEOKSTRING message. If the text box in the edit control
is empty or contains nothing but spaces, the lists of files
and directories are updated. If the text box in the edit
control contains anything else, nFileOffset and
nFileExtension are set to values generated by parsing the
text. No default extension is added to the text, nor is text
copied to the buffer specified by lpstrFileTitle. If the
value specified by nFileOffset is less than zero, the file
name is invalid. Otherwise, the file name is valid, and
nFileExtension and nFileOffset can be used as if the
OFN_NOVALIDATE flag had not been specified.

OFN_OVERWRITEPROMPT Causes the Save As dialog box to generate a message


0x00000002 box if the selected file already exists. The user must
confirm whether to overwrite the file.

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_READONLY Causes the Read Only check box to be selected initially


0x00000001 when the dialog box is created. This flag indicates the
state of the Read Only check box when the dialog box is
closed.

OFN_SHAREAWARE Specifies that if a call to the OpenFile function fails


0x00004000 because of a network sharing violation, the error is
ignored and the dialog box returns the selected file
name. If this flag is not set, the dialog box notifies your
hook procedure when a network sharing violation occurs
for the file name specified by the user. If you set the
OFN_EXPLORER flag, the dialog box sends the
CDN_SHAREVIOLATION message to the hook procedure.
If you do not set OFN_EXPLORER, the dialog box sends
the SHAREVISTRING registered message to the hook
procedure.

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

The default extension. GetOpenFileName and GetSaveFileName append this extension


to the file name if the user fails to type an extension. This string can be any length, but
only the first three characters are appended. The string should not contain a period (.). If
this member is NULL and the user fails to type an extension, no extension is appended.

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.

If OFN_EXPLORER is set, lpfnHook is a pointer to an OFNHookProc hook procedure. The


hook procedure receives notification messages sent from the dialog box. The hook
procedure also receives messages for any additional controls that you defined by
specifying a child dialog template. The hook procedure does not receive messages
intended for the standard controls of the default dialog box.

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*

This member is reserved.

dwReserved

Type: DWORD

This member is reserved.

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

The commdlg.h header defines OPENFILENAME 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]


Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

GetOpenFileName

GetSaveFileName

Other Resources

Reference

SHGetSpecialFolderLocation

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


OPENFILENAMEW structure
(commdlg.h)
Article07/27/2022

[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.]

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.

Syntax
C++

typedef struct tagOFNW {


DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCWSTR lpstrFilter;
LPWSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPWSTR lpstrFile;
DWORD nMaxFile;
LPWSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCWSTR lpstrInitialDir;
LPCWSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCWSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCWSTR lpTemplateName;
LPEDITMENU lpEditInfo;
LPCSTR lpstrPrompt;
void *pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
} OPENFILENAMEW, *LPOPENFILENAMEW;
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

If the OFN_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a


handle to a memory object containing a dialog box template. If the
OFN_ENABLETEMPLATE flag is set, hInstance is a handle to a module that contains a
dialog box template named by the lpTemplateName member. If neither flag is set, this
member is ignored. 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.

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:

1. If lpstrFile contains a path, that path is the initial directory.


2. Otherwise, lpstrInitialDir specifies the initial directory.
3. Otherwise, if the application has used an Open or Save As dialog box in the past,
the path most recently used is selected as the initial directory. However, if an
application is not run for a long time, its saved selected path is discarded.
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.

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.

If you specify a custom template for an old-style dialog


box, the definition of the File Name list box must contain
the LBS_EXTENDEDSEL value.

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_DONTADDTORECENT Prevents the system from adding a link to the selected


0x02000000 file in the file system directory that contains the user's
most recently used documents. To retrieve the location of
this directory, call the SHGetSpecialFolderLocation
function with the CSIDL_RECENT flag.

OFN_ENABLEHOOK Enables the hook function specified in the lpfnHook


0x00000020 member.

OFN_ENABLEINCLUDENOTIFY Causes the dialog box to send CDN_INCLUDEITEM


0x00400000 notification messages to your OFNHookProc hook
procedure when the user opens a folder. The dialog box
sends a notification for each item in the newly opened
folder. These messages enable you to control which items
the dialog box displays in the folder's item list.

OFN_ENABLESIZING Enables the Explorer-style dialog box to be resized using


0x00800000 either the mouse or the keyboard. By default, the
Explorer-style Open and Save As dialog boxes allow the
dialog box to be resized regardless of whether this flag is
set. This flag is necessary only if you provide a hook
procedure or custom template. The old-style dialog box
does not permit resizing.

OFN_ENABLETEMPLATE The lpTemplateName member is a pointer to the name


0x00000040 of a dialog template resource in the module identified by
the hInstance 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.

OFN_ENABLETEMPLATEHANDLE The hInstance member identifies a data block that


0x00000080 contains a preloaded dialog box template. The system
ignores lpTemplateName if this flag is specified. 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.

OFN_EXPLORER Indicates that any customizations made to the Open or


0x00080000 Save As dialog box use the Explorer-style customization
methods. For more information, see Explorer-Style Hook
Procedures and Explorer-Style Custom Templates.

By default, the Open and Save As dialog boxes use the


Explorer-style user interface regardless of whether this
flag is set. This flag is necessary only if you provide a
hook procedure or custom template, or set the
OFN_ALLOWMULTISELECT flag.

If you want the old-style user interface, omit the


OFN_EXPLORER flag and provide a replacement old-style
template or hook procedure. If you want the old style but
do not need a custom template or hook procedure,
simply provide a hook procedure that always returns
FALSE.

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_FORCESHOWHIDDEN Forces the showing of system and hidden files, thus


0x10000000 overriding the user setting to show or not show hidden
files. However, a file that is marked both system and
hidden is not shown.

OFN_HIDEREADONLY Hides the Read Only check box.


0x00000004

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_NOCHANGEDIR Restores the current directory to its original value if the


0x00000008 user changed the directory while searching for files.
This flag is ineffective for GetOpenFileName.

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_NONETWORKBUTTON Hides and disables the Network button.


0x00020000

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_NOVALIDATE The common dialog boxes allow invalid characters in the


0x00000100 returned file name. Typically, the calling application uses
a hook procedure that checks the file name by using the
FILEOKSTRING message. If the text box in the edit control
is empty or contains nothing but spaces, the lists of files
and directories are updated. If the text box in the edit
control contains anything else, nFileOffset and
nFileExtension are set to values generated by parsing the
text. No default extension is added to the text, nor is text
copied to the buffer specified by lpstrFileTitle. If the
value specified by nFileOffset is less than zero, the file
name is invalid. Otherwise, the file name is valid, and
nFileExtension and nFileOffset can be used as if the
OFN_NOVALIDATE flag had not been specified.

OFN_OVERWRITEPROMPT Causes the Save As dialog box to generate a message


0x00000002 box if the selected file already exists. The user must
confirm whether to overwrite the file.

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_READONLY Causes the Read Only check box to be selected initially


0x00000001 when the dialog box is created. This flag indicates the
state of the Read Only check box when the dialog box is
closed.

OFN_SHAREAWARE Specifies that if a call to the OpenFile function fails


0x00004000 because of a network sharing violation, the error is
ignored and the dialog box returns the selected file
name. If this flag is not set, the dialog box notifies your
hook procedure when a network sharing violation occurs
for the file name specified by the user. If you set the
OFN_EXPLORER flag, the dialog box sends the
CDN_SHAREVIOLATION message to the hook procedure.
If you do not set OFN_EXPLORER, the dialog box sends
the SHAREVISTRING registered message to the hook
procedure.

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

The default extension. GetOpenFileName and GetSaveFileName append this extension


to the file name if the user fails to type an extension. This string can be any length, but
only the first three characters are appended. The string should not contain a period (.). If
this member is NULL and the user fails to type an extension, no extension is appended.

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.

If OFN_EXPLORER is set, lpfnHook is a pointer to an OFNHookProc hook procedure. The


hook procedure receives notification messages sent from the dialog box. The hook
procedure also receives messages for any additional controls that you defined by
specifying a child dialog template. The hook procedure does not receive messages
intended for the standard controls of the default dialog box.

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*

This member is reserved.

dwReserved

Type: DWORD

This member is reserved.

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

The commdlg.h header defines OPENFILENAME 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]


Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

GetOpenFileName

GetSaveFileName

Other Resources

Reference

SHGetSpecialFolderLocation

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


PageSetupDlgA callback function
(commdlg.h)
Article06/28/2022

ASCII version of PageSetupDlg

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

Get help at Microsoft Q&A


PAGESETUPDLGA structure (commdlg.h)
Article11/19/2022

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++

typedef struct tagPSDA {


DWORD lStructSize;
HWND hwndOwner;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
DWORD Flags;
POINT ptPaperSize;
RECT rtMinMargin;
RECT rtMargin;
HINSTANCE hInstance;
LPARAM lCustData;
LPPAGESETUPHOOK lpfnPageSetupHook;
LPPAGEPAINTHOOK lpfnPagePaintHook;
LPCSTR lpPageSetupTemplateName;
HGLOBAL hPageSetupTemplate;
} PAGESETUPDLGA, *LPPAGESETUPDLGA;

Members
lStructSize

Type: DWORD

The size, in bytes, of this structure.

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

A handle to a global memory object that contains a DEVMODE structure. On input, if a


handle is specified, the values in the corresponding DEVMODE structure are used to
initialize the controls in the dialog box. On output, the dialog box sets hDevMode to a
global memory handle to a DEVMODE structure that contains values specifying the
user's selections. If the user's selections are not available, the dialog box sets hDevMode
to NULL.

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_DISABLEMARGINS Disables the margin controls, preventing the user


0x00000010 from setting the margins.

PSD_DISABLEORIENTATION Disables the orientation controls, preventing the


0x00000100 user from setting the page orientation.

PSD_DISABLEPAGEPAINTING Prevents the dialog box from drawing the


0x00080000 contents of the sample page. If you enable a
PagePaintHook hook procedure, you can still draw
the contents of the sample page.
PSD_DISABLEPAPER Disables the paper controls, preventing the user
0x00000200 from setting page parameters such as the paper
size and source.

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_ENABLEPAGEPAINTHOOK Enables the hook procedure specified in the


0x00040000 lpfnPagePaintHook member.

PSD_ENABLEPAGESETUPHOOK Enables the hook procedure specified in the


0x00002000 lpfnPageSetupHook member.

PSD_ENABLEPAGESETUPTEMPLATE Indicates that the hInstance and


0x00008000 lpPageSetupTemplateName members specify a
dialog box template to use in place of the default
template.

PSD_ENABLEPAGESETUPTEMPLATEHANDLE Indicates that the hPageSetupTemplate member


0x00020000 identifies a data block that contains a preloaded
dialog box template. The system ignores the
lpPageSetupTemplateName member if this flag is
specified.

PSD_INHUNDREDTHSOFMILLIMETERS Indicates that hundredths of millimeters are the


0x00000008 unit of measurement for margins and paper size.
The values in the rtMargin, rtMinMargin, and
ptPaperSize members are in hundredths of
millimeters. You can set this flag on input to
override the default unit of measurement for the
user's locale. When the function returns, the
dialog box sets this flag to indicate the units used.

PSD_INTHOUSANDTHSOFINCHES Indicates that thousandths of inches are the unit


0x00000004 of measurement for margins and paper size. The
values in the rtMargin, rtMinMargin, and
ptPaperSize members are in thousandths of
inches. You can set this flag on input to override
the default unit of measurement for the user's
locale. When the function returns, the dialog box
sets this flag to indicate the units used.

PSD_INWININIINTLMEASURE Reserved.
0x00000000

PSD_MARGINS Causes the system to use the values specified in


0x00000002 the rtMargin member as the initial widths for the
left, top, right, and bottom margins. If
PSD_MARGINS is not set, the system sets the
initial widths to one inch for all margins.

PSD_MINMARGINS Causes the system to use the values specified in


0x00000001 the rtMinMargin member as the minimum
allowable widths for the left, top, right, and
bottom margins. The system prevents the user
from entering a width that is less than the
specified minimum. If PSD_MINMARGINS is not
specified, the system sets the minimum allowable
widths to those allowed by the printer.

PSD_NONETWORKBUTTON Hides and disables the Network button.


0x00200000

PSD_NOWARNING Prevents the system from displaying a warning


0x00000080 message when there is no default printer.

PSD_RETURNDEFAULT PageSetupDlg does not display the dialog box.


0x00000400 Instead, it sets the hDevNames and hDevMode
members to handles to DEVMODE and
DEVNAMES structures that are initialized for the
system default printer. PageSetupDlg returns an
error if either hDevNames or hDevMode is not
NULL.

PSD_SHOWHELP Causes the dialog box to display the Help button.


0x00000800 The hwndOwner member must specify the
window to receive the HELPMSGSTRING
registered messages that the dialog box sends
when the user clicks the Help button.

ptPaperSize

Type: POINT

The dimensions of the paper selected by the user. The


PSD_INTHOUSANDTHSOFINCHES or PSD_INHUNDREDTHSOFMILLIMETERS flag
indicates the units of measurement.

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

If the PSD_ENABLEPAGESETUPTEMPLATE flag is set in the Flags member, hInstance is a


handle to the application or module instance that contains the dialog box template
named by the lpPageSetupTemplateName member.

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

A pointer to a PagePaintHook hook procedure that receives WM_PSD_* messages from


the dialog box whenever the sample page is redrawn. By processing the messages, the
hook procedure can customize the appearance of the sample page. This member is
ignored unless the PSD_ENABLEPAGEPAINTHOOK flag is set in the Flags member.

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

If the PSD_ENABLEPAGESETUPTEMPLATEHANDLE flag is set in the Flags member,


hPageSetupTemplate is a handle to a memory object containing a dialog box template.

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

The commdlg.h header defines PAGESETUPDLG 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]

Minimum supported server Windows 2000 Server [desktop apps only]


Header commdlg.h (include Windows.h)

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

Get help at Microsoft Q&A


PageSetupDlgW callback function
(commdlg.h)
Article06/28/2022

Wide string version of PageSetupDlg

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

Get help at Microsoft Q&A


PAGESETUPDLGW structure
(commdlg.h)
Article11/19/2022

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++

typedef struct tagPSDW {


DWORD lStructSize;
HWND hwndOwner;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
DWORD Flags;
POINT ptPaperSize;
RECT rtMinMargin;
RECT rtMargin;
HINSTANCE hInstance;
LPARAM lCustData;
LPPAGESETUPHOOK lpfnPageSetupHook;
LPPAGEPAINTHOOK lpfnPagePaintHook;
LPCWSTR lpPageSetupTemplateName;
HGLOBAL hPageSetupTemplate;
} PAGESETUPDLGW, *LPPAGESETUPDLGW;

Members
lStructSize

Type: DWORD

The size, in bytes, of this structure.

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

A handle to a global memory object that contains a DEVMODE structure. On input, if a


handle is specified, the values in the corresponding DEVMODE structure are used to
initialize the controls in the dialog box. On output, the dialog box sets hDevMode to a
global memory handle to a DEVMODE structure that contains values specifying the
user's selections. If the user's selections are not available, the dialog box sets hDevMode
to NULL.

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_DISABLEMARGINS Disables the margin controls, preventing the user


0x00000010 from setting the margins.

PSD_DISABLEORIENTATION Disables the orientation controls, preventing the


0x00000100 user from setting the page orientation.

PSD_DISABLEPAGEPAINTING Prevents the dialog box from drawing the


0x00080000 contents of the sample page. If you enable a
PagePaintHook hook procedure, you can still draw
the contents of the sample page.

PSD_DISABLEPAPER Disables the paper controls, preventing the user


0x00000200 from setting page parameters such as the paper
size and source.

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_ENABLEPAGEPAINTHOOK Enables the hook procedure specified in the


0x00040000 lpfnPagePaintHook member.

PSD_ENABLEPAGESETUPHOOK Enables the hook procedure specified in the


0x00002000 lpfnPageSetupHook member.

PSD_ENABLEPAGESETUPTEMPLATE Indicates that the hInstance and


0x00008000 lpPageSetupTemplateName members specify a
dialog box template to use in place of the default
template.

PSD_ENABLEPAGESETUPTEMPLATEHANDLE Indicates that the hPageSetupTemplate member


0x00020000 identifies a data block that contains a preloaded
dialog box template. The system ignores the
lpPageSetupTemplateName member if this flag is
specified.

PSD_INHUNDREDTHSOFMILLIMETERS Indicates that hundredths of millimeters are the


0x00000008 unit of measurement for margins and paper size.
The values in the rtMargin, rtMinMargin, and
ptPaperSize members are in hundredths of
millimeters. You can set this flag on input to
override the default unit of measurement for the
user's locale. When the function returns, the
dialog box sets this flag to indicate the units used.

PSD_INTHOUSANDTHSOFINCHES Indicates that thousandths of inches are the unit


0x00000004 of measurement for margins and paper size. The
values in the rtMargin, rtMinMargin, and
ptPaperSize members are in thousandths of
inches. You can set this flag on input to override
the default unit of measurement for the user's
locale. When the function returns, the dialog box
sets this flag to indicate the units used.

PSD_INWININIINTLMEASURE Reserved.
0x00000000

PSD_MARGINS Causes the system to use the values specified in


0x00000002 the rtMargin member as the initial widths for the
left, top, right, and bottom margins. If
PSD_MARGINS is not set, the system sets the
initial widths to one inch for all margins.

PSD_MINMARGINS Causes the system to use the values specified in


0x00000001 the rtMinMargin member as the minimum
allowable widths for the left, top, right, and
bottom margins. The system prevents the user
from entering a width that is less than the
specified minimum. If PSD_MINMARGINS is not
specified, the system sets the minimum allowable
widths to those allowed by the printer.

PSD_NONETWORKBUTTON Hides and disables the Network button.


0x00200000

PSD_NOWARNING Prevents the system from displaying a warning


0x00000080 message when there is no default printer.

PSD_RETURNDEFAULT PageSetupDlg does not display the dialog box.


0x00000400 Instead, it sets the hDevNames and hDevMode
members to handles to DEVMODE and
DEVNAMES structures that are initialized for the
system default printer. PageSetupDlg returns an
error if either hDevNames or hDevMode is not
NULL.

PSD_SHOWHELP Causes the dialog box to display the Help button.


0x00000800 The hwndOwner member must specify the
window to receive the HELPMSGSTRING
registered messages that the dialog box sends
when the user clicks the Help button.

ptPaperSize

Type: POINT

The dimensions of the paper selected by the user. The


PSD_INTHOUSANDTHSOFINCHES or PSD_INHUNDREDTHSOFMILLIMETERS flag
indicates the units of measurement.

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

If the PSD_ENABLEPAGESETUPTEMPLATE flag is set in the Flags member, hInstance is a


handle to the application or module instance that contains the dialog box template
named by the lpPageSetupTemplateName member.

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

A pointer to a PagePaintHook hook procedure that receives WM_PSD_* messages from


the dialog box whenever the sample page is redrawn. By processing the messages, the
hook procedure can customize the appearance of the sample page. This member is
ignored unless the PSD_ENABLEPAGEPAINTHOOK flag is set in the Flags member.

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

If the PSD_ENABLEPAGESETUPTEMPLATEHANDLE flag is set in the Flags member,


hPageSetupTemplate is a handle to a memory object containing a dialog box template.

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

The commdlg.h header defines PAGESETUPDLG 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

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

Get help at Microsoft Q&A


PrintDlgA callback function
(commdlg.h)
Article06/28/2022

ASCII version of PrintDlg

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

Get help at Microsoft Q&A


PRINTDLGA structure (commdlg.h)
Article07/27/2022

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++

typedef struct tagPDA {


DWORD lStructSize;
HWND hwndOwner;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
HDC hDC;
DWORD Flags;
WORD nFromPage;
WORD nToPage;
WORD nMinPage;
WORD nMaxPage;
WORD nCopies;
HINSTANCE hInstance;
LPARAM lCustData;
LPPRINTHOOKPROC lpfnPrintHook;
LPSETUPHOOKPROC lpfnSetupHook;
LPCSTR lpPrintTemplateName;
LPCSTR lpSetupTemplateName;
HGLOBAL hPrintTemplate;
HGLOBAL hSetupTemplate;
} PRINTDLGA, *LPPRINTDLGA;

Members
lStructSize

Type: DWORD

The structure size, in bytes.

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

A handle to a movable global memory object that contains a DEVMODE structure. If


hDevMode is not NULL on input, you must allocate a movable block of memory for the
DEVMODE structure and initialize its members. The PrintDlg function uses the input
data to initialize the controls in the dialog box. When PrintDlg returns, the DEVMODE
members indicate the user's input.

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.

If the device name (specified by the dmDeviceName member of the DEVMODE


structure) does not appear in the [devices] section of WIN.INI, PrintDlg returns an error.

For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.

hDevNames

Type: HGLOBAL

A handle to a movable global memory object that contains a DEVNAMES structure. If


hDevNames is not NULL on input, you must allocate a movable block of memory for
the DEVNAMES structure and initialize its members. The PrintDlg function uses the
input data to initialize the controls in the dialog box. When PrintDlg returns, the
DEVNAMES members contain information for the printer chosen by the user. You can
use this information to create a device context or an information context.

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.

PD_COLLATE If this flag is set, the Collate check box is selected.


0x00000010
If this flag is set when the PrintDlg function returns, the
application must simulate collation of multiple copies.
For more information, see the description of the
PD_USEDEVMODECOPIESANDCOLLATE flag.

See PD_NOPAGENUMS.

PD_DISABLEPRINTTOFILE Disables the Print to File check box.


0x00080000

PD_ENABLEPRINTHOOK Enables the hook procedure specified in the


0x00001000 lpfnPrintHook member. This enables the hook
procedure for the Print dialog box.

PD_ENABLEPRINTTEMPLATE Indicates that the hInstance and


0x00004000 lpPrintTemplateName members specify a replacement
for the default Print dialog box template.

PD_ENABLEPRINTTEMPLATEHANDLE Indicates that the hPrintTemplate member identifies a


0x00010000 data block that contains a preloaded dialog box
template. This template replaces the default template
for the Print dialog box. The system ignores the
lpPrintTemplateName member if this flag is specified.

PD_ENABLESETUPHOOK Enables the hook procedure specified in the


0x00002000 lpfnSetupHook member. This enables the hook
procedure for the Print Setup dialog box.

PD_ENABLESETUPTEMPLATE Indicates that the hInstance and


0x00008000 lpSetupTemplateName members specify a
replacement for the default Print Setup dialog box
template.

PD_ENABLESETUPTEMPLATEHANDLE Indicates that the hSetupTemplate member identifies a


0x00020000 data block that contains a preloaded dialog box
template. This template replaces the default template
for the Print Setup dialog box. The system ignores the
lpSetupTemplateName member if this flag is specified.

PD_HIDEPRINTTOFILE Hides the Print to File check box.


0x00100000

PD_NONETWORKBUTTON Hides and disables the Network button.


0x00200000

PD_NOPAGENUMS Disables the Pages radio button and the associated


0x00000008 edit controls. Also, it causes the Collate check box to
appear in the dialog.

PD_NOSELECTION Disables the Selection radio button.


0x00000004

PD_NOWARNING Prevents the warning message from being displayed


0x00000080 when there is no default printer.

PD_PAGENUMS If this flag is set, the Pages radio button is selected. If


0x00000002 this flag is set when the PrintDlg function returns, the
nFromPage and nToPage members indicate the
starting and ending pages specified by the user.

PD_PRINTSETUP Causes the system to display the Print Setup dialog


0x00000040 box rather than the Print dialog box.

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_RETURNDC Causes PrintDlg to return a device context matching


0x00000100 the selections the user made in the dialog box. The
device context is returned in hDC.

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_RETURNIC Similar to the PD_RETURNDC flag, except this flag


0x00000200 returns an information context rather than a device
context. If neither PD_RETURNDC nor PD_RETURNIC is
specified, hDC is undefined on output.

PD_SELECTION If this flag is set, the Selection radio button is selected.


0x00000001 If neither PD_PAGENUMS nor PD_SELECTION is set,
the All radio button is selected.

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.

PD_USEDEVMODECOPIES Same as PD_USEDEVMODECOPIESANDCOLLATE.


0x00040000

PD_USEDEVMODECOPIESANDCOLLATE This flag indicates whether your application supports


0x00040000 multiple copies and collation. Set this flag on input to
indicate that your application does not support
multiple copies and collation. In this case, the nCopies
member of the PRINTDLG structure always returns 1,
and PD_COLLATE is never set in the Flags member.

If this flag is not set, the application is responsible for


printing and collating multiple copies. In this case, the
nCopies member of the PRINTDLG structure indicates
the number of copies the user wants to print, and the
PD_COLLATE flag in the Flags member indicates
whether the user wants collation.

Regardless of whether this flag is set, an application


can determine from nCopies and PD_COLLATE how
many copies to render and whether to print them
collated.

If this flag is set and the printer driver does not


support multiple copies, the Copies edit control is
disabled. Similarly, if this flag is set and the printer
driver does not support collation, the Collate check
box is disabled.

The dmCopies and dmCollate members of the


DEVMODE structure contain the copies and collate
information used by the printer driver. If this flag is set
and the printer driver supports multiple copies, the
dmCopies member indicates the number of copies
requested by the user. If this flag is set and the printer
driver supports collation, the dmCollate member of
the DEVMODE structure indicates whether the user
wants collation. If this flag is not set, the dmCopies
member always returns 1, and the dmCollate member
is always zero.

Known issue on Windows 2000/XP/2003: If this flag


is not set before calling PrintDlg, PrintDlg might swap
nCopies and dmCopies values when it returns. The
workaround for this issue is use dmCopies if its value is
larger than 1, else, use nCopies, for you to to get the
actual number of copies to be printed when PrintDlg
returns.

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

The initial value for the starting page edit control.

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

If the PD_ENABLEPRINTTEMPLATE or PD_ENABLESETUPTEMPLATE flag is set in the


Flags member, hInstance is a handle to the application or module instance that contains
the dialog box template named by the lpPrintTemplateName or lpSetupTemplateName
member.

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

If the PD_ENABLEPRINTTEMPLATEHANDLE flag is set in the Flags member,


hPrintTemplate is a handle to a memory object containing a dialog box template. This
template replaces the default Print dialog box template.

hSetupTemplate

Type: HGLOBAL

If the PD_ENABLESETUPTEMPLATEHANDLE flag is set in the Flags member,


hSetupTemplate is a handle to a memory object containing a dialog box template. This
template replaces the default Print Setup dialog box template.

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

The commdlg.h header defines PRINTDLG 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

DEVMODE

DEVNAMES

PrintDlg

Reference

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


PrintDlgExA callback function
(commdlg.h)
Article06/28/2022

ASCII version of PrintDlgEx

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

Get help at Microsoft Q&A


PRINTDLGEXA structure (commdlg.h)
Article07/27/2022

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++

typedef struct tagPDEXA {


DWORD lStructSize;
HWND hwndOwner;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
HDC hDC;
DWORD Flags;
DWORD Flags2;
DWORD ExclusionFlags;
DWORD nPageRanges;
DWORD nMaxPageRanges;
LPPRINTPAGERANGE lpPageRanges;
DWORD nMinPage;
DWORD nMaxPage;
DWORD nCopies;
HINSTANCE hInstance;
LPCSTR lpPrintTemplateName;
LPUNKNOWN lpCallback;
DWORD nPropertyPages;
HPROPSHEETPAGE *lphPropertyPages;
DWORD nStartPage;
DWORD dwResultAction;
} PRINTDLGEXA, *LPPRINTDLGEXA;

Members
lStructSize

Type: DWORD

The structure size, in bytes.

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

A handle to a movable global memory object that contains a DEVMODE structure. If


hDevMode is not NULL on input, you must allocate a movable block of memory for the
DEVMODE structure and initialize its members. The PrintDlgEx function uses the input
data to initialize the controls in the property sheet. When PrintDlgEx returns, the
DEVMODE members indicate the user's input.

If hDevMode is NULL on input, PrintDlgEx allocates memory for the DEVMODE


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.

hDevNames

Type: HGLOBAL

A handle to a movable global memory object that contains a DEVNAMES structure. If


hDevNames is not NULL on input, you must allocate a movable block of memory for
the DEVNAMES structure and initialize its members. The PrintDlgEx function uses the
input data to initialize the controls in the property sheet. When PrintDlgEx returns, the
DEVNAMES members contain information for the printer chosen by the user. You can
use this information to create a device context or an information context.

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

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,
then the value of this member is undefined. If both flags are specified, then
PD_RETURNDC has priority. If hDC isn't NULL, then you must call DeleteDC to free the
GDI object after you no longer need it; otherwise you'll leak GDI objects whenever you
call PrintDlgw APIs.

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.

PD_COLLATE If this flag is set, the Collate check box is selected.


0x00000010
If this flag is set when the PrintDlgEx function returns,
the application must simulate collation of multiple
copies. For more information, see the description of
the PD_USEDEVMODECOPIESANDCOLLATE flag.

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_DISABLEPRINTTOFILE Disables the Print to File check box.


0x00080000

PD_ENABLEPRINTTEMPLATE Indicates that the hInstance and lpPrintTemplateName


0x00004000 members specify a replacement for 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. The system uses the specified
template to create a window that is a child of the
General page.

PD_ENABLEPRINTTEMPLATEHANDLE Indicates that the hInstance member identifies a data


0x00010000 block that contains a preloaded dialog box template.
This template replaces the default dialog box template
in the lower portion of the General page. The system
uses the specified template to create a window that is
a child of the General page. The system ignores the
lpPrintTemplateName member if this flag is specified.

PD_EXCLUSIONFLAGS Indicates that the ExclusionFlags member identifies


0x01000000 items to be excluded from the printer driver property
pages. If this flag is not set, items will be excluded by
default from the printer driver property pages. The
exclusions prevent the duplication of items among the
General page, any application-specified pages, and the
printer driver pages.

PD_HIDEPRINTTOFILE Hides the Print to File check box.


0x00100000

PD_NOCURRENTPAGE Disables the Current Page radio button.


0x00800000

PD_NOPAGENUMS Disables the Pages radio button and the associated


0x00000008 edit controls. Also, it causes the Collate check box to
appear in the dialog.

PD_NOSELECTION Disables the Selection radio button.


0x00000004

PD_NOWARNING Prevents the warning message from being displayed


0x00000080 when an error occurs.

PD_PAGENUMS If this flag is set, the Pages radio button is selected. If


0x00000002 none of the PD_PAGENUMS, PD_SELECTION, or
PD_CURRENTPAGE flags is set, the All radio button is
selected. If this flag is set when the PrintDlgEx function
returns, the lpPageRanges member indicates the page
ranges specified by the user.

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.

PD_RETURNDC Causes PrintDlgEx to return a device context matching


0x00000100 the selections the user made in the property sheet. The
device context is returned in hDC.

PD_RETURNDEFAULT If this flag is set, the PrintDlgEx function does not


0x00000400 display the property sheet. Instead, it sets the
hDevNames and hDevMode members to handles to
DEVNAMES and DEVMODE structures that are
initialized for the system default printer. Both
hDevNames and hDevMode must be NULL, or
PrintDlgEx returns an error.

PD_RETURNIC Similar to the PD_RETURNDC flag, except this flag


0x00000200 returns an information context rather than a device
context. If neither PD_RETURNDC nor PD_RETURNIC is
specified, hDC is undefined on output.

PD_SELECTION If this flag is set, the Selection radio button is selected.


0x00000001 If none of the PD_PAGENUMS, PD_SELECTION, or
PD_CURRENTPAGE flags is set, the All radio button is
selected.

PD_USEDEVMODECOPIES Same as PD_USEDEVMODECOPIESANDCOLLATE.


0x00040000

PD_USEDEVMODECOPIESANDCOLLATE This flag indicates whether your application supports


0x00040000 multiple copies and collation. Set this flag on input to
indicate that your application does not support
multiple copies and collation. In this case, the nCopies
member of the PRINTDLGEX structure always returns
1, and PD_COLLATE is never set in the Flags member.

If this flag is not set, the application is responsible for


printing and collating multiple copies. In this case, the
nCopies member of the PRINTDLGEX structure
indicates the number of copies the user wants to print,
and the PD_COLLATE flag in the Flags member
indicates whether the user wants collation.

Regardless of whether this flag is set, an application


can determine from nCopies and PD_COLLATE how
many copies to render and whether to print them
collated.

If this flag is set and the printer driver does not


support multiple copies, the Copies edit control is
disabled. Similarly, if this flag is set and the printer
driver does not support collation, the Collate check
box is disabled.

The dmCopies and dmCollate members of the


DEVMODE structure contain the copies and collate
information used by the printer driver. If this flag is set
and the printer driver supports multiple copies, the
dmCopies member indicates the number of copies
requested by the user. If this flag is set and the printer
driver supports collation, the dmCollate member of
the DEVMODE structure indicates whether the user
wants collation. If this flag is not set, the dmCopies
member always returns 1, and the dmCollate member
is always zero.

In Windows versions prior to Windows Vista, if this flag


is not set by the calling application and the dmCopies
member of the DEVMODE structure is greater than 1,
use that value for the number of copies; otherwise, use
the value of the nCopies member of the PRINTDLGEX
structure.

PD_USELARGETEMPLATE Forces the property sheet to use a large template for


0x10000000 the General page. The larger template provides more
space for applications that specify a custom template
for the lower portion of the General page.

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

Pointer to a buffer containing an array of PRINTPAGERANGE structures. On input, the


array contains the initial page ranges to display in the Pages edit control. When the
PrintDlgEx function returns, the array contains the page ranges specified by the user. If
the PD_NOPAGENUMS flag is specified, this value is not valid. If the PD_NOPAGENUMS
flag is not specified, lpPageRanges must be non-NULL.

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

If the PD_ENABLEPRINTTEMPLATE flag is set in the Flags member, hInstance is a


handle to the application or module instance that contains the dialog box template
named by the lpPrintTemplateName member. If the
PD_ENABLEPRINTTEMPLATEHANDLE flag is set in the Flags member, hInstance is a
handle to a memory object containing a dialog box template. If neither of the template
flags is set in the Flags member, hInstance should be NULL.

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

The number of property page handles in the lphPropertyPages array.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

DEVMODE

DEVNAMES

IPrintDialogCallback

IPrintDialogServices

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


PrintDlgExW callback function
(commdlg.h)
Article06/28/2022

Wide string version of PrintDlgEx

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

Get help at Microsoft Q&A


PRINTDLGEXW structure (commdlg.h)
Article07/27/2022

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++

typedef struct tagPDEXW {


DWORD lStructSize;
HWND hwndOwner;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
HDC hDC;
DWORD Flags;
DWORD Flags2;
DWORD ExclusionFlags;
DWORD nPageRanges;
DWORD nMaxPageRanges;
LPPRINTPAGERANGE lpPageRanges;
DWORD nMinPage;
DWORD nMaxPage;
DWORD nCopies;
HINSTANCE hInstance;
LPCWSTR lpPrintTemplateName;
LPUNKNOWN lpCallback;
DWORD nPropertyPages;
HPROPSHEETPAGE *lphPropertyPages;
DWORD nStartPage;
DWORD dwResultAction;
} PRINTDLGEXW, *LPPRINTDLGEXW;

Members
lStructSize

Type: DWORD

The structure size, in bytes.

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

A handle to a movable global memory object that contains a DEVMODE structure. If


hDevMode is not NULL on input, you must allocate a movable block of memory for the
DEVMODE structure and initialize its members. The PrintDlgEx function uses the input
data to initialize the controls in the property sheet. When PrintDlgEx returns, the
DEVMODE members indicate the user's input.

If hDevMode is NULL on input, PrintDlgEx allocates memory for the DEVMODE


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.

hDevNames

Type: HGLOBAL

A handle to a movable global memory object that contains a DEVNAMES structure. If


hDevNames is not NULL on input, you must allocate a movable block of memory for
the DEVNAMES structure and initialize its members. The PrintDlgEx function uses the
input data to initialize the controls in the property sheet. When PrintDlgEx returns, the
DEVNAMES members contain information for the printer chosen by the user. You can
use this information to create a device context or an information context.

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

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

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.

PD_COLLATE If this flag is set, the Collate check box is selected.


0x00000010
If this flag is set when the PrintDlgEx function returns,
the application must simulate collation of multiple
copies. For more information, see the description of
the PD_USEDEVMODECOPIESANDCOLLATE flag.

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_DISABLEPRINTTOFILE Disables the Print to File check box.


0x00080000

PD_ENABLEPRINTTEMPLATE Indicates that the hInstance and


0x00004000 lpPrintTemplateName members specify a replacement
for 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. The system uses the specified template to create a
window that is a child of the General page.

PD_ENABLEPRINTTEMPLATEHANDLE Indicates that the hInstance member identifies a data


0x00010000 block that contains a preloaded dialog box template.
This template replaces the default dialog box template
in the lower portion of the General page. The system
uses the specified template to create a window that is
a child of the General page. The system ignores the
lpPrintTemplateName member if this flag is specified.

PD_EXCLUSIONFLAGS Indicates that the ExclusionFlags member identifies


0x01000000 items to be excluded from the printer driver property
pages. If this flag is not set, items will be excluded by
default from the printer driver property pages. The
exclusions prevent the duplication of items among the
General page, any application-specified pages, and the
printer driver pages.

PD_HIDEPRINTTOFILE Hides the Print to File check box.


0x00100000

PD_NOCURRENTPAGE Disables the Current Page radio button.


0x00800000

PD_NOPAGENUMS Disables the Pages radio button and the associated


0x00000008 edit controls. Also, it causes the Collate check box to
appear in the dialog.

PD_NOSELECTION Disables the Selection radio button.


0x00000004

PD_NOWARNING Prevents the warning message from being displayed


0x00000080 when an error occurs.

PD_PAGENUMS If this flag is set, the Pages radio button is selected. If


0x00000002 none of the PD_PAGENUMS, PD_SELECTION, or
PD_CURRENTPAGE flags is set, the All radio button is
selected. If this flag is set when the PrintDlgEx function
returns, the lpPageRanges member indicates the page
ranges specified by the user.

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.

PD_RETURNDC Causes PrintDlgEx to return a device context matching


0x00000100 the selections the user made in the property sheet. The
device context is returned in hDC.

PD_RETURNDEFAULT If this flag is set, the PrintDlgEx function does not


0x00000400 display the property sheet. Instead, it sets the
hDevNames and hDevMode members to handles to
DEVNAMES and DEVMODE structures that are
initialized for the system default printer. Both
hDevNames and hDevMode must be NULL, or
PrintDlgEx returns an error.

PD_RETURNIC Similar to the PD_RETURNDC flag, except this flag


0x00000200 returns an information context rather than a device
context. If neither PD_RETURNDC nor PD_RETURNIC is
specified, hDC is undefined on output.

PD_SELECTION If this flag is set, the Selection radio button is selected.


0x00000001 If none of the PD_PAGENUMS, PD_SELECTION, or
PD_CURRENTPAGE flags is set, the All radio button is
selected.

PD_USEDEVMODECOPIES Same as PD_USEDEVMODECOPIESANDCOLLATE.


0x00040000

PD_USEDEVMODECOPIESANDCOLLATE This flag indicates whether your application supports


0x00040000 multiple copies and collation. Set this flag on input to
indicate that your application does not support
multiple copies and collation. In this case, the nCopies
member of the PRINTDLGEX structure always returns
1, and PD_COLLATE is never set in the Flags member.

If this flag is not set, the application is responsible for


printing and collating multiple copies. In this case, the
nCopies member of the PRINTDLGEX structure
indicates the number of copies the user wants to print,
and the PD_COLLATE flag in the Flags member
indicates whether the user wants collation.
Regardless of whether this flag is set, an application
can determine from nCopies and PD_COLLATE how
many copies to render and whether to print them
collated.

If this flag is set and the printer driver does not


support multiple copies, the Copies edit control is
disabled. Similarly, if this flag is set and the printer
driver does not support collation, the Collate check
box is disabled.

The dmCopies and dmCollate members of the


DEVMODE structure contain the copies and collate
information used by the printer driver. If this flag is set
and the printer driver supports multiple copies, the
dmCopies member indicates the number of copies
requested by the user. If this flag is set and the printer
driver supports collation, the dmCollate member of
the DEVMODE structure indicates whether the user
wants collation. If this flag is not set, the dmCopies
member always returns 1, and the dmCollate member
is always zero.

In Windows versions prior to Windows Vista, if this flag


is not set by the calling application and the dmCopies
member of the DEVMODE structure is greater than 1,
use that value for the number of copies; otherwise, use
the value of the nCopies member of the PRINTDLGEX
structure.

PD_USELARGETEMPLATE Forces the property sheet to use a large template for


0x10000000 the General page. The larger template provides more
space for applications that specify a custom template
for the lower portion of the General page.

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

Pointer to a buffer containing an array of PRINTPAGERANGE structures. On input, the


array contains the initial page ranges to display in the Pages edit control. When the
PrintDlgEx function returns, the array contains the page ranges specified by the user. If
the PD_NOPAGENUMS flag is specified, this value is not valid. If the PD_NOPAGENUMS
flag is not specified, lpPageRanges must be non-NULL.

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

If the PD_ENABLEPRINTTEMPLATE flag is set in the Flags member, hInstance is a


handle to the application or module instance that contains the dialog box template
named by the lpPrintTemplateName member. If the
PD_ENABLEPRINTTEMPLATEHANDLE flag is set in the Flags member, hInstance is a
handle to a memory object containing a dialog box template. If neither of the template
flags is set in the Flags member, hInstance should be NULL.

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

The number of property page handles in the lphPropertyPages array.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

DEVMODE

DEVNAMES

IPrintDialogCallback

IPrintDialogServices

PrintDlgEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


PrintDlgW callback function
(commdlg.h)
Article06/28/2022

Wide string version of PrintDlg

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

Get help at Microsoft Q&A


PRINTDLGW structure (commdlg.h)
Article07/27/2022

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++

typedef struct tagPDW {


DWORD lStructSize;
HWND hwndOwner;
HGLOBAL hDevMode;
HGLOBAL hDevNames;
HDC hDC;
DWORD Flags;
WORD nFromPage;
WORD nToPage;
WORD nMinPage;
WORD nMaxPage;
WORD nCopies;
HINSTANCE hInstance;
LPARAM lCustData;
LPPRINTHOOKPROC lpfnPrintHook;
LPSETUPHOOKPROC lpfnSetupHook;
LPCWSTR lpPrintTemplateName;
LPCWSTR lpSetupTemplateName;
HGLOBAL hPrintTemplate;
HGLOBAL hSetupTemplate;
} PRINTDLGW, *LPPRINTDLGW;

Members
lStructSize

Type: DWORD

The structure size, in bytes.

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

A handle to a movable global memory object that contains a DEVMODE structure. If


hDevMode is not NULL on input, you must allocate a movable block of memory for the
DEVMODE structure and initialize its members. The PrintDlg function uses the input
data to initialize the controls in the dialog box. When PrintDlg returns, the DEVMODE
members indicate the user's input.

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.

If the device name (specified by the dmDeviceName member of the DEVMODE


structure) does not appear in the [devices] section of WIN.INI, PrintDlg returns an error.

For more information about the hDevMode and hDevNames members, see the
Remarks section at the end of this topic.

hDevNames

Type: HGLOBAL

A handle to a movable global memory object that contains a DEVNAMES structure. If


hDevNames is not NULL on input, you must allocate a movable block of memory for
the DEVNAMES structure and initialize its members. The PrintDlg function uses the
input data to initialize the controls in the dialog box. When PrintDlg returns, the
DEVNAMES members contain information for the printer chosen by the user. You can
use this information to create a device context or an information context.

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.

PD_COLLATE If this flag is set, the Collate check box is selected.


0x00000010
If this flag is set when the PrintDlg function returns, the
application must simulate collation of multiple copies.
For more information, see the description of the
PD_USEDEVMODECOPIESANDCOLLATE flag.

See PD_NOPAGENUMS.

PD_DISABLEPRINTTOFILE Disables the Print to File check box.


0x00080000

PD_ENABLEPRINTHOOK Enables the hook procedure specified in the


0x00001000 lpfnPrintHook member. This enables the hook
procedure for the Print dialog box.

PD_ENABLEPRINTTEMPLATE Indicates that the hInstance and


0x00004000 lpPrintTemplateName members specify a replacement
for the default Print dialog box template.

PD_ENABLEPRINTTEMPLATEHANDLE Indicates that the hPrintTemplate member identifies a


0x00010000 data block that contains a preloaded dialog box
template. This template replaces the default template
for the Print dialog box. The system ignores the
lpPrintTemplateName member if this flag is specified.

PD_ENABLESETUPHOOK Enables the hook procedure specified in the


0x00002000 lpfnSetupHook member. This enables the hook
procedure for the Print Setup dialog box.

PD_ENABLESETUPTEMPLATE Indicates that the hInstance and


0x00008000 lpSetupTemplateName members specify a
replacement for the default Print Setup dialog box
template.

PD_ENABLESETUPTEMPLATEHANDLE Indicates that the hSetupTemplate member identifies a


0x00020000 data block that contains a preloaded dialog box
template. This template replaces the default template
for the Print Setup dialog box. The system ignores the
lpSetupTemplateName member if this flag is specified.

PD_HIDEPRINTTOFILE Hides the Print to File check box.


0x00100000

PD_NONETWORKBUTTON Hides and disables the Network button.


0x00200000

PD_NOPAGENUMS Disables the Pages radio button and the associated


0x00000008 edit controls. Also, it causes the Collate check box to
appear in the dialog.

PD_NOSELECTION Disables the Selection radio button.


0x00000004

PD_NOWARNING Prevents the warning message from being displayed


0x00000080 when there is no default printer.

PD_PAGENUMS If this flag is set, the Pages radio button is selected. If


0x00000002 this flag is set when the PrintDlg function returns, the
nFromPage and nToPage members indicate the
starting and ending pages specified by the user.

PD_PRINTSETUP Causes the system to display the Print Setup dialog


0x00000040 box rather than the Print dialog box.

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_RETURNDC Causes PrintDlg to return a device context matching


0x00000100 the selections the user made in the dialog box. The
device context is returned in hDC.

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_RETURNIC Similar to the PD_RETURNDC flag, except this flag


0x00000200 returns an information context rather than a device
context. If neither PD_RETURNDC nor PD_RETURNIC is
specified, hDC is undefined on output.

PD_SELECTION If this flag is set, the Selection radio button is selected.


0x00000001 If neither PD_PAGENUMS nor PD_SELECTION is set,
the All radio button is selected.

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.

PD_USEDEVMODECOPIES Same as PD_USEDEVMODECOPIESANDCOLLATE.


0x00040000

PD_USEDEVMODECOPIESANDCOLLATE This flag indicates whether your application supports


0x00040000 multiple copies and collation. Set this flag on input to
indicate that your application does not support
multiple copies and collation. In this case, the nCopies
member of the PRINTDLG structure always returns 1,
and PD_COLLATE is never set in the Flags member.

If this flag is not set, the application is responsible for


printing and collating multiple copies. In this case, the
nCopies member of the PRINTDLG structure indicates
the number of copies the user wants to print, and the
PD_COLLATE flag in the Flags member indicates
whether the user wants collation.

Regardless of whether this flag is set, an application


can determine from nCopies and PD_COLLATE how
many copies to render and whether to print them
collated.

If this flag is set and the printer driver does not


support multiple copies, the Copies edit control is
disabled. Similarly, if this flag is set and the printer
driver does not support collation, the Collate check
box is disabled.

The dmCopies and dmCollate members of the


DEVMODE structure contain the copies and collate
information used by the printer driver. If this flag is set
and the printer driver supports multiple copies, the
dmCopies member indicates the number of copies
requested by the user. If this flag is set and the printer
driver supports collation, the dmCollate member of
the DEVMODE structure indicates whether the user
wants collation. If this flag is not set, the dmCopies
member always returns 1, and the dmCollate member
is always zero.

Known issue on Windows 2000/XP/2003: If this flag


is not set before calling PrintDlg, PrintDlg might swap
nCopies and dmCopies values when it returns. The
workaround for this issue is use dmCopies if its value is
larger than 1, else, use nCopies, for you to to get the
actual number of copies to be printed when PrintDlg
returns.

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

The initial value for the starting page edit control.

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

If the PD_ENABLEPRINTTEMPLATE or PD_ENABLESETUPTEMPLATE flag is set in the


Flags member, hInstance is a handle to the application or module instance that contains
the dialog box template named by the lpPrintTemplateName or lpSetupTemplateName
member.

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

If the PD_ENABLEPRINTTEMPLATEHANDLE flag is set in the Flags member,


hPrintTemplate is a handle to a memory object containing a dialog box template. This
template replaces the default Print dialog box template.

hSetupTemplate

Type: HGLOBAL

If the PD_ENABLESETUPTEMPLATEHANDLE flag is set in the Flags member,


hSetupTemplate is a handle to a memory object containing a dialog box template. This
template replaces the default Print Setup dialog box template.

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

The commdlg.h header defines PRINTDLG 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)

See also
Common Dialog Box Library

Conceptual

DEVMODE

DEVNAMES

PrintDlg

Reference

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


PRINTPAGERANGE structure
(commdlg.h)
Article04/02/2021

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++

typedef struct tagPRINTPAGERANGE {


DWORD nFromPage;
DWORD nToPage;
} PRINTPAGERANGE;

Members
nFromPage

Type: DWORD

The first page of the range.

nToPage

Type: DWORD

The last page of the range.

Requirements

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Header commdlg.h (include Windows.h)


See also
Common Dialog Box Library

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


ReplaceTextA function (commdlg.h)
Article02/09/2023

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

A pointer to a FINDREPLACE structure that contains information used to initialize the


dialog box. The dialog box uses this structure to send information about the user's input
to your application. For more information, see the following Remarks section.

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

The commdlg.h header defines ReplaceText 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 Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header commdlg.h (include Windows.h)


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

Common Dialog Box Library

Conceptual

FINDREPLACE

FRHookProc

IsDialogMessage

Reference

RegisterWindowMessage

WM_CTLCOLORDLG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


ReplaceTextW function (commdlg.h)
Article02/09/2023

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

A pointer to a FINDREPLACE structure that contains information used to initialize the


dialog box. The dialog box uses this structure to send information about the user's input
to your application. For more information, see the following Remarks section.

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

The commdlg.h header defines ReplaceText 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 Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header commdlg.h (include Windows.h)


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

Common Dialog Box Library

Conceptual

FINDREPLACE

FRHookProc

IsDialogMessage

Reference

RegisterWindowMessage

WM_CTLCOLORDLG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


winuser.h header
Article02/17/2023

This header is used by multiple technologies. For more information, see:

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

winuser.h contains the following programming interfaces:

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

Determines whether two DPI_AWARENESS_CONTEXT values are identical.

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

Blocks keyboard and mouse input events from reaching applications.

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

The BroadcastSystemMessage function sends a message to the specified recipients.


(BroadcastSystemMessage)

BroadcastSystemMessageA

Sends a message to the specified recipients. (BroadcastSystemMessageA)

BroadcastSystemMessageExA

Sends a message to the specified recipients. (BroadcastSystemMessageExA)

BroadcastSystemMessageExW
Sends a message to the specified recipients. (BroadcastSystemMessageExW)

BroadcastSystemMessageW

The BroadcastSystemMessageW (Unicode) function sends a message to the specified recipients.


(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

Passes message information to the specified window procedure. (ANSI)

CallWindowProcW

Passes message information to the specified window procedure. (Unicode)

CascadeWindows

Cascades the specified child windows of the specified parent window.

ChangeClipboardChain

Removes a specified window from the chain of clipboard viewers.

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

Changes the check state of a button control.

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

Confines the cursor to a rectangular area on the screen.


CloseClipboard

Closes the clipboard.

CloseDesktop

Closes an open handle to a desktop object.

CloseGestureInfoHandle

Closes resources associated with a gesture information handle.

CloseTouchInputHandle

Closes a touch input handle, frees process memory associated with it, and invalidates the handle.

CloseWindow

Minimizes (but does not destroy) the specified window.

CloseWindowStation

Closes an open window station handle.

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

Copies the specified cursor.

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

The CopyRect function copies the coordinates of one rectangle to another.

CountClipboardFormats

Retrieves the number of different data formats currently on the clipboard.

CreateAcceleratorTableA

Creates an accelerator table. (ANSI)

CreateAcceleratorTableW

Creates an accelerator table. (Unicode)

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

Creates an icon or cursor from an ICONINFO structure.

CreateMDIWindowA
Creates a multiple-document interface (MDI) child window. (ANSI)

CreateMDIWindowW

Creates a multiple-document interface (MDI) child window. (Unicode)

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

Creates a drop-down menu, submenu, or shortcut menu.

CreateSyntheticPointerDevice

Configures the pointer injection device for the calling application, and initializes the maximum
number of simultaneous pointers that the app can inject.

CreateWindowA

Creates an overlapped, pop-up, or child window. (ANSI)

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

Creates an overlapped, pop-up, or child window. (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)

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

Verifies that the size of the RAWINPUTHEADER structure is correct.

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

Destroys an accelerator table.

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

Destroys an icon and frees any memory the icon occupied.

DestroyMenu

Destroys the specified menu and frees any memory that the menu occupies.

DestroySyntheticPointerDevice

Destroys the specified pointer injection device.

DestroyWindow

Destroys the specified window.

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

The DispatchMessage function dispatches a message to a window procedure. It is typically used


to dispatch a message retrieved by the GetMessage function.

DispatchMessageA

Dispatches a message to a window procedure. It is typically used to dispatch a message retrieved


by the GetMessage function. (DispatchMessageA)

DispatchMessageW

The DispatchMessageW (Unicode) function dispatches a message to a window procedure. It is


typically used to dispatch a message retrieved by the GetMessage function.
DisplayConfigGetDeviceInfo

The DisplayConfigGetDeviceInfo function retrieves display configuration information about the


device.

DisplayConfigSetDeviceInfo

The DisplayConfigSetDeviceInfo function sets the properties of a target.

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

The DrawCaption function draws a window caption.

DrawEdge

The DrawEdge function draws one or more edges of rectangle.

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

Draws an icon or cursor into the specified device context.

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

Enables, disables, or grays the specified menu item.

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

Ends the calling thread's active menu.

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

Forcibly closes the specified window.

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

Enumerates the data formats currently available on the clipboard.

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

The EnumDisplayMonitors function enumerates display monitors (including invisible pseudo-


monitors associated with the mirroring drivers) that intersect a region formed by the intersection
of a specified clipping rectangle and the visible region of a device context. EnumDisplayMonitors
calls an application-defined MonitorEnumProc callback function once for each monitor that is
enumerated. Note that GetSystemMetrics (SM_CMONITORS) counts only the display monitors.

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

Calls the ExitWindowsEx function to log off the interactive user.

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

Retrieves the application command from the specified LPARAM value.

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

Retrieves the hit-test value from the specified WPARAM value.

GET_POINTERID_WPARAM
Retrieves the pointer ID using the specified value.

GET_RAWINPUT_CODE_WPARAM

Retrieves the input code from wParam in WM_INPUT.

GET_WHEEL_DELTA_WPARAM

Retrieves the wheel-delta value from the specified WPARAM value.

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

Retrieves the handle to the ancestor of the specified window.

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

Retrieves the DPI_AWARENESS value from a DPI_AWARENESS_CONTEXT.

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

Copies the caret's position to the specified POINT structure.

GetCIMSSM

Retrieves the source of the input message (GetCurrentInputMessageSourceInSendMessage).

GetClassInfoA

Retrieves information about a window class. (ANSI)

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

Retrieves information about a window class. (Unicode)

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

Retrieves the coordinates of a window's client area.

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

Retrieves the window handle of the current owner of the clipboard.

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

Retrieves information about the specified combo box.

GetCurrentInputMessageSource

Retrieves the source of the input message.

GetCursor

Retrieves a handle to the current cursor.

GetCursorInfo

Retrieves information about the global cursor.

GetCursorPos

Retrieves the position of the mouse cursor, in screen coordinates.

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

Retrieves the screen auto-rotation preferences for the current process.

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

Retrieves the identifier of the specified control.

GetDlgItem

Retrieves a handle to a control in the specified dialog box.

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

Retrieves the current double-click time for the mouse.

GetDpiAwarenessContextForProcess
Gets a DPI_AWARENESS_CONTEXT handle for the specified process.

GetDpiForSystem

Returns the system DPI.

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

Retrieves additional information about a gesture from its GESTUREINFO handle.

GetGestureInfo

Retrieves a GESTUREINFO structure given a handle to the gesture information.

GetGuiResources

Retrieves the count of handles to graphical user interface (GUI) objects in use by the specified
process.

GetGUIThreadInfo

Retrieves information about the active window or a specified GUI thread.

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

Retrieves the current code page.

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

Retrieves information about the current keyboard.


GetKeyNameTextA

Retrieves a string that represents the name of a key. (ANSI)

GetKeyNameTextW

Retrieves a string that represents the name of a key. (Unicode)

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

Retrieves the time of the last input event.

GetLayeredWindowAttributes

Retrieves the opacity and transparency color key of a layered window.

GetListBoxInfo

Retrieves the number of items per column in a specified list box.

GetMenu

Retrieves a handle to the menu assigned to the specified window.

GetMenuBarInfo

Retrieves information about the specified menu bar.

GetMenuCheckMarkDimensions

Retrieves the dimensions of the default check-mark bitmap.

GetMenuContextHelpId

Retrieves the Help context identifier associated with the specified menu.

GetMenuDefaultItem

Determines the default menu item on the specified menu.


GetMenuInfo

Retrieves information about a specified menu.

GetMenuItemCount

Determines the number of items in the specified menu.

GetMenuItemID

Retrieves the menu item identifier of a menu item located at the specified position in a menu.

GetMenuItemInfoA

Retrieves information about a menu item. (ANSI)

GetMenuItemInfoW

Retrieves information about a menu item. (Unicode)

GetMenuItemRect

Retrieves the bounding rectangle for the specified menu item.

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

The GetMonitorInfo function retrieves information about a display monitor. (ANSI)

GetMonitorInfoW

The GetMonitorInfo function retrieves information about a display monitor. (Unicode)

GetMouseMovePointsEx

Retrieves a history of up to 64 previous coordinates of the mouse or pen.

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

Retrieves the position of the cursor in physical coordinates.

GetPointerCursorId

Retrieves the cursor identifier associated with the specified pointer.

GetPointerDevice

Gets information about the pointer device.

GetPointerDeviceCursors

Gets the cursor IDs that are mapped to the cursors associated with a pointer device.

GetPointerDeviceProperties

Gets device properties that aren't included in the POINTER_DEVICE_INFO structure.

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

Gets information about the pointer devices attached to the system.

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

Retrieves the first available clipboard format in the specified list.

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

Performs a buffered read of the raw input data.

GetRawInputData

Retrieves the raw input from the specified device.

GetRawInputDeviceInfoA

Retrieves information about the raw input device. (ANSI)

GetRawInputDeviceInfoW

Retrieves information about the raw input device. (Unicode)

GetRawInputDeviceList

Enumerates the raw input devices attached to the system.


GetRawPointerDeviceData

Gets the raw input data from the pointer device.

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

Retrieves a handle to the Shell's desktop window.

GetSubMenu

Retrieves a handle to the drop-down menu or submenu activated by the specified menu item.

GetSysColor

Retrieves the current color of the specified display element.

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

Retrieves the specified system metric or system configuration setting.

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

Retrieves a handle to the desktop assigned to the specified thread.

GetThreadDpiAwarenessContext

Gets the DPI_AWARENESS_CONTEXT for the current thread.

GetThreadDpiHostingBehavior

Retrieves the DPI_HOSTING_BEHAVIOR from the current thread.

GetTitleBarInfo

Retrieves information about the specified title bar.

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

Retrieves the currently supported clipboard formats.

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

Retrieves security information for the specified user object.

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

Returns the DPI_HOSTING_BEHAVIOR of the specified window.

GetWindowFeedbackSetting

Retrieves the feedback configuration for a window.

GetWindowInfo

Retrieves information about the specified window. (GetWindowInfo)

GetWindowLongA

Retrieves information about the specified window. (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

Retrieves information about the specified window. (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

The GetWindowRgn function obtains a copy of the window region of a window.

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

The GID_ROTATE_ANGLE_FROM_ARGUMENT macro is used to interpret the GID_ROTATE


ullArgument value when receiving the value in the WM_GESTURE structure.

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

Adds or removes highlighting from an item in a menu bar.

InflateRect

The InflateRect function increases or decreases the width and height of the specified rectangle.

InheritWindowMonitor

Causes a specified window to inherit the monitor of another window.

InitializeTouchInjection

Configures the touch injection context for the calling application and initializes the maximum
number of simultaneous contacts that the app can inject.

InjectSyntheticPointerInput

Simulates pointer input (pen or touch).

InjectTouchInput

Simulates touch input.

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

Inserts a new menu item at the specified position in a menu. (ANSI)

InsertMenuItemW

Inserts a new menu item at the specified position in a menu. (Unicode)

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

Determines whether a value is an integer identifier for a resource.


IS_POINTER_CANCELED_WPARAM

Checks whether the specified pointer input ended abruptly, or was invalid, indicating the
interaction was not completed.

IS_POINTER_FIFTHBUTTON_WPARAM

Checks whether the specified pointer took fifth action.

IS_POINTER_FIRSTBUTTON_WPARAM

Checks whether the specified pointer took first action.

IS_POINTER_FLAG_SET_WPARAM

Checks whether a pointer macro sets the specified flag.

IS_POINTER_FOURTHBUTTON_WPARAM

Checks whether the specified pointer took fourth action.

IS_POINTER_INCONTACT_WPARAM

Checks whether the specified pointer is in contact.

IS_POINTER_INRANGE_WPARAM

Checks whether the specified pointer is in range.

IS_POINTER_NEW_WPARAM

Checks whether the specified pointer is a new pointer.

IS_POINTER_SECONDBUTTON_WPARAM

Checks whether the specified pointer took second action.

IS_POINTER_THIRDBUTTON_WPARAM

Checks whether the specified pointer took third action.

IsCharAlphaA

Determines whether a character is an alphabetical character. This determination is based on the


semantics of the language selected by the user during setup or through Control Panel. (ANSI)

IsCharAlphaNumericA

Determines whether a character is either an alphabetical or a numeric character. This


determination is based on the semantics of the language selected by the user during setup or
through Control Panel. (ANSI)

IsCharAlphaNumericW

Determines whether a character is either an alphabetical or a numeric character. This


determination is based on the semantics of the language selected by the user during setup or
through Control Panel. (Unicode)

IsCharAlphaW

Determines whether a character is an alphabetical character. This determination is based on the


semantics of the language selected by the user during setup or through Control Panel. (Unicode)

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

The IsCharLowerW (Unicode) function determines whether a character is lowercase.


(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

Determines whether a window is a child window or descendant window of a specified parent


window.

IsClipboardFormatAvailable

Determines whether the clipboard contains data in the specified format.

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

The IsDlgButtonChecked function determines whether a button control is checked or whether a


three-state button control is checked, unchecked, or indeterminate.

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

Determines whether the specified window is minimized (iconic).

IsImmersiveProcess

Determines whether the process belongs to a Windows Store app.

IsMenu

Determines whether a handle is a menu handle.

IsMouseInPointerEnabled

Indicates whether EnableMouseInPointer is set for the mouse to act as a pointer input device and
send WM_POINTER messages.

IsProcessDPIAware

IsProcessDPIAware may be altered or unavailable. Instead, use GetProcessDPIAwareness.

IsRectEmpty

The IsRectEmpty function determines whether the specified rectangle is empty.

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

Determines whether the specified window handle identifies an existing window.

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

Determines whether the specified window is a native Unicode window.

IsWindowVisible

Determines the visibility state of the specified window.

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

Determines whether a window is maximized.

keybd_event

Synthesizes a keystroke.

KillTimer

Destroys the specified timer.

LoadAcceleratorsA

Loads the specified accelerator table. (ANSI)


LoadAcceleratorsW

Loads the specified accelerator table. (Unicode)

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

Creates a cursor based on data contained in a file. (ANSI)

LoadCursorFromFileW

Creates a cursor based on data contained in a file. (Unicode)

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

Loads an icon, cursor, animated cursor, or bitmap. (ANSI)

LoadImageW

Loads an icon, cursor, animated cursor, or bitmap. (Unicode)


LoadKeyboardLayoutA

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

Loads the specified menu template in memory. (ANSI)

LoadMenuIndirectW

Loads the specified menu template in memory. (Unicode)

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

Converts the logical coordinates of a point in a window to physical coordinates.

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

Converts an integer value to a resource type compatible with the resource-management


functions. This macro is used in place of a string containing the name of the resource. (ANSI)

MAKEINTRESOURCEW

Converts an integer value to a resource type compatible with the resource-management


functions. This macro is used in place of a string containing the name of the resource. (Unicode)

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

Converts the specified dialog box units to screen units (pixels).


MapVirtualKeyA

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

Determines which menu item, if any, is at the specified location.

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

Creates, displays, and operates a message box. (Unicode)

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

Changes an existing menu item. (ANSI)

ModifyMenuW

Changes an existing menu item. (Unicode)

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

The mouse_event function synthesizes mouse motion and button clicks.

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

Retrieves the location of the next structure in an array of RAWINPUT structures.

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

Opens the specified desktop object. (ANSI)

OpenDesktopW

Opens the specified desktop object. (Unicode)

OpenIcon

Restores a minimized (iconic) window to its previous size and position; it then activates the
window.

OpenInputDesktop

Opens the desktop that receives user input.

OpenWindowStationA

Opens the specified window station. (ANSI)

OpenWindowStationW

Opens the specified window station. (Unicode)

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

Converts the physical coordinates of a point in a window to logical coordinates.

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

The POINTTOPOINTS macro converts a POINT structure to a POINTS structure.

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

Retrieves a string that specifies the window type. (ANSI)

RealGetWindowClassW

Retrieves a string that specifies the window type. (Unicode)

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

Defines a system-wide hot key.

RegisterPointerDeviceNotifications

Registers a window to process the WM_POINTERDEVICECHANGE, WM_POINTERDEVICEINRANGE,


and WM_POINTERDEVICEOUTOFRANGE pointer device notifications.

RegisterPointerInputTarget

Allows the caller to register a target window to which all pointer input of the specified type is
redirected.

RegisterPointerInputTargetEx

RegisterPointerInputTargetEx may be altered or unavailable. Instead, use


RegisterPointerInputTarget.

RegisterPowerSettingNotification
Registers the application to receive power setting notifications for the specific power setting
event.

RegisterRawInputDevices

Registers the devices that supply the raw input data.

RegisterShellHookWindow

Registers a specified Shell window to receive certain messages for events or notifications that are
useful to Shell applications.

RegisterSuspendResumeNotification

Registers to receive notification when the system is suspended or resumed. Similar to


PowerRegisterSuspendResumeNotification, but operates in user mode and can take a window
handle.

RegisterTouchHitTestingWindow

Registers a window to process the WM_TOUCHHITTESTING notification.

RegisterTouchWindow

Registers a window as being touch-capable.

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

Deletes a menu item or detaches a submenu from the specified menu.

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

Replies to a message sent from another thread by the SendMessage function.

ScreenToClient

The ScreenToClient function converts the screen coordinates of a specified point on the screen to
client-area coordinates.

ScrollDC

The ScrollDC function scrolls a rectangle of bits horizontally and vertically.

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

Sends a message to the specified control in a dialog box. (ANSI)

SendDlgItemMessageW

Sends a message to the specified control in a dialog box. (Unicode)

SendInput

Synthesizes keystrokes, mouse motions, and button clicks.


SendMessage

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

Sends the specified message to a window or windows. (SendMessageCallbackA)

SendMessageCallbackW

Sends the specified message to a window or windows. (SendMessageCallbackW)

SendMessageTimeoutA

Sends the specified message to one or more windows. (ANSI)

SendMessageTimeoutW

Sends the specified message to one or more windows. (Unicode)

SendMessageW

The SendMessageW (Unicode) function sends the specified message to a window or windows.
(SendMessageW)

SendNotifyMessageA

Sends the specified message to a window or windows. (SendNotifyMessageA)

SendNotifyMessageW

Sends the specified message to a window or windows. (SendNotifyMessageW)

SetActiveWindow

Activates a window. The window must be attached to the calling thread's message queue.

SetAdditionalForegroundBoostProcesses

SetAdditionalForegroundBoostProcesses is a performance assist API to help applications with a


multi-process application model where multiple processes contribute to a foreground experience,
either as data or rendering.
SetCapture

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

Places data on the clipboard in a specified clipboard format.

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

Sets the cursor shape.

SetCursorPos

Moves the cursor to the specified screen coordinates.

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

Sets the screen auto-rotation preferences for the current process.

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

Sets the title or text of a control in a dialog box. (ANSI)

SetDlgItemTextW

Sets the title or text of a control in a dialog box. (Unicode)

SetDoubleClickTime

Sets the double-click time for the mouse.

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

Sets the last-error code.

SetLayeredWindowAttributes

Sets the opacity and transparency color key of a layered window.

SetMenu

Assigns a new menu to the specified window.

SetMenuContextHelpId

Associates a Help context identifier with a menu.

SetMenuDefaultItem

Sets the default menu item for the specified menu.

SetMenuInfo

Sets information for a specified menu.

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

Changes information about a menu item. (Unicode)

SetMessageExtraInfo

Sets the extra message information for the current thread.

SetParent

Changes the parent window of the specified child window.

SetPhysicalCursorPos

Sets the position of the cursor in physical coordinates.

SetProcessDefaultLayout

Changes the default layout when windows are created with no parent or owner only for the
currently running process.

SetProcessDPIAware

SetProcessDPIAware may be altered or unavailable. Instead, use SetProcessDPIAwareness.

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

Assigns the specified window station to the calling process.

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

Sets the colors for the specified display elements.

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

Creates a timer with the specified time-out value.

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

Associates a Help context identifier with the specified window.

SetWindowDisplayAffinity

Stores the display affinity setting in kernel mode on the hWnd associated with the window.

SetWindowFeedbackSetting

Sets the feedback configuration for a window.

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

Changes an attribute of the specified window. (ANSI)

SetWindowLongPtrW

Changes an attribute of the specified window. (Unicode)

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

The SetWindowRgn function sets the window region of a window.

SetWindowsHookExA

Installs an application-defined hook procedure into a hook chain. (ANSI)

SetWindowsHookExW

Installs an application-defined hook procedure into a hook chain. (Unicode)

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

Sets an event hook function for a range of events.

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

Shows or hides all pop-up windows owned by the specified window.

ShowScrollBar

The ShowScrollBar function shows or hides the specified scroll bar.

ShowWindow

Sets the specified window's show state.

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

Retrieves the reason string set by the ShutdownBlockReasonCreate function.

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

Triggers a visual signal to indicate that a sound is playing.

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

Switches focus to the specified window and brings it to the foreground.

SystemParametersInfoA

Retrieves or sets the value of one of the system-wide parameters. (ANSI)

SystemParametersInfoForDpi

Retrieves the value of one of the system-wide parameters, taking into account the provided DPI
value.

SystemParametersInfoW

Retrieves or sets the value of one of the system-wide parameters. (Unicode)

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

Tiles the specified child windows of the specified parent window.

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

Converts touch coordinates to pixels.

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

Processes accelerator keys for menu commands. (ANSI)

TranslateAcceleratorW

Processes accelerator keys for menu commands. (Unicode)

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

Removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.

UnhookWinEvent

Removes an event hook function created by a previous call to SetWinEventHook.

UnionRect

The UnionRect function creates the union of two rectangles. The union is the smallest rectangle
that contains both source rectangles.

UnloadKeyboardLayout

Unloads an input locale identifier (formerly called a keyboard layout).

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

Closes the specified device notification handle.

UnregisterHotKey

Frees a hot key previously registered by the calling thread.

UnregisterPointerInputTarget

Allows the caller to unregister a target window to which all pointer input of the specified type is
redirected.

UnregisterPointerInputTargetEx

UnregisterPointerInputTargetEx may be altered or unavailable. Instead, use


UnregisterPointerInputTarget.

UnregisterPowerSettingNotification

Unregisters the power setting notification.

UnregisterSuspendResumeNotification
Cancels a registration to receive notification when the system is suspended or resumed. Similar to
PowerUnregisterSuspendResumeNotification but operates in user mode.

UnregisterTouchWindow

Registers a window as no longer being touch-capable.

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

Retrieves a handle to the window that contains the specified point.

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

Writes formatted data to the specified buffer. (ANSI)

wsprintfW

Writes formatted data to the specified buffer. (Unicode)

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

The DrawStateProc function is an application-defined callback function that renders a complex


image for the DrawState function.

EDITWORDBREAKPROCA

An application-defined callback function used with the EM_SETWORDBREAKPROC message.


(ANSI)

EDITWORDBREAKPROCW

An application-defined callback function used with the EM_SETWORDBREAKPROC message.


(Unicode)

GRAYSTRINGPROC

The OutputProc function is an application-defined callback function used with the GrayString
function.

HOOKPROC

An application-defined or library-defined callback function used with the SetWindowsHookEx


function. The system calls this function after the SendMessage function is called. The hook
procedure can examine the message; it cannot modify it.

MONITORENUMPROC

A MonitorEnumProc function is an application-defined callback function that is called by the


EnumDisplayMonitors function.

MSGBOXCALLBACK
A callback function, which you define in your application, that processes help events for the
message box.

PROPENUMPROCA

An application-defined callback function used with the EnumProps function. (ANSI)

PROPENUMPROCEXA

Application-defined callback function used with the EnumPropsEx function. (ANSI)

PROPENUMPROCEXW

Application-defined callback function used with the EnumPropsEx function. (Unicode)

PROPENUMPROCW

An application-defined callback function used with the EnumProps function. (Unicode)

SENDASYNCPROC

An application-defined callback function used with the SendMessageCallback function.

TIMERPROC

An application-defined callback function that processes WM_TIMER messages. The TIMERPROC


type defines a pointer to this callback function. TimerProc is a placeholder for the application-
defined function name.

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

Defines an accelerator key used in an accelerator table.


ACCESSTIMEOUT

Contains information about the time-out period associated with the accessibility features.

ALTTABINFO

Contains status information for the application-switching (ALT+TAB) window.

ANIMATIONINFO

Describes the animation effects associated with user actions.

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

Contains information about a window that denied a request from BroadcastSystemMessageEx.

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

Contains information passed to a WH_CBT hook procedure, CBTProc, before a window is


activated.

CHANGEFILTERSTRUCT

Contains extended result information obtained by calling the ChangeWindowMessageFilterEx


function.

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

Contains data to be passed to another application by the WM_COPYDATA message.

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

Contains global cursor information.

CURSORSHAPE

Contains information about a cursor.

CWPRETSTRUCT

Defines the message parameters passed to a WH_CALLWNDPROCRET hook procedure,


CallWndRetProc.

CWPSTRUCT

Defines the message parameters passed to a WH_CALLWNDPROC hook procedure, CallWndProc.

DEBUGHOOKINFO

Contains debugging information passed to a WH_DEBUG hook procedure, DebugProc.

DELETEITEMSTRUCT

Describes a deleted list box or combo box item.

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

Defines the dimensions and style of a dialog box.

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

Stores information about a gesture.

GESTURENOTIFYSTRUCT

When transmitted with WM_GESTURENOTIFY messages, passes information about a gesture.

GUITHREADINFO

Contains information about a GUI thread.


HARDWAREINPUT

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

Contains information about the high contrast accessibility feature. (ANSI)

HIGHCONTRASTW

Contains information about the high contrast accessibility feature. (Unicode)

ICONINFO

Contains information about an icon or a cursor.

ICONINFOEXA

Contains information about an icon or a cursor. Extends ICONINFO. Used by GetIconInfoEx. (ANSI)

ICONINFOEXW

Contains information about an icon or a cursor. Extends ICONINFO. Used by GetIconInfoEx.


(Unicode)

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

Contains the input injection details.

INPUT_MESSAGE_SOURCE

Contains information about the source of the input message.

INPUT_TRANSFORM

Defines the matrix that represents a transform on a message consumer.

KBDLLHOOKSTRUCT

Contains information about a low-level keyboard input event.

KEYBDINPUT

Contains information about a simulated keyboard event.

LASTINPUTINFO

Contains the time of the last input.

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

Contains information about the menu to be activated.

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

Contains menu bar information.

MENUGETOBJECTINFO

Contains information about the menu that the mouse cursor is on.

MENUINFO

Contains information about a menu.

MENUITEMINFOA

Contains information about a menu item. (MENUITEMINFOA)

MENUITEMINFOW

Contains information about a menu item. (MENUITEMINFOW)

MENUITEMTEMPLATE

Defines a menu item in a menu template.

MENUITEMTEMPLATEHEADER

Defines the header for a menu template. A complete menu template consists of a header and one
or more menu item lists.

MINIMIZEDMETRICS

Contains the scalable metrics associated with minimized windows.

MINMAXINFO

Contains information about a window's maximized size and position and its minimum and
maximum tracking size.

MONITORINFO

The MONITORINFO structure contains information about a display monitor.The GetMonitorInfo


function stores information in a MONITORINFO structure or a MONITORINFOEX structure.The
MONITORINFO structure is a subset of the MONITORINFOEX structure.

MONITORINFOEXA

The MONITORINFOEX structure contains information about a display monitor.The GetMonitorInfo


function stores information into a MONITORINFOEX structure or a MONITORINFO structure.The
MONITORINFOEX structure is a superset of the MONITORINFO structure. (ANSI)

MONITORINFOEXW

The MONITORINFOEX structure contains information about a display monitor.The GetMonitorInfo


function stores information into a MONITORINFOEX structure or a MONITORINFO structure.The
MONITORINFOEX structure is a superset of the MONITORINFO structure. (Unicode)

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

Contains information about a simulated mouse event.

MOUSEKEYS

Contains information about the MouseKeys accessibility feature.

MOUSEMOVEPOINT

Contains information about the mouse's location in screen coordinates.

MSG

Contains message information from a thread's message queue.

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

Contains information about a low-level mouse input event.


MULTIKEYHELPA

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

Contains cursor ID mappings for pointer devices.

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

Defines basic pen information common to all pointer types.

POINTER_TOUCH_INFO

Defines basic touch information common to all pointer types.

POINTER_TYPE_INFO

Contains information about the pointer input type.

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

Contains the raw input from a device.

RAWINPUTDEVICE

Defines information for the raw input devices.

RAWINPUTDEVICELIST

Contains information about a raw input device.

RAWINPUTHEADER

Contains the header information that is part of the raw input data.

RAWKEYBOARD

Contains information about the state of the keyboard.

RAWMOUSE

Contains information about the state of the mouse.


RID_DEVICE_INFO

Defines the raw input data coming from any device.

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

The SCROLLBARINFO structure contains scroll bar information.

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

Contains information about the StickyKeys accessibility feature.

STYLESTRUCT

Contains the styles for a window.

TITLEBARINFO

Contains title bar information.

TITLEBARINFOEX

Expands on the information described in the TITLEBARINFO structure by including the coordinates
of each element of the title bar.

TOGGLEKEYS

Contains information about the ToggleKeys accessibility feature.

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

Encapsulates data for touch input.

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

Contains extended parameters for the TrackPopupMenuEx function.

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

Used by UpdateLayeredWindowIndirect to provide position, size, shape, content, and translucency


information for a layered window.

USAGE_PROPERTIES

Contains device properties (Human Interface Device (HID) global items that correspond to HID
usages) for any type of HID input device.

USEROBJECTFLAGS

Contains information about a window station or desktop handle.

WINDOWINFO

Contains window information.

WINDOWPLACEMENT

Contains information about the placement of a window on the screen.

WINDOWPOS

Contains information about the size and position of a window.

WNDCLASSA

Contains the window class attributes that are registered by the RegisterClass function. (ANSI)

WNDCLASSEXA

Contains window class information. (ANSI)

WNDCLASSEXW

Contains window class information. (Unicode)

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

Specifies the visual feedback associated with an event.

INPUT_MESSAGE_DEVICE_TYPE

The type of device that sent the input message.

INPUT_MESSAGE_ORIGIN_ID

The ID of the input message source.

ORIENTATION_PREFERENCE

Indicates the screen orientation preference for a desktop app process.

POINTER_BUTTON_CHANGE_TYPE

Identifies a change in the state of a button associated with a pointer.

POINTER_DEVICE_CURSOR_TYPE

Identifies the pointer device cursor types.

POINTER_DEVICE_TYPE

Identifies the pointer device types.

POINTER_FEEDBACK_MODE
Identifies the visual feedback behaviors available to CreateSyntheticPointerDevice.

tagPOINTER_INPUT_TYPE

Identifies the pointer input types.

TOOLTIP_DISMISS_FLAGS

The TOOLTIP_DISMISS_FLAGS enumeration defines constants that indicate whether a window is


registered or unregistered to receive tooltip dismiss notifications.

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


CreateDialogA macro (winuser.h)
Article02/09/2023

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.

[in, optional] hWndParent

Type: HWND

A handle to the window that owns the dialog box.


[in, optional] lpDialogFunc

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

The winuser.h header defines CreateDialog 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


CreateDialogIndirectA macro (winuser.h)
Article02/09/2023

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

A handle to the module that creates the dialog box.

[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 a standard template, the header is a DLGTEMPLATE structure followed by additional


variable-length arrays. The data for each control consists of a DLGITEMTEMPLATE
structure followed by additional variable-length arrays.

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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines CreateDialogIndirect 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


CreateDialogIndirectParamA function
(winuser.h)
Article02/09/2023

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 a standard template, the header is a DLGTEMPLATE structure followed by additional


variable-length arrays. The data for each control consists of a DLGITEMTEMPLATE
structure followed by additional variable-length arrays.

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.

[in, optional] hWndParent

Type: HWND

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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.

After CreateDialogIndirectParam 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.

7 Note

The winuser.h header defines CreateDialogIndirectParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows


Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

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

Get help at Microsoft Q&A


CreateDialogIndirectParamW function
(winuser.h)
Article02/09/2023

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 a standard template, the header is a DLGTEMPLATE structure followed by additional


variable-length arrays. The data for each control consists of a DLGITEMTEMPLATE
structure followed by additional variable-length arrays.

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.

[in, optional] hWndParent

Type: HWND

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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.

After CreateDialogIndirectParam 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.

7 Note

The winuser.h header defines CreateDialogIndirectParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows


Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

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

Get help at Microsoft Q&A


CreateDialogIndirectW macro
(winuser.h)
Article02/09/2023

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

A handle to the module that creates the dialog box.

[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 a standard template, the header is a DLGTEMPLATE structure followed by additional


variable-length arrays. The data for each control consists of a DLGITEMTEMPLATE
structure followed by additional variable-length arrays.

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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines CreateDialogIndirect 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


CreateDialogParamA function
(winuser.h)
Article02/09/2023

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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines CreateDialogParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

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

Get help at Microsoft Q&A


CreateDialogParamW function
(winuser.h)
Article02/09/2023

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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines CreateDialogParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

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

Get help at Microsoft Q&A


CreateDialogW macro (winuser.h)
Article02/09/2023

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.

[in, optional] hWndParent

Type: HWND

A handle to the window that owns the dialog box.


[in, optional] lpDialogFunc

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

The winuser.h header defines CreateDialog 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


DefDlgProcA function (winuser.h)
Article07/27/2022

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++

LRESULT LRESULT DefDlgProcA(


[in] HWND hDlg,
[in] UINT Msg,
[in] WPARAM wParam,
[in] LPARAM lParam
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box.

[in] Msg

Type: UINT

The message.

[in] wParam

Type: WPARAM

Additional message-specific information.

[in] lParam

Type: LPARAM

Additional message-specific information.


Return value
Type: LRESULT

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

See also
Conceptual

DefWindowProc
Dialog Boxes
GetClassInfo

Reference

RegisterClass
WNDCLASS

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


DefDlgProcW function (winuser.h)
Article02/09/2023

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++

LRESULT LRESULT DefDlgProcW(


[in] HWND hDlg,
[in] UINT Msg,
[in] WPARAM wParam,
[in] LPARAM lParam
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box.

[in] Msg

Type: UINT

The message.

[in] wParam

Type: WPARAM

Additional message-specific information.

[in] lParam

Type: LPARAM

Additional message-specific information.


Return value
Type: LRESULT

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

See also
Conceptual

DefWindowProc

Dialog Boxes

GetClassInfo

Reference

RegisterClass

WNDCLASS

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


DialogBoxA macro (winuser.h)
Article02/09/2023

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.

DialogBox is implemented as a call to the DialogBoxParam 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.

[in, optional] hWndParent

Type: HWND
A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

For an example, see Creating a Modal Dialog Box.

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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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.

DialogBoxIndirect is implemented as a call to the DialogBoxIndirectParam function.

Syntax
C++

void DialogBoxIndirectA(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);

Parameters
[in, optional] hInstance

Type: HINSTANCE

A handle to the module that creates the dialog box.

[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 a standard template for a dialog box, the header is a DLGTEMPLATE structure


followed by additional variable-length arrays. The data for each control consists of a
DLGITEMTEMPLATE structure followed by additional variable-length arrays.

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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines DialogBoxIndirect 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


DialogBoxIndirectParamA function
(winuser.h)
Article02/09/2023

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

A handle to the module that creates the dialog box.

[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.

In a standard template for a dialog box, the header is a DLGTEMPLATE structure


followed by additional variable-length arrays. The data for each control consists of a
DLGITEMTEMPLATE structure followed by additional variable-length arrays.
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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines DialogBoxIndirectParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib
DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

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

Get help at Microsoft Q&A


DialogBoxIndirectParamW function
(winuser.h)
Article02/09/2023

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

A handle to the module that creates the dialog box.

[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.

In a standard template for a dialog box, the header is a DLGTEMPLATE structure


followed by additional variable-length arrays. The data for each control consists of a
DLGITEMTEMPLATE structure followed by additional variable-length arrays.
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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines DialogBoxIndirectParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib
DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

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

Get help at Microsoft Q&A


DialogBoxIndirectW 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.

DialogBoxIndirect is implemented as a call to the DialogBoxIndirectParam function.

Syntax
C++

void DialogBoxIndirectW(
[in, optional] hInstance,
[in] lpTemplate,
[in, optional] hWndParent,
[in, optional] lpDialogFunc
);

Parameters
[in, optional] hInstance

Type: HINSTANCE

A handle to the module that creates the dialog box.

[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 a standard template for a dialog box, the header is a DLGTEMPLATE structure


followed by additional variable-length arrays. The data for each control consists of a
DLGITEMTEMPLATE structure followed by additional variable-length arrays.

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

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines DialogBoxIndirect 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


DialogBoxParamA function (winuser.h)
Article02/09/2023

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.

[in, optional] hWndParent


Type: HWND

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines DialogBoxParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-1 (introduced in Windows 8.1)

See also
Conceptual

CreateWindowEx

Dialog Boxes

DialogBox

DialogBoxIndirect

DialogBoxIndirectParam

DialogProc

EndDialog

MAKEINTRESOURCE
Reference

WM_INITDIALOG

WM_SETFONT

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


DialogBoxParamW function (winuser.h)
Article02/09/2023

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.

[in, optional] hWndParent


Type: HWND

A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

The winuser.h header defines DialogBoxParam 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-1 (introduced in Windows 8.1)

See also
Conceptual

CreateWindowEx

Dialog Boxes

DialogBox

DialogBoxIndirect

DialogBoxIndirectParam

DialogProc

EndDialog

MAKEINTRESOURCE
Reference

WM_INITDIALOG

WM_SETFONT

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


DialogBoxW macro (winuser.h)
Article02/09/2023

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.

DialogBox is implemented as a call to the DialogBoxParam 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.

[in, optional] hWndParent

Type: HWND
A handle to the window that owns the dialog box.

[in, optional] lpDialogFunc

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

For an example, see Creating a Modal Dialog Box.

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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

The width, in dialog box units, of the control.

cy

Type: short

The height, in dialog box units, of the control.

id

Type: WORD

The control identifier.

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.

Each DLGITEMTEMPLATE structure in the template must be aligned on a DWORD


boundary. The class and title arrays must be aligned on WORD boundaries. The creation
data array must be aligned on a WORD boundary.

Immediately following each DLGITEMTEMPLATE structure is a class array that specifies


the window class of the control. If the first element of this array is any value other than
0xFFFF, the system treats the array as a null-terminated Unicode string that specifies the
name of a registered window class. If the first element is 0xFFFF, the array has one
additional element that specifies the ordinal value of a predefined system class. The
ordinal can be one of the following atom values.

Value Meaning

0x0080 Button

0x0081 Edit

0x0082 Static

0x0083 List box

0x0084 Scroll bar

0x0085 Combo box

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

Minimum supported client Windows 2000 Professional [desktop apps only]


Minimum supported server Windows 2000 Server [desktop apps only]

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


DLGPROC callback function (winuser.h)
Article04/02/2021

Application-defined callback function used with the CreateDialog and DialogBox


families of functions. It processes messages sent to a modal or modeless dialog box. The
DLGPROC type defines a pointer to this callback function. DialogProc is a placeholder
for the application-defined function name.

Syntax
C++

DLGPROC Dlgproc;

INT_PTR Dlgproc(
HWND unnamedParam1,
UINT unnamedParam2,
WPARAM unnamedParam3,
LPARAM unnamedParam4
)
{...}

Parameters
unnamedParam1

Type: HWND

A handle to the dialog box.

unnamedParam2

Type: UINT

The message.

unnamedParam3

Type: WPARAM

Additional message-specific information.

unnamedParam4
Type: LPARAM

Additional message-specific information.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


DLGTEMPLATE structure (winuser.h)
Article03/13/2023

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.

The DS_SHELLFONT style is not supported in the DLGTEMPLATE header.


dwExtendedStyle

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

The number of items in the dialog box.

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

The width, in dialog box units, of the dialog box.

cy

Type: short

The height, in dialog box units, of the dialog box.

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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header winuser.h (include Windows.h)

See also
Conceptual

CreateDialogIndirect

CreateDialogIndirectParam

DLGITEMTEMPLATE

DLGITEMTEMPLATEEX

DLGTEMPLATEEX

Dialog Boxes

DialogBoxIndirect

DialogBoxIndirectParam

MapDialogRect

MultiByteToWideChar

Other Resources

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


EndDialog function (winuser.h)
Article10/13/2021

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

A handle to the dialog box to be destroyed.

[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 succeeds, the return value is nonzero.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

DialogBox

DialogBoxIndirect

DialogBoxIndirectParam
DialogBoxParam

Reference

WM_INITDIALOG

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetDialogBaseUnits function (winuser.h)
Article06/29/2021

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:

pixelX = MulDiv(templateunitX, baseunitX, 4);


pixelY = MulDiv(templateunitY, baseunitY, 8);

Similarly, to convert from pixels to dialog template units, use the following formulas:

templateunitX = MulDiv(pixelX, 4, baseunitX);


templateunitY = MulDiv(pixelY, 8, baseunitY);

Examples

For an example, see "Creating a Combo Box Toolbar" in Using Combo Boxes.

Requirements

Minimum supported Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-2 (introduced in Windows 10,


version 10.0.10240)
See also
Conceptual

Dialog Boxes

MapDialogRect

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetDlgCtrlID function (winuser.h)
Article10/13/2021

Retrieves the identifier of the specified control.

Syntax
C++

int GetDlgCtrlID(
[in] HWND hWnd
);

Parameters
[in] hWnd

Type: HWND

A handle to the control.

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.

Although GetDlgCtrlID may return a value if hwndCtl is a handle to a top-level window,


top-level windows cannot have identifiers and such a return value is never valid.
Examples
For an example, see Initializing a Dialog Box.

Requirements

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

CreateWindow

CreateWindowEx

Dialog Boxes

GetDlgItem

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetDlgItem function (winuser.h)
Article10/13/2021

Retrieves a handle to a control in the specified dialog box.

Syntax
C++

HWND GetDlgItem(
[in, optional] HWND hDlg,
[in] int nIDDlgItem
);

Parameters
[in, optional] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The identifier of the control to be retrieved.

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

CreateWindow

CreateWindowEx

Dialog Boxes

GetDlgItemInt

GetDlgItemText

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetDlgItemInt function (winuser.h)
Article10/13/2021

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

A handle to the dialog box that contains the control of interest.

[in] nIDDlgItem

Type: int

The identifier of the control whose text is to be translated.

[out, optional] lpTranslated

Type: BOOL*

Indicates success or failure (TRUE indicates success, FALSE indicates failure).

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.

If lpTranslated is NULL, the function returns no information about success or 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.

To get extended error information, call GetLastError.

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

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-2 (introduced in Windows 10,


version 10.0.10240)

See also
Conceptual

Dialog Boxes

GetDlgCtrlID

GetDlgItem

GetDlgItemText

Reference

SetDlgItemInt

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetDlgItemTextA function (winuser.h)
Article02/09/2023

Retrieves the title or text associated with a control in a dialog box.

Syntax
C++

UINT GetDlgItemTextA(
[in] HWND hDlg,
[in] int nIDDlgItem,
[out] LPSTR lpString,
[in] int cchMax
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The identifier of the control whose title or text is to be retrieved.

[out] lpString

Type: LPTSTR

The buffer to receive the title or text.

[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.

The GetDlgItemText function sends a WM_GETTEXT message to the control.

Examples
For an example, see Creating a Modal Dialog Box.

7 Note

The winuser.h header defines GetDlgItemText 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib
DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

GetDlgItemInt

Reference

SetDlgItemInt

SetDlgItemText

WM_GETTEXT

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetDlgItemTextW function (winuser.h)
Article02/09/2023

Retrieves the title or text associated with a control in a dialog box.

Syntax
C++

UINT GetDlgItemTextW(
[in] HWND hDlg,
[in] int nIDDlgItem,
[out] LPWSTR lpString,
[in] int cchMax
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The identifier of the control whose title or text is to be retrieved.

[out] lpString

Type: LPTSTR

The buffer to receive the title or text.

[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.

The GetDlgItemText function sends a WM_GETTEXT message to the control.

Examples
For an example, see Creating a Modal Dialog Box.

7 Note

The winuser.h header defines GetDlgItemText 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib
DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

GetDlgItemInt

Reference

SetDlgItemInt

SetDlgItemText

WM_GETTEXT

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetNextDlgGroupItem function
(winuser.h)
Article10/13/2021

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

A handle to the dialog box to be searched.

[in, optional] hCtl

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]


Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

See also
Conceptual

Dialog Boxes

GetNextDlgTabItem

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


GetNextDlgTabItem function (winuser.h)
Article10/13/2021

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

A handle to the dialog box to be searched.

[in, optional] hCtl

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

Minimum supported Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-2 (introduced in Windows 10,


version 10.0.10240)

See also
Conceptual

Dialog Boxes

GetDlgItem
GetNextDlgGroupItem

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


IsDialogMessageA function (winuser.h)
Article02/09/2023

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

A handle to the dialog box.

[in] lpMsg

Type: LPMSG

A pointer to an MSG structure that contains the message to be checked.

Return value
Type: BOOL

If the message has been processed, the return value is nonzero.

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.

When IsDialogMessage processes a message, it checks for keyboard messages and


converts them into selections for the corresponding dialog box. For example, the TAB
key, when pressed, selects the next control or group of controls, and the DOWN ARROW
key, when pressed, selects the next control in a group.

Because the IsDialogMessage function performs all necessary translating and


dispatching of messages, a message processed by IsDialogMessage must not be passed
to the TranslateMessage or DispatchMessage function.

IsDialogMessage sends WM_GETDLGCODE messages to the dialog box procedure to


determine which keys should be processed.

IsDialogMessage can send DM_GETDEFID and DM_SETDEFID messages to the window.


These messages are defined in the Winuser.h header file as WM_USER and WM_USER +
1, so conflicts are possible with application-defined messages having the same values.

7 Note

The winuser.h header defines IsDialogMessage 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 Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


IsDialogMessageW function (winuser.h)
Article02/09/2023

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

A handle to the dialog box.

[in] lpMsg

Type: LPMSG

A pointer to an MSG structure that contains the message to be checked.

Return value
Type: BOOL

If the message has been processed, the return value is nonzero.

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.

When IsDialogMessage processes a message, it checks for keyboard messages and


converts them into selections for the corresponding dialog box. For example, the TAB
key, when pressed, selects the next control or group of controls, and the DOWN ARROW
key, when pressed, selects the next control in a group.

Because the IsDialogMessage function performs all necessary translating and


dispatching of messages, a message processed by IsDialogMessage must not be passed
to the TranslateMessage or DispatchMessage function.

IsDialogMessage sends WM_GETDLGCODE messages to the dialog box procedure to


determine which keys should be processed.

IsDialogMessage can send DM_GETDEFID and DM_SETDEFID messages to the window.


These messages are defined in the Winuser.h header file as WM_USER and WM_USER +
1, so conflicts are possible with application-defined messages having the same values.

7 Note

The winuser.h header defines IsDialogMessage 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 Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


MapDialogRect function (winuser.h)
Article10/13/2021

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.

[in, out] lpRect

Type: LPRECT

A pointer to a RECT structure that contains the dialog box coordinates to be converted.

Return value
Type: BOOL

If the function succeeds, the return value is nonzero.

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

left = MulDiv(left, baseunitX, 4);


right = MulDiv(right, baseunitX, 4);
top = MulDiv(top, baseunitY, 8);
bottom = MulDiv(bottom, baseunitY, 8);

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

Minimum supported Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-2 (introduced in Windows 10,


version 10.0.10240)

See also
Conceptual

Dialog Boxes

GetDialogBaseUnits
Other Resources

RECT

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MessageBox function (winuser.h)
Article08/02/2022

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.

[in, optional] lpText

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.

[in, optional] lpCaption

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_ABORTRETRYIGNORE The message box contains three push buttons: Abort,


0x00000002L Retry, and Ignore.

MB_CANCELTRYCONTINUE The message box contains three push buttons: Cancel,


0x00000006L Try Again, Continue. Use this message box type instead
of MB_ABORTRETRYIGNORE.

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_OKCANCEL The message box contains two push buttons: OK and


0x00000001L Cancel.

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

MB_ICONEXCLAMATION An exclamation-point icon appears in the message box.


0x00000030L

MB_ICONWARNING An exclamation-point icon appears in the message box.


0x00000030L

MB_ICONINFORMATION An icon consisting of a lowercase letter i in a circle


0x00000040L appears in the message box.

MB_ICONASTERISK An icon consisting of a lowercase letter i in a circle


0x00000040L appears in the message box.
MB_ICONQUESTION A question-mark icon appears in the message box. The
0x00000020L question-mark message icon is no longer recommended
because it does not clearly represent a specific type of
message and because the phrasing of a message as a
question could apply to any message type. In addition,
users can confuse the message symbol question mark
with Help information. Therefore, do not use this
question mark message symbol in your message boxes.
The system continues to support its inclusion only for
backward compatibility.

MB_ICONSTOP A stop-sign icon appears in the message box.


0x00000010L

MB_ICONERROR A stop-sign icon appears in the message box.


0x00000010L

MB_ICONHAND A stop-sign icon appears in the message box.


0x00000010L

To indicate the default button, specify one of the following values.

Value Meaning

MB_DEFBUTTON1 The first button is the default button.


0x00000000L MB_DEFBUTTON1 is the default unless
MB_DEFBUTTON2, MB_DEFBUTTON3, or
MB_DEFBUTTON4 is specified.

MB_DEFBUTTON2 The second button is the default button.


0x00000100L

MB_DEFBUTTON3 The third button is the default button.


0x00000200L

MB_DEFBUTTON4 The fourth button is the default button.


0x00000300L

To indicate the modality of the dialog box, specify one of the following values.

Value Meaning

MB_APPLMODAL The user must respond to the message box before


0x00000000L continuing work in the window identified by the hWnd
parameter. However, the user can move to the windows
of other threads and work in those windows.
Depending on the hierarchy of windows in the
application, the user may be able to move to other
windows within the thread. All child windows of the
parent of the message box are automatically disabled,
but pop-up windows are not.

MB_APPLMODAL is the default if neither


MB_SYSTEMMODAL nor MB_TASKMODAL is specified.

MB_SYSTEMMODAL Same as MB_APPLMODAL except that the message box


0x00001000L has the WS_EX_TOPMOST style. Use system-modal
message boxes to notify the user of serious, potentially
damaging errors that require immediate attention (for
example, running out of memory). This flag has no effect
on the user's ability to interact with windows other than
those associated with hWnd.

MB_TASKMODAL Same as MB_APPLMODAL except that all the top-level


0x00002000L windows belonging to the current thread are disabled if
the hWnd parameter is NULL. Use this flag when the
calling application or library does not have a window
handle available but still needs to prevent input to other
windows in the calling thread without suspending other
threads.

To specify other options, use one or more of the following values.

Value Meaning

MB_DEFAULT_DESKTOP_ONLY Same as desktop of the interactive window station. For


0x00020000L more information, see Window Stations.

If the current input desktop is not the default desktop,


MessageBox does not return until the user switches to
the default desktop.

MB_RIGHT The text is right-justified.


0x00080000L

MB_RTLREADING Displays message and caption text using right-to-left


0x00100000L reading order on Hebrew and Arabic systems.

MB_SETFOREGROUND The message box becomes the foreground window.


0x00010000L Internally, the system calls the SetForegroundWindow
function for the message box.

MB_TOPMOST The message box is created with the WS_EX_TOPMOST


0x00040000L window style.

MB_SERVICE_NOTIFICATION The caller is a service notifying the user of an event. The


0x00200000L function displays a message box on the current active
desktop, even if there is no user logged on to the
computer.
Terminal Services: If the calling thread has an
impersonation token, the function directs the message
box to the session specified in the impersonation token.

If this flag is set, the hWnd parameter must be NULL. This


is so that the message box can appear on a desktop
other than the desktop corresponding to the hWnd.

For information on security considerations in regard to


using this flag, see Interactive Services. In particular, be
aware that this flag can produce interactive content on a
locked desktop and should therefore be used for only a
very limited set of scenarios, such as resource exhaustion.

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.

Return code/value Description

IDABORT The Abort button was selected.


3

IDCANCEL The Cancel button was selected.


2

IDCONTINUE The Continue button was selected.


11

IDIGNORE The Ignore button was selected.


5

IDNO The No button was selected.


7
IDOK The OK button was selected.
1

IDRETRY The Retry button was selected.


4

IDTRYAGAIN The Try Again button was selected.


10

IDYES The Yes button was selected.


6

Remarks
The following system icons can be used in a message box by setting the uType
parameter to the corresponding flag value.

Icon Flag values

MB_ICONHAND, MB_ICONSTOP, or MB_ICONERROR

MB_ICONQUESTION

MB_ICONEXCLAMATION or MB_ICONWARNING

MB_ICONASTERISK or MB_ICONINFORMATION

Adding two right-to-left marks (RLMs), represented by Unicode formatting character


U+200F, in the beginning of a MessageBox display string is interpreted by the
MessageBox rendering engine so as to cause the reading order of the MessageBox to
be rendered as right-to-left (RTL).

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:

For another message box example, see Displaying a Message Box.


Requirements

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

FlashWindow

MessageBeep

MessageBoxEx

MessageBoxIndirect

Other Resources

Reference

SetForegroundWindow

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MessageBoxA function (winuser.h)
Article02/09/2023

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.

[in, optional] lpText

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.

[in, optional] lpCaption

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_ABORTRETRYIGNORE The message box contains three push buttons: Abort,


0x00000002L Retry, and Ignore.

MB_CANCELTRYCONTINUE The message box contains three push buttons: Cancel,


0x00000006L Try Again, Continue. Use this message box type instead
of MB_ABORTRETRYIGNORE.

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_OKCANCEL The message box contains two push buttons: OK and


0x00000001L Cancel.

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

MB_ICONEXCLAMATION An exclamation-point icon appears in the message box.


0x00000030L

MB_ICONWARNING An exclamation-point icon appears in the message box.


0x00000030L

MB_ICONINFORMATION An icon consisting of a lowercase letter i in a circle


0x00000040L appears in the message box.

MB_ICONASTERISK An icon consisting of a lowercase letter i in a circle


0x00000040L appears in the message box.
MB_ICONQUESTION A question-mark icon appears in the message box. The
0x00000020L question-mark message icon is no longer recommended
because it does not clearly represent a specific type of
message and because the phrasing of a message as a
question could apply to any message type. In addition,
users can confuse the message symbol question mark
with Help information. Therefore, do not use this
question mark message symbol in your message boxes.
The system continues to support its inclusion only for
backward compatibility.

MB_ICONSTOP A stop-sign icon appears in the message box.


0x00000010L

MB_ICONERROR A stop-sign icon appears in the message box.


0x00000010L

MB_ICONHAND A stop-sign icon appears in the message box.


0x00000010L

To indicate the default button, specify one of the following values.

Value Meaning

MB_DEFBUTTON1 The first button is the default button.


0x00000000L MB_DEFBUTTON1 is the default unless
MB_DEFBUTTON2, MB_DEFBUTTON3, or
MB_DEFBUTTON4 is specified.

MB_DEFBUTTON2 The second button is the default button.


0x00000100L

MB_DEFBUTTON3 The third button is the default button.


0x00000200L

MB_DEFBUTTON4 The fourth button is the default button.


0x00000300L

To indicate the modality of the dialog box, specify one of the following values.

Value Meaning

MB_APPLMODAL The user must respond to the message box before


0x00000000L continuing work in the window identified by the hWnd
parameter. However, the user can move to the windows
of other threads and work in those windows.
Depending on the hierarchy of windows in the
application, the user may be able to move to other
windows within the thread. All child windows of the
parent of the message box are automatically disabled,
but pop-up windows are not.

MB_APPLMODAL is the default if neither


MB_SYSTEMMODAL nor MB_TASKMODAL is specified.

MB_SYSTEMMODAL Same as MB_APPLMODAL except that the message box


0x00001000L has the WS_EX_TOPMOST style. Use system-modal
message boxes to notify the user of serious, potentially
damaging errors that require immediate attention (for
example, running out of memory). This flag has no effect
on the user's ability to interact with windows other than
those associated with hWnd.

MB_TASKMODAL Same as MB_APPLMODAL except that all the top-level


0x00002000L windows belonging to the current thread are disabled if
the hWnd parameter is NULL. Use this flag when the
calling application or library does not have a window
handle available but still needs to prevent input to other
windows in the calling thread without suspending other
threads.

To specify other options, use one or more of the following values.

Value Meaning

MB_DEFAULT_DESKTOP_ONLY Same as desktop of the interactive window station. For


0x00020000L more information, see Window Stations.

If the current input desktop is not the default desktop,


MessageBox does not return until the user switches to
the default desktop.

MB_RIGHT The text is right-justified.


0x00080000L

MB_RTLREADING Displays message and caption text using right-to-left


0x00100000L reading order on Hebrew and Arabic systems.

MB_SETFOREGROUND The message box becomes the foreground window.


0x00010000L Internally, the system calls the SetForegroundWindow
function for the message box.

MB_TOPMOST The message box is created with the WS_EX_TOPMOST


0x00040000L window style.

MB_SERVICE_NOTIFICATION The caller is a service notifying the user of an event. The


0x00200000L function displays a message box on the current active
desktop, even if there is no user logged on to the
computer.
Terminal Services: If the calling thread has an
impersonation token, the function directs the message
box to the session specified in the impersonation token.

If this flag is set, the hWnd parameter must be NULL. This


is so that the message box can appear on a desktop
other than the desktop corresponding to the hWnd.

For information on security considerations in regard to


using this flag, see Interactive Services. In particular, be
aware that this flag can produce interactive content on a
locked desktop and should therefore be used for only a
very limited set of scenarios, such as resource exhaustion.

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.

Return code/value Description

IDABORT The Abort button was selected.


3

IDCANCEL The Cancel button was selected.


2

IDCONTINUE The Continue button was selected.


11

IDIGNORE The Ignore button was selected.


5

IDNO The No button was selected.


7
IDOK The OK button was selected.
1

IDRETRY The Retry button was selected.


4

IDTRYAGAIN The Try Again button was selected.


10

IDYES The Yes button was selected.


6

Remarks
The following system icons can be used in a message box by setting the uType
parameter to the corresponding flag value.

Icon Flag values

MB_ICONHAND, MB_ICONSTOP, or MB_ICONERROR

MB_ICONQUESTION

MB_ICONEXCLAMATION or MB_ICONWARNING

MB_ICONASTERISK or MB_ICONINFORMATION

Adding two right-to-left marks (RLMs), represented by Unicode formatting character


U+200F, in the beginning of a MessageBox display string is interpreted by the
MessageBox rendering engine so as to cause the reading order of the MessageBox to
be rendered as right-to-left (RTL).

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:

For another message box example, see Displaying a Message Box.


7 Note

The winuser.h header defines MessageBox 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

FlashWindow

MessageBeep

MessageBoxEx

MessageBoxIndirect

Other Resources

Reference

SetForegroundWindow
Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MessageBoxExA function (winuser.h)
Article02/09/2023

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.

Currently MessageBoxEx and MessageBox work the same way.

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.

[in, optional] lpText

Type: LPCTSTR

The message to be displayed.

[in, optional] lpCaption

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.

Return code/value Description

IDABORT The Abort button was selected.


3

IDCANCEL The Cancel button was selected.


2

IDCONTINUE The Continue button was selected.


11

IDIGNORE The Ignore button was selected.


5

IDNO The No button was selected.


7
IDOK The OK button was selected.
1

IDRETRY The Retry button was selected.


4

IDTRYAGAIN The Try Again button was selected.


10

IDYES The Yes button was selected.


6

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

The winuser.h header defines MessageBoxEx 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


MessageBoxExW function (winuser.h)
Article02/09/2023

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.

Currently MessageBoxEx and MessageBox work the same way.

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.

[in, optional] lpText

Type: LPCTSTR

The message to be displayed.

[in, optional] lpCaption

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.

Return code/value Description

IDABORT The Abort button was selected.


3

IDCANCEL The Cancel button was selected.


2

IDCONTINUE The Continue button was selected.


11

IDIGNORE The Ignore button was selected.


5

IDNO The No button was selected.


7
IDOK The OK button was selected.
1

IDRETRY The Retry button was selected.


4

IDTRYAGAIN The Try Again button was selected.


10

IDYES The Yes button was selected.


6

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

The winuser.h header defines MessageBoxEx 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

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

Get help at Microsoft Q&A


MessageBoxIndirectA function
(winuser.h)
Article02/09/2023

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

Type: const LPMSGBOXPARAMS

A pointer to a MSGBOXPARAMS structure that contains information used to display the


message box.

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.

Return code/value Description

IDABORT The Abort button was selected.


3
IDCANCEL The Cancel button was selected.
2

IDCONTINUE The Continue button was selected.


11

IDIGNORE The Ignore button was selected.


5

IDNO The No button was selected.


7

IDOK The OK button was selected.


1

IDRETRY The Retry button was selected.


4

IDTRYAGAIN The Try Again button was selected.


10

IDYES The Yes button was selected.


6

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

The winuser.h header defines MessageBoxIndirect 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

MSGBOXPARAMS

MessageBox

MessageBoxEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MessageBoxIndirectW function
(winuser.h)
Article02/09/2023

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

Type: const LPMSGBOXPARAMS

A pointer to a MSGBOXPARAMS structure that contains information used to display the


message box.

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.

Return code/value Description

IDABORT The Abort button was selected.


3
IDCANCEL The Cancel button was selected.
2

IDCONTINUE The Continue button was selected.


11

IDIGNORE The Ignore button was selected.


5

IDNO The No button was selected.


7

IDOK The OK button was selected.


1

IDRETRY The Retry button was selected.


4

IDTRYAGAIN The Try Again button was selected.


10

IDYES The Yes button was selected.


6

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

The winuser.h header defines MessageBoxIndirect 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

MSGBOXPARAMS

MessageBox

MessageBoxEx

Reference

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MessageBoxW function (winuser.h)
Article02/09/2023

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.

[in, optional] lpText

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.

[in, optional] lpCaption

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_ABORTRETRYIGNORE The message box contains three push buttons: Abort,


0x00000002L Retry, and Ignore.

MB_CANCELTRYCONTINUE The message box contains three push buttons: Cancel,


0x00000006L Try Again, Continue. Use this message box type instead
of MB_ABORTRETRYIGNORE.

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_OKCANCEL The message box contains two push buttons: OK and


0x00000001L Cancel.

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

MB_ICONEXCLAMATION An exclamation-point icon appears in the message box.


0x00000030L

MB_ICONWARNING An exclamation-point icon appears in the message box.


0x00000030L

MB_ICONINFORMATION An icon consisting of a lowercase letter i in a circle


0x00000040L appears in the message box.

MB_ICONASTERISK An icon consisting of a lowercase letter i in a circle


0x00000040L appears in the message box.
MB_ICONQUESTION A question-mark icon appears in the message box. The
0x00000020L question-mark message icon is no longer recommended
because it does not clearly represent a specific type of
message and because the phrasing of a message as a
question could apply to any message type. In addition,
users can confuse the message symbol question mark
with Help information. Therefore, do not use this
question mark message symbol in your message boxes.
The system continues to support its inclusion only for
backward compatibility.

MB_ICONSTOP A stop-sign icon appears in the message box.


0x00000010L

MB_ICONERROR A stop-sign icon appears in the message box.


0x00000010L

MB_ICONHAND A stop-sign icon appears in the message box.


0x00000010L

To indicate the default button, specify one of the following values.

Value Meaning

MB_DEFBUTTON1 The first button is the default button.


0x00000000L MB_DEFBUTTON1 is the default unless
MB_DEFBUTTON2, MB_DEFBUTTON3, or
MB_DEFBUTTON4 is specified.

MB_DEFBUTTON2 The second button is the default button.


0x00000100L

MB_DEFBUTTON3 The third button is the default button.


0x00000200L

MB_DEFBUTTON4 The fourth button is the default button.


0x00000300L

To indicate the modality of the dialog box, specify one of the following values.

Value Meaning

MB_APPLMODAL The user must respond to the message box before


0x00000000L continuing work in the window identified by the hWnd
parameter. However, the user can move to the windows
of other threads and work in those windows.
Depending on the hierarchy of windows in the
application, the user may be able to move to other
windows within the thread. All child windows of the
parent of the message box are automatically disabled,
but pop-up windows are not.

MB_APPLMODAL is the default if neither


MB_SYSTEMMODAL nor MB_TASKMODAL is specified.

MB_SYSTEMMODAL Same as MB_APPLMODAL except that the message box


0x00001000L has the WS_EX_TOPMOST style. Use system-modal
message boxes to notify the user of serious, potentially
damaging errors that require immediate attention (for
example, running out of memory). This flag has no effect
on the user's ability to interact with windows other than
those associated with hWnd.

MB_TASKMODAL Same as MB_APPLMODAL except that all the top-level


0x00002000L windows belonging to the current thread are disabled if
the hWnd parameter is NULL. Use this flag when the
calling application or library does not have a window
handle available but still needs to prevent input to other
windows in the calling thread without suspending other
threads.

To specify other options, use one or more of the following values.

Value Meaning

MB_DEFAULT_DESKTOP_ONLY Same as desktop of the interactive window station. For


0x00020000L more information, see Window Stations.

If the current input desktop is not the default desktop,


MessageBox does not return until the user switches to
the default desktop.

MB_RIGHT The text is right-justified.


0x00080000L

MB_RTLREADING Displays message and caption text using right-to-left


0x00100000L reading order on Hebrew and Arabic systems.

MB_SETFOREGROUND The message box becomes the foreground window.


0x00010000L Internally, the system calls the SetForegroundWindow
function for the message box.

MB_TOPMOST The message box is created with the WS_EX_TOPMOST


0x00040000L window style.

MB_SERVICE_NOTIFICATION The caller is a service notifying the user of an event. The


0x00200000L function displays a message box on the current active
desktop, even if there is no user logged on to the
computer.
Terminal Services: If the calling thread has an
impersonation token, the function directs the message
box to the session specified in the impersonation token.

If this flag is set, the hWnd parameter must be NULL. This


is so that the message box can appear on a desktop
other than the desktop corresponding to the hWnd.

For information on security considerations in regard to


using this flag, see Interactive Services. In particular, be
aware that this flag can produce interactive content on a
locked desktop and should therefore be used for only a
very limited set of scenarios, such as resource exhaustion.

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.

Return code/value Description

IDABORT The Abort button was selected.


3

IDCANCEL The Cancel button was selected.


2

IDCONTINUE The Continue button was selected.


11

IDIGNORE The Ignore button was selected.


5

IDNO The No button was selected.


7
IDOK The OK button was selected.
1

IDRETRY The Retry button was selected.


4

IDTRYAGAIN The Try Again button was selected.


10

IDYES The Yes button was selected.


6

Remarks
The following system icons can be used in a message box by setting the uType
parameter to the corresponding flag value.

Icon Flag values

MB_ICONHAND, MB_ICONSTOP, or MB_ICONERROR

MB_ICONQUESTION

MB_ICONEXCLAMATION or MB_ICONWARNING

MB_ICONASTERISK or MB_ICONINFORMATION

Adding two right-to-left marks (RLMs), represented by Unicode formatting character


U+200F, in the beginning of a MessageBox display string is interpreted by the
MessageBox rendering engine so as to cause the reading order of the MessageBox to
be rendered as right-to-left (RTL).

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:

For another message box example, see Displaying a Message Box.


7 Note

The winuser.h header defines MessageBox 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

FlashWindow

MessageBeep

MessageBoxEx

MessageBoxIndirect

Other Resources

Reference

SetForegroundWindow
Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MSGBOXCALLBACK callback function
(winuser.h)
Article05/03/2021

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

Minimum supported client Windows 2000 Professional [desktop apps only]

Minimum supported server Windows 2000 Server [desktop apps only]


Header winuser.h (include windows.h)

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MSGBOXPARAMSA structure (winuser.h)
Article07/27/2022

Contains information used to display a message box. The MessageBoxIndirect function


uses this structure.

Syntax
C++

typedef struct tagMSGBOXPARAMSA {


UINT cbSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCSTR lpszText;
LPCSTR lpszCaption;
DWORD dwStyle;
LPCSTR lpszIcon;
DWORD_PTR dwContextHelpId;
MSGBOXCALLBACK lpfnMsgBoxCallback;
DWORD dwLanguageId;
} MSGBOXPARAMSA, *PMSGBOXPARAMSA, *LPMSGBOXPARAMSA;

Members
cbSize

Type: UINT

The structure size, in bytes.

hwndOwner

Type: HWND

A handle to the owner window. This member can be NULL.

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

Identifies an icon resource. This parameter can be either a null-terminated string or an


integer resource identifier passed to the MAKEINTRESOURCE macro.

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:

VOID CALLBACK MsgBoxCallback(LPHELPINFO lpHelpInfo);

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

The winuser.h header defines MSGBOXPARAMS 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Header winuser.h (include Windows.h)


See also
Conceptual

Dialog Boxes

HELPINFO

LoadIcon

MAKEINTRESOURCE

MAKELANGID

MessageBoxEx

MessageBoxIndirect

Other Resources

Reference

WM_HELP

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


MSGBOXPARAMSW structure
(winuser.h)
Article07/27/2022

Contains information used to display a message box. The MessageBoxIndirect function


uses this structure.

Syntax
C++

typedef struct tagMSGBOXPARAMSW {


UINT cbSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCWSTR lpszText;
LPCWSTR lpszCaption;
DWORD dwStyle;
LPCWSTR lpszIcon;
DWORD_PTR dwContextHelpId;
MSGBOXCALLBACK lpfnMsgBoxCallback;
DWORD dwLanguageId;
} MSGBOXPARAMSW, *PMSGBOXPARAMSW, *LPMSGBOXPARAMSW;

Members
cbSize

Type: UINT

The structure size, in bytes.

hwndOwner

Type: HWND

A handle to the owner window. This member can be NULL.

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

Identifies an icon resource. This parameter can be either a null-terminated string or an


integer resource identifier passed to the MAKEINTRESOURCE macro.

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:

VOID CALLBACK MsgBoxCallback(LPHELPINFO lpHelpInfo);

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

The winuser.h header defines MSGBOXPARAMS 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]


Minimum supported server Windows 2000 Server [desktop apps only]

Header winuser.h (include Windows.h)

See also
Conceptual

Dialog Boxes

HELPINFO

LoadIcon

MAKEINTRESOURCE

MAKELANGID

MessageBoxEx

MessageBoxIndirect

Other Resources

Reference

WM_HELP

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


SendDlgItemMessageA function
(winuser.h)
Article02/09/2023

Sends a message to the specified control in a dialog box.

Syntax
C++

LRESULT SendDlgItemMessageA(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] UINT Msg,
[in] WPARAM wParam,
[in] LPARAM lParam
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The identifier of the control that receives the message.

[in] Msg

Type: UINT

The message to be sent.

For lists of the system-provided messages, see System-Defined Messages.

[in] wParam

Type: WPARAM
Additional message-specific information.

[in] lParam

Type: LPARAM

Additional message-specific information.

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.

Using SendDlgItemMessage is identical to retrieving a handle to the specified control


and calling the SendMessage function.

Examples
For an example, see Creating a Modeless Dialog Box.

7 Note

The winuser.h header defines SendDlgItemMessage 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]


Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

Reference

SendMessage

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


SendDlgItemMessageW function
(winuser.h)
Article02/09/2023

Sends a message to the specified control in a dialog box.

Syntax
C++

LRESULT SendDlgItemMessageW(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] UINT Msg,
[in] WPARAM wParam,
[in] LPARAM lParam
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The identifier of the control that receives the message.

[in] Msg

Type: UINT

The message to be sent.

For lists of the system-provided messages, see System-Defined Messages.

[in] wParam

Type: WPARAM
Additional message-specific information.

[in] lParam

Type: LPARAM

Additional message-specific information.

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.

Using SendDlgItemMessage is identical to retrieving a handle to the specified control


and calling the SendMessage function.

Examples
For an example, see Creating a Modeless Dialog Box.

7 Note

The winuser.h header defines SendDlgItemMessage 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]


Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

Reference

SendMessage

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


SetDlgItemInt function (winuser.h)
Article10/13/2021

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

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The control to be changed.

[in] uValue

Type: UINT

The integer value used to generate the item text.

[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 succeeds, the return value is nonzero.

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

Minimum supported Windows 2000 Professional [desktop apps only]


client

Minimum supported Windows 2000 Server [desktop apps only]


server

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-2 (introduced in Windows 10,


version 10.0.10240)

See also
Conceptual

Dialog Boxes

GetDlgItemInt

Reference

SetDlgItemText
WM_SETTEXT

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


SetDlgItemTextA function (winuser.h)
Article02/09/2023

Sets the title or text of a control in a dialog box.

Syntax
C++

BOOL SetDlgItemTextA(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] LPCSTR lpString
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The control with a title or text to be set.

[in] lpString

Type: LPCTSTR

The text to be copied to the control.

Return value
Type: BOOL

If the function succeeds, the return value is nonzero.

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

For an example, see Using List Boxes.

7 Note

The winuser.h header defines SetDlgItemText 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

GetDlgItemInt

GetDlgItemText
Reference

SetDlgItemInt

WM_SETTEXT

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A


SetDlgItemTextW function (winuser.h)
Article02/09/2023

Sets the title or text of a control in a dialog box.

Syntax
C++

BOOL SetDlgItemTextW(
[in] HWND hDlg,
[in] int nIDDlgItem,
[in] LPCWSTR lpString
);

Parameters
[in] hDlg

Type: HWND

A handle to the dialog box that contains the control.

[in] nIDDlgItem

Type: int

The control with a title or text to be set.

[in] lpString

Type: LPCTSTR

The text to be copied to the control.

Return value
Type: BOOL

If the function succeeds, the return value is nonzero.

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

For an example, see Using List Boxes.

7 Note

The winuser.h header defines SetDlgItemText 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]

Minimum supported server Windows 2000 Server [desktop apps only]

Target Platform Windows

Header winuser.h (include Windows.h)

Library User32.lib

DLL User32.dll

API set ext-ms-win-ntuser-dialogbox-l1-1-0 (introduced in Windows 8)

See also
Conceptual

Dialog Boxes

GetDlgItemInt

GetDlgItemText
Reference

SetDlgItemInt

WM_SETTEXT

Feedback
Was this page helpful? ツ Yes ト No

Get help at Microsoft Q&A

You might also like