The SetIcon method updates the large and/or small icons
associated with the host window created using the Create
or Create method. This is equivalent to sending
the WM_SETICON message to the host window, but automatically
handles both the large and small icons and supports DPI-aware sizing when
requested.
If the hRetInst parameter is not NULL, either a string resource
name (lpszIconName) or a numeric resource identifier (uResId)
can be specified to identify the icon. If both are provided, the string
resource name takes precedence. The resource must exist in the module instance
specified by hResInst. If neither lpszIconName nor uResId
resolves to a valid icon, the method fails.
if the hResInst parameter is NULL, the lpszIconName
parameter must specify the name of a file which contains the icon and
the uResId parameter is ignored. It is recommended that you
provide an absolute path to the icon file. If the path includes
environment variables surrounded with percent (%) symbols, those
variables will be automatically expanded. The file must use the
standard Windows icon format.
The dwFlags parameter determines which icons are updated. You can set
the large icon (used in the Alt-Tab interface and title bar), the small icon
(shown in the window caption and taskbar), or both. If WEBVIEW_ICON_DPI_AWARE
is specified, the system will choose an appropriate small icon size based on
the current display scaling.
Windows icons are stored in the standard .ico file format,
which can contain one or more images at different resolutions and color
depths. When you compile icons into your application's resources and reference
them by name or identifier, Windows will automatically select the most
appropriate image for the current display settings. This allows a single
icon resource to provide 16x16, 32x32, 48x48, or higher-resolution images
within the same file.
The operating system chooses which image to use based on context and DPI
scaling. For example, a 16x16 version may be displayed in a window caption or
taskbar, while a 32x32 or 48x48 version may be shown in the Alt-Tab interface
or Windows Explorer. If WEBVIEW_ICON_DPI_AWARE is specified, the
system can pick a small-icon size that best matches the current DPI rather
than always defaulting to 16x16.
Calling this method does not destroy the icon resource itself; ownership
remains with the module that loaded it. If you dynamically create icons at
runtime using CreateIcon or LoadImage, you are
responsible for releasing them with DestroyIcon if they are no
longer needed.
This method can only be used with windows created by this library, it
cannot be used with windows you attach the browser to using the
Attach method.