In a MFC windows application, the right icon is shown in the taskbar if I run the .exe file created through a release/debug build. However it doesn't show and only loads windows default icon if the application gets installed on the machine.
What is the reason behind this latter behaviour?
Maybe your icon resources aren't available in all sizes? I.e. the 16 px is used for the task bar, but there is a default one for the bigger size that is used for the shortcut.
Related
This seems like a thing that should be quite simple to do, but for some reason I have problems even to google anything on the subject...
How do you add an icon to a console application in Visual Studio. Now, I know how this works with Win32 desktop applications - you have the resource file, and the icon with the lowest ID is simply used as the app's icon. But if I add a new resource file to a console application and even mess around with the icon editor - nothing happens. The target executable still has the same default icon. Is there some kind of difference between a console application and a desktop one regarding resources? Or do I need to also do set something else apart from just adding the resource file with an icon?
Thanks
It should work the same as with normal WinAPI application. In my case the problem was probably caused by windows icons caching. You can verify this is the case by moving the executable to another directory.
I need to set title.ico as my application icon and shortcut.ico as my desktop shortcut. Is there any way to do it in a Qt application itself while building?
Whenever the user right-clicks on my application and clicks on sendto->desktop(create shortcut), the shortcut should have shortcut.ico. But now it's always displaying title.ico.
I checked WinApi IShell_link but it didn't help.
I am also a beginner, but turns out this is possible. See this thread: https://forum.qt.io/topic/45324/taskbar-icon-different-from-the-icon-of-the-window/8
Hope I understood you right. Enjoy!
Edit 2018-03-13:
Create your icon in diffrent sizes (e.g. 16px, 32px, ...) as an .ico (while on Windows), for further information visit: http://doc.qt.io/qt-5/appicon.html
Call QWindow::setIcon() (http://doc.qt.io/qt-5/qwindow.html#setIcon)
Profit. The icon should now be visible in the greater resolution in the taskbar, while the smaller one is choosen for the app window.
I am trying to change the icon of the application, and I have changed it and the project builds completely fine.
But when the application starts, I still see the default icon on the taskbar. On the otherhand, when I click on About, I can see the new Icon.
What am I missing?
You need to make sure that the resource ID of your icon is the lowest of all the icons in your resources. Windows will display the icon with the lowest ID.
I've added an icon resource to my program. Unfortunately, it's a 16x16 icon meant as a visual aid on a button, and now it's set as the executable's main icon. Obviously, this looks terrible.
Is it possible to add a resource while retaining the EXE's icon as the Windows default?
I'm using Visual Studio 2010, if that helps.
It looks like your 16x16 icon is the only icon resource in your application, or the one with the smallest identifier. In that case, both Explorer (for its file lists) and the window manager (for the window's title bar) will default to that icon.
You should add another icon to your application, with an id less than the id of your 16x16 icon, so it will become the default icon. If you want to use the default application icon, you can get it from the Visual Studio Image Library.
You can do it manually. You can add an identifier in resource.h, rc file and then use it by calling required function with parameter MAKEINTRESOURCE(IDENTFIER) to make the cast from id to image.
One option would be to put your icons in a separate module, i.e. a DLL. This would stop the system using them for application icons and avoid the need to add your own copy of the default system application icon.
In C++, is there anyway to let the user chose the icon of the app? For example, Winamp lets you select which icon you wish to use from a list of icons in it's preferences. How is it done?
There is the icon that you see in explorer. This is a resource in your executable. You could change that, but I wouldn't advise you too. Virus scanners can get nervous if executables are modified, and in Windows Vista you will not even be allowed to write in the Program Files folder.
But the icon that is displayed on the task bar or in the system tray can be changed. This is actually the icon of your application window and it can be set by sending a WM_SETICON message.
And there are shortcuts. They can be changed too, and in a shortcut you can specify which icon should be used.
I found a discussion on changing icons that has information about the first two options.
For Visual Studio 2010 in an MFC dialog based app
A. In the resource view, rightclick Icon folder and add icon. Give it an ID like IDI_MYICON. Leave it as is or draw something nice.
B. Go to OnInitDialog. Add the following two lines of code:
HICON hMyIcon = LoadIcon( AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MYICON) );
SetIcon( hMyIcon, FALSE ); // FALSE == use as small icon
You can read about these functions in the help to understand what is happening.
This sets the icon as icon for the sysmenu (topleft) and in the taskbar. This is however not automatically reflected in all situations. E.g. for a systray icon you need to explicitly specify the icon again in the call to Shell_NotifyIcon().