How to Assign an Icon to a Window

In the .RC file, you must assign an icon to the same resource ID that the dialog window is using in the .DLG file, and then load it when you create the window. This is done as follows:

In your .H file, you would have:

#define MY_DIALOG_RCID 0x1000 In your .RC file, you would have: ICON MY_DIALOG_RCID myicon.ico In your .DLG file, you would have: DLGTEMPLATE MY_DIALOG_RCID PRELOAD MOVEABLE DISCARDABLE BEGIN DIALOG "My Dialog Title", MY_DIALOG_RCID, ... In your .CPP file, you would have: IFrameWindow *myDlg = new IFrameWindow( MY_DIALOG_RCID ); // create the window myDlg->setIcon( MY_DIALOG_RCID ); // set the icon
Note:
See also How to Prevent the Minimized Icon From Being Overwritten

[Home] [Index]
Page generated by Stéphane Charette on 1997 November 02
Open Class Library (OCL) FAQ © Stéphane Charette, 1997