Specifying a Class Icon

A “class icon” is an icon that represents a particular window class whenever a window in that class is minimized. You specify a class icon by supplying an icon handle in the hIcon field of the window-class structure before registering the class. Once the class icon is set, Windows automatically displays that icon when any window you create using that window class is minimized.

The following example shows a definition of the window class wc before registering the class. In this definition, the field hIcon is set to the handle returned by LoadIcon.

wc.style = NULL;

wc.lpfnWndProc = MainWndProc;

wc.cbClsExtra = 0;

wc.cbWndExtra = 0;

wc.hInstance = hInstance;

1 wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);

wc.hCursor = LoadCursor (NULL, IDC_ARROW);

wc.hbrBackground = COLOR_WINDOW + 1;

wc.lpszMenuName = NULL;

wc.lpszClassName = “Generic";

1 The LoadIcon function returns a handle to the built-in application icon identified by IDI_APPLICATION. If you minimize a window that has this class, you will see a white rectangle with a black border. This is the built-in application icon.