Microsoft KB Archive/114612

From BetaArchive Wiki

HOWTO: Get a Dialog to Use an Icon When Minimized

Q114612



The information in this article applies to:


  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows Software Development Kit (SDK) 3.1





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:


  1. 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.

  2. Get the dialog box to use the private class.
  3. 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.

Additional query words:

Keywords : kbDlg kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin
Issue type : kbhowto
Technology : kbWin32SDKSearch kbAudDeveloper kbWin3xSearch kbSDKSearch kbWin32sSearch kbWinSDKSearch kbWinSDK310


Last Reviewed: July 12, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.