1

Is it possible to change an application icon directly from the program? it's a WPF windows application. I would like to let users change the application's icon from the program so next time they would see the previously selected icon in the launcher. I actually want the user can change the icon of the application. I write the below code in the formload event of the main form.

this.Icon = Properties.Resources.coins; 

but it just changes the form's icon. But I wanna change the program icon. How could this be done? I'm developing on VS 2019/WPF/ C#.

Neda
  • 119
  • 2
  • 12
  • Why do you want to change it? Where do you see what it's different than of main window? – Sinatr Jan 28 '20 at 08:01
  • I have more than one form in my software. Is it the best solution that I change the icon in formload event of every form? – Neda Jan 28 '20 at 08:10
  • To be honest, I'd like to change icons everywhere such as the shortcut on the desktop, start menu and all forms of my software.Also, I don't want these extra codes lead to reduce the speed of my program. But it seems impossible – Neda Jan 28 '20 at 08:14
  • You didn't answer why you want to *change* icon. Setting once custom icon make sense, but changing it dynamically? Why? If you have multiple windows, then you can define icon in one place and all windows have to use it. Changing dynamically shortcuts icon is completely exotic request. – Sinatr Jan 28 '20 at 08:21
  • *"I actually want the user can change the icon of the application"* - is this what you call dynamic? The easy solution is to require software restart, this way you will be able to load all windows with new icon. Instead of changing shortcut icons you can recreate them assigning a new icon. – Sinatr Jan 28 '20 at 08:31
  • @Sinatr Thanks for your reply. Actually this idea appeared for me when my boss sometimes tells me about the change of the application's icon. I have to build a setup again. If my program has this ability so I don't have to build the setup of the program again. – Neda Jan 28 '20 at 08:38
  • 1
    I not shore there is a simple way to do this. See [1](https://stackoverflow.com/questions/3971970/changing-external-exe-icon-at-runtime), [2](https://stackoverflow.com/questions/40479974/how-to-change-exe-icon-programmatically-in-c-sharp-net), [3](https://stackoverflow.com/questions/12059066/programmatically-change-the-program-icon) similar questions, it doesn't seem there is a simple way. There are free windows resource editors that can do this but i'ts not an automatic processes. – Eliahu Aaron Jan 28 '20 at 09:30
  • 1
    @Neda are you sure you aren't asking how to change the *shortcut icons* during setup? That's a setting you provide when you create those shortcuts. Applications have *multiple* icons already, often in multiple resolutions. Shortcuts contain not only the path to the executable but the icon to display as well – Panagiotis Kanavos Jan 28 '20 at 09:48
  • 2
    @Neda you should clarify what you want, not how you think it can be done. Creating shortcuts with different icons is done when you create the setup program. All installer generation programs offer setup properties that can be used to store the icon to use. Or you can add different icons during the build step. Or you can add a build step that sets the setup property – Panagiotis Kanavos Jan 28 '20 at 09:50
  • 1
    @Neda once the application is deployed, the taskbar icons can change appearance on Windows 7 and later to reflect eg progress or application status. That's not the same as changing the windows icon though. – Panagiotis Kanavos Jan 28 '20 at 09:52
  • 1
    Maybe this can guide you through it https://stackoverflow.com/a/53188029/3690982 – Katana Jan 30 '20 at 06:05

0 Answers0