How load icon from resource using LoadImage?
Marcone
marcone at email.com
Sun Jan 5 22:02:54 UTC 2020
On Sunday, 5 January 2020 at 15:13:17 UTC, Rumbu wrote:
> On Sunday, 5 January 2020 at 13:33:35 UTC, Marcone wrote:
>> I am using this code to load icon from local directory, but I
>> want to load icon from resource.res file:
>>
>> wndclass.hIcon = LoadImage( NULL, "icon.ico", IMAGE_ICON, 0,
>> 0, LR_LOADFROMFILE| LR_SHARED | LR_LOADTRANSPARENT);
>
> You cannot load icons from res files.
>
> If you link your res file to the executable, you can load the
> icon using:
>
> LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(youriconid));
>
>
> The function LoadImage from above loads an icon from the file
> named icon.ico, not from a res file.
Very good! working using: LoadIcon(hInstance,
MAKEINTRESOURCE(youriconid)); becouse GetModuleHandle(NULL) is
undefined here.
More information about the Digitalmars-d-learn
mailing list