Help Center

CDialog.DialogNewPixelsmethod

Creates a modeless dialog in memory

WindowsmethodCDialog.incdocumented

Syntax

FUNCTION DialogNewPixels (BYVAL hParent AS HWND = HWND_DESKTOP, BYREF wszTitle AS WSTRING, BYVAL x AS LONG = -1, BYVAL y AS LONG = -1, BYVAL cx AS LONG = 0, BYVAL cy AS LONG = 0, BYVAL dwStyle AS LONG = 0, BYVAL dwExStyle AS LONG = 0) AS HWND
FUNCTION DialogNewPixels (BYREF wszClassName AS WSTRING, BYVAL hParent AS HWND = HWND_DESKTOP, BYREF wszTitle AS WSTRING = "", BYVAL x AS LONG = -1, BYVAL y AS LONG = -1, BYVAL cx AS LONG = 0, BYVAL cy AS LONG = 0, BYVAL dwStyle AS LONG = 0, BYVAL dwExStyle AS LONG = 0) AS HWND
Also documented as DialogNew — one description covers them all.

Parameters

NameDescription
wszClassNameThe class name.
hParentHandle of the parent window or dialog. If there is no parent, use zero (0) or HWND_DESKTOP. If the dialog is MODAL, the parent window/dialog will be disabled while this "child" dialog is running.
wszTitleThe text displayed in the title or caption bar of the dialog.
x*, *yOptional location of the top-left corner for the dialog. The location is specified in the same terms (pixels or dialog units) as specified in the DialogNew / DialogNewPixels functions. If neither x and y are specified, the dialog is centered on the screen. If CW_USEDEFAULT (&H080000000) is specified, the default Windows position is used (cascading from the upper-left corner).
cx*, *cyThe width and height of the dialog. The size is specified in the same terms (pixels or dialog units) as specified in the DialogNew / DialogNewPixels functions. If the default dialog style (or any other dialog style that includes the WS_CAPTION style) is used, the width and height parameters specify the client size only, and this does not include any caption and border dimensions.

Return value

The Windows window handle assigned by Windows. This handle should be used with subsequent Dialog and Control functions, and may be directly used with Windows API calls.

If the dialog could not be created (i.e., due to low Windows resources), NULL is returned.

Description

Creates a dialog in memory. A new empty dialog is created, but not yet displayed. Once the dialog has been created and all of the desired controls have been added with, the dialog can be displayed with the DialogShowModeless or DialogSHowModal functions.

If a modeless dialog is created, the application must create a DialogDoEvents message pump for the duration of the dialog. Failure to provide a message pump can result in disruptions to the display of the dialog, or the inability of the dialog to respond to messages such as button clicks, etc. Modal dialogs do not require a message pump.

To change the displayed state of a dialog (i.e., hidden, minimized, etc) after the dialog has been created, use the DialogShowState function.

If a dialog does not have either WS_CHILD or WS_POPUP styles, Windows may enforce a minimum dialog width of some 60-70 dialog units.

You can give to the dialog a class Name of your choice; otherwise, the predefined class #32770" is used.

The overloaded function DialogNewPixels uses pixels instead of dialog units.

If the style does not include WS_CAPTION, the width and height specify the overall dialog size, including the caption and border, if any. Note that WS_CAPTION is a combination of the WS_BORDER and WS_DLGFRAME styles. The default dialog style includes WS_BORDER and WS_DLGFRAME styles, so it implicitly includes the WS_CAPTION style. |

Reference

  • Include file CDialog.inc
  • Defined in AfxNova/CDialog.inc:993
  • Documented in Windows/Windows GUI/CDialog Class.md
  • Topic: CDialog Class