È possibile utilizzare LoadImage
:
wcex.hIcon = (HICON) LoadImage(// returns a HANDLE so we have to cast to HICON
NULL, // hInstance must be NULL when loading from a file
"iconfile.ico", // the icon file name
IMAGE_ICON, // specifies that the file is an icon
0, // width of the image (we'll specify default later on)
0, // height of the image
LR_LOADFROMFILE| // we want to load a file (as opposed to a resource)
LR_DEFAULTSIZE| // default metrics based on the type (IMAGE_ICON, 32x32)
LR_SHARED // let the system release the handle when it's no longer used
);
Assicurarsi di entrambi i set wcex.hIconSm
(piccola icona) a NULL o caricare una piccola icona. Quando lo si imposta su NULL, utilizzerà automaticamente l'immagine specificata da hIcon. Quando si carica una piccola icona con LoadImage, è necessario impostare la larghezza e l'altezza a 16 e rimuovere il flag LR_DEFAULTSIZE. Se è un'icona progettata per avere parti trasparenti, aggiungi il flag LR_LOADTRANSPARENT
fonte
2012-11-02 00:57:04
Da [documentazione] (http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045.aspx): Non utilizzare LR_SHARED per le immagini che hanno dimensioni non standard, che possono cambiare dopo il caricamento, o che vengono caricati da un file. – Paul