• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

How do I use SetDeviceWindowIcon()?

Phil7

Moderator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
886
Is there anything you should be aware when using this function. I tried it using a icon in the data folder and I couldn't see any effect. So some questions came up:
- Which icon is changed here? The Icon in the corner of the window or the app executable icon or the one in the taskbar?
- Does it work with Visual Studio and MinGW builds (Windows)?
- Is the path to be set absolute?
- Can you change the icon in runtime or is it just effecting the build process i.e. makefile/ icon.rc
 
I tried it using a icon in the data folder and I couldn't see any effect. So some questions came up:
It should have. Use a PNG file and place it inside the data folder. What you set with SetDeviceWindowIcon is the little image in the top left of a window and the icon on the taskbar:

Cerberus:
SetDeviceWindowIcon("icon.png")

614


Does it work with Visual Studio and MinGW builds (Windows)?
Yes, it does.

Is the path to be set absolute?
Nope, see the code example above.

Can you change the icon in runtime or is it just effecting the build process i.e. makefile/ icon.rc
This is a runtime change.

To change the icon of an exe, you need to modify the project files. Since the last release, with MingW you have to exchange the icon here:

615


You can name it differently, but then you have to change the reference in the resource.rc file.
On MSVC I still have to look into this, there it won't work like that.
Anyway, this method of changing the exe icon is temporary and subject to change.
 
Ok, I managed to add this icon into the resource of the MSVC project.

Copy the content of the attachment into the template/msvc folder of the GLFW target.
 

Attachments

  • CerberusGame.zip
    20.8 KB · Views: 186
Thank you!
So SetDeviceWindowIcon() is only useful, if I want to change the window icon during runtime.
At least with MinGW I can set all icons on windows by changing it with windres
 
I couldn't test msvc for now. But for minGW I think I found something:
1. Sometimes it was necessary to delete the 'build' folder inside 'glfw3/gcc_winnt' to trigger a new resource.o
2. There seems to be some kind of cache for the display of the exe icon. I don't know how to reset this , but the new Icon is displayed correctly after a system reboot.

3. Something else is the suggestion to change the content of resource.rc to
Cerberus:
id ICON "CerberusIcon.ico"
GLFW_ICON ICON "CerberusIcon.ico"

This way the icon is also displayed in the corner of the window and in the taskbar. I also changed the default name of the icon to CerberusIcon to make it speak a bit more, as per default file extensions are not shown on windows as far as I know.
 
Cerberus:
GLFW_ICON ICON "Cerberus.ico"
Thank Phil7, that works perfectly.
 
Back
Top Bottom