-
January 16th, 2018, 11:07 AM
#1
[RESOLVED] win32 - WNDCLASSEX: how we change the window icon?
for we create a window, we must, first, create a register a class:
Code:
string strWindowClassName = "WindowClassname"; WNDCLASSEX wndClassName;
ZeroMemory(&wndClassName, sizeof(WNDCLASSEX));
wndClassName.cbSize = sizeof(WNDCLASSEX);
wndClassName.cbClsExtra = 0;
wndClassName.cbWndExtra = 0;
wndClassName.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wndClassName.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClassName.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wndClassName.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
wndClassName.hInstance = GetModuleHandle(NULL);
wndClassName.lpfnWndProc = (WNDPROC)WndProc;
wndClassName.lpszClassName = strWindowClassName.c_str();
wndClassName.lpszMenuName = 0;
wndClassName.style = CS_HREDRAW | CS_VREDRAW;
if (!RegisterClassEx(&wndClassName))
MessageBox(NULL, "Not Registed", "error", MB_OK);
until here, it's normal...
now i need to show you just WNDCLASSEX 2 members:
Code:
wndClassName.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wndClassName.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
these 2 members are for change the window icon(hIconSm) and on windows toolbar icon(hIcon). these 2 members must be the same(tested).
i have 1 question about IDI consts. i can use IDI_QUESTION, but not the IDI_WINLOGO... why? it's because of the icon resolution?
-
January 16th, 2018, 11:30 AM
#2
Re: win32 - WNDCLASSEX: how we change the window icon?
Not sure I'm understanding the question. LoadIcon() can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values.
See remarks section in https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
January 16th, 2018, 02:09 PM
#3
Re: win32 - WNDCLASSEX: how we change the window icon?
![Quote](images/misc/quote_icon.png) Originally Posted by Cambalinho
... i can use IDI_QUESTION, but not the IDI_WINLOGO... why? it's because of the icon resolution?
What exactly is your problem by using IDI_WINLOGO icon?
Victor Nijegorodov
-
January 16th, 2018, 06:20 PM
#4
Re: win32 - WNDCLASSEX: how we change the window icon?
"What exactly is your problem by using IDI_WINLOGO icon?"
now i get it the IDI_WINLOGO and IDI_APPLICATION are the same icon:
Value |
Meaning |
IDI_APPLICATIONMAKEINTRESOURCE(32512) |
Default application icon. |
IDI_ASTERISKMAKEINTRESOURCE(32516) |
Asterisk icon. Same as IDI_INFORMATION. |
IDI_ERRORMAKEINTRESOURCE(32513) |
Hand-shaped icon. |
IDI_EXCLAMATIONMAKEINTRESOURCE(32515) |
Exclamation point icon. Same as IDI_WARNING. |
IDI_HANDMAKEINTRESOURCE(32513) |
Hand-shaped icon. Same as IDI_ERROR. |
IDI_INFORMATIONMAKEINTRESOURCE(32516) |
Asterisk icon. |
IDI_QUESTIONMAKEINTRESOURCE(32514) |
Question mark icon. |
IDI_SHIELDMAKEINTRESOURCE(32518) |
Security Shield icon. |
IDI_WARNINGMAKEINTRESOURCE(32515) |
Exclamation point icon. |
IDI_WINLOGOMAKEINTRESOURCE(32517) |
Default application icon.
Windows 2000: Windows logo icon. |
i know that i can choose the icon by resource or file. i don't know all macros icons. but the result it's the same.
see these image:
![Name: Sem TÃ*tulo.png
Views: 1113
Size: 6.5 KB](https://forums.codeguru.com/attachment.php?s=e9a884d39f7e14ae3c70a558457a3448&attachmentid=35147&d=1516144673)
that icon, on image, is the default icon?
on MSDN i can't see the icons
-
January 17th, 2018, 02:57 AM
#5
Re: win32 - WNDCLASSEX: how we change the window icon?
![Quote](images/misc/quote_icon.png) Originally Posted by Cambalinho
... that icon, on image, is the default icon?
on MSDN i can't see the icons
Yes, it is a default one.
All these standard icons are stored in the User32.dll
Victor Nijegorodov
-
January 17th, 2018, 07:51 AM
#6
Re: win32 - WNDCLASSEX: how we change the window icon?
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
|