MFC - Replacing default application icon - mfc

I have a MFC Dialog Application. I would like to replace the application exe icon.
I open the default MFC icon eg. app.ico in the res folder using Axialis IconWorkshop.
Replace all images in the icon.
Save it to appA.ico.
Then I change Filename property of icon IDR_MAINFRAME to res\appA.ico.
Visual Studio icon editor shows the correct image.
But when I build the application, the icon associated to the app.exe still show MFC default icon.
What went wrong?

In these cases the Visual Studio designer is a little buggy (or, otherwise, by design but incomprehensible). It's best to edit the .rc code file and change the icon filename there.

I think I recall that it is the first icon in the .RC file that is used, no matter what you do, so you might have to edit the .RC file directly, like djeidot says.

Sometimes, Windows caches icons. It may not be a problem with your application. Try downloading something like Resource Hacker
and look at your exe file. If the icon looks right, there is an IconCache.db or similar in your appdata\Local folder (depending on Windows version). Delete that and reload Explorer.

One of the Visual Studio files caches some resources; unfortunately I can't remember which one at the moment. Rename those files with odd extensions to something else and try a rebuild.

I have same problem and solve it by this solution:
Build\Clean Solution
Copy appA.ico again into res folder
Rebuild project

I have same problem and solve it by :
1.clear solution
2.open task manager and goto details tab.
3.search for explorer.exe and right click on it and end task.
4.goto File->run new task, type explorer.exe
5.now build the solution and check application icon.

Related

Visual Studio 2015 doesn't open saved projects

I'm just starting off with VS (2015 version) (C++ in general) and, knowing my luck, I immediately stumble upon an issue: VS 2015 doesn't open saved projects. I believe that it loads them up but doesn't bother to view them. I can't really describe it in words so I'll post a GIF. Any and all help would be appreciated.
A more detailed GIF
On the right side of your screen there should be a vertical tab called "Solution Explorer".
Clicking on it reveals your solution, its projects, and all the files associated with it. From there you should be able to find the files.
If you still can't find the files, it is likely that you didn't include them. You can add them to a directory in "Solution Explorer" by Right-clicking -> Add -> New Item -> C++ File
This happens when you close every tab in your project, and because VS saves the state of your tabs, when you reopen the project, they are all closed.
Also note that by default, when creating a whole new project, there are no files to open, so the screen will also be empty.
You can also use the shortcut key to show the solution explorer. Ctrl-Alt-L by default I believe.

Select File or Folder in MFC VS2010

I have converted a MFC application which was run on VS2005 to VS2010
In there I've functionality to select either a file or folder from CSelectDialog and it worked fine.
But when I convert the project into VS2010 now I can select files only.
How can I get rid of that? I couldn't find any libraries that I can use for this.
Simply I want to select either a file or folder using MFC in VS2010
Don't consider this as a duplication of
https://stackoverflow.com/questions/15852106/how-to-use-open-file-dialog-to-select-either-a-file-or-a-folder-in-vc-mfc
or
How do you configure an OpenFileDialog to select folders?
Because those answers are not applicable to this.
The source has a lot of assumptions about the types and ids of child controls on the file dialog. And the assumptions are broken if the file dialog upgraded to vista style. You can use the bVistaStyle parameter in the constructor to disable the automatic upgrade.
SHBrowseForFolder with BIF_BROWSEINCLUDEFILES is the only documented way I know of to choose file and folder at once. You can also consider supporting Shell Data Transfer between Windows Explorer and your program (e.g. drag/drop, copy/paste).
It looks like you're using some code from CodeProject that may not be compatible with 2010. You should use the standard CFileDialog to avoid any compatibility issues.

How to specify the icon to be displayed by the shell in my application

I have a standard MFC application with its own icon, and when viewing the application file through explorer, the icon displays fine. I have to add a library however that also includes icons for its various windows, and when I do add it to the project, Windows Explorer displays one of these icons instead of mine. Is there any way to force explorer displaying a specific icon?
Thanks
Windows displays the first icon in the resource for the program itself, so you just need to make sure that your icon is listed first.

Adding icon to .exe

Hi people I been trying to do this the whole night, can somebody help me/guide me on this.
Details:
Not Visual Studio (using Geany).
I'm using A lightweight IDE, and projects option is not available.
Is for the .exe file output.
Please give me some guidance on this.
I use Resource Hacker for such tasks. This will add an existing icon to an EXE; you'll need another tool to make the actual icon.
I am guessing you are using Visual Studio since you are talking about Windows.
First go to "Resource View" (from menu: View → Other Window → Resource View). Then in "Resource View" navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon.
Recompile your project and see if change takes effect.
Second way:
Use preprocessor directives in your resource script to choose your icon file.
You need to use the resource compiler rc.exe. You will also need to create a .rc file listing the resource (your icon). On compilation with rc.exe, you will get a .res file which should be passed to the linker.

How to assign an icon to an executable on windows (or visual studio) [duplicate]

This question already has answers here:
How do I set the icon for my application in visual studio 2008?
(6 answers)
Closed 9 years ago.
I would like to use a custom icon (a .ico file) for an executable, on windows (XP).
The executable is a C++ program created thanks to visual studio (2008).
How can I change the icon from the executable, to the .ico file I want?
Has mentioned in the comment, it is a duplicate question
Here is a copy paste of the answer from Jason Stevenson:
First go to Resource View (from menu: View --> Other Window --> Resource View). Then in Resource View navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon.
Use the embedded image editor in order to edit the existing or new icon. Note that an icon can include several types (sizes), selected from Image menu.
Then compile your project and see the effect.
You can use a program such as Resource Hacker to edit resources (including icons) of Windows executables.
Assuming you have a "resource.h" and a ".rc"-file ,you define a identifier in "resource.h" (lets call it IDI_MY_ICON) and then add a line in the icon-section of your rc-file like IDI_MY_ICON ICON "myicon.ico" as the first icon (thus this line must preceed any other ICON lines). Rebuild ,that's it.
In C# projects you right clink on project that creates .exe file, select Properties and on the first screen you can set icon. Not sure if this works for C++ but the properties panel is the place that you should look in.
You should be able find it at the 'Properties' of your project. (By rightclicking your project name). It's on the Application Tab, at least, in Visual Studio 2008 working in C# it is, and scrolling down there a bit.