-
June 4th, 2019, 04:11 AM
#1
[RESOLVED] Changing the Small and Big icons of a window using LoadImage... How to?
So another question since I've hit another stumbling block...
Tried about 7 different guides and many different forum posts, none of which are working, I must be doing something obvious wrong...
Trying to change the 'small' icon (upper-left icon in a window) and the 'Big' icon (icon that appears in the taskbar) of a Window I've created with Win32.
I'm using LoadImage() and placing the result into an 'HICON' Handle. I'm not using LoadIcon().
Here's the relevant code:
Under WNDCLASSEX wc in WinMain:
Code:
WNDCLASSEX wc;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
and then, later, under a custom function I made that appears under WM_CREATE in WndProc function:
Code:
void LoadVisuals()
{
HICON hIconSm = (HICON)LoadImage(NULL, L"Icon.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
}
The icon doesn't change, it remains the same.
I run some error checking. The LoadImage() part reports Error Code 0 (function successful) but the SendMessage() part reports 'Error 1813: The specified resource type cannot be found in the image file.'
I have confirmed the .ico icon's file path and have tried specifying the FULL PATH ("C:\\files\\to\\icon.ico").
Can anyone explain what I'm doing wrong? Am I placing LoadVisuals() in the wrong part of WndProc? Am I casting LoadImage() to the wrong handle-type? Is wc.hIconSm overriding the SendMessage()?
Appreciate your help - I've checked lots of other forum posts but nothing has worked so far.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|