The information in this article applies to:
SUMMARY
The standard Windows dialog box does not have an icon when it is minimized.
A dialog box can be made to use an icon by replacing the standard dialog
box class with a private dialog box class.
MORE INFORMATION
The standard dialog box class specifies NULL as the value of the hIcon
field of its WNDCLASS structure. So no icon is drawn when the standard
dialog box is minimized.
An icon can be specified by getting the dialog to use a private class as
follows:
- Register a private class.
WNDCLASS wc;
wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW;
wc.lpfnWndProc = DefDlgProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = DLGWINDOWEXTRA;
wc.hInstance = hinst;
wc.hIcon = LoadIcon(hinst, "DialogIcon");
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = COLOR_WINDOW + 1;
wc.lpszMenuName = NULL;
wc.lpszClassName = "MyDlgClass";
RegisterClass(&wc);
NOTE: The default dialog window procedure, DefDlgProc(), is used as the
window procedure of the class. This causes windows of this class to
behave as standard dialogs. The cbWndExtra field has to be assigned to
DLGWINDOWEXTRA - the dialog box stores its internal state information in
these extra window bytes. The icon to be used when the dialog box is
minimized is assigned to the hIncon field.
- Get the dialog box to use the private class.
Use the CLASS statement in the dialog box template to get the dialog box
to use the private class:
IDD_MYDIALOG DIALOG 0, 0, 186, 92
CLASS "MyDlgClass"
:
- Create the dialog box using DialogBox() or CreateDialog().
DialogBox (hinst,
MAKEINTRESOURCE (IDD_MYDIALOG),
NULL,
(DLGPROC)MyDlgFunc);
MyDlgFunc() is the dialog function implemented by the application. When
the dialog box is minimized, it will use the icon specified in the
private class.
|