Changing the exe icon of VB6 project that uses a resource file - winapi

I need to change .exe icon for a VB6 project. I tried using the option generate .exe by selecting the form which loads first but this doesn't work as the previous exe icon comes from a resource file. I also tried adding the icon to the resource file, but VB 6 doesn't allow to add icons of more than 256 colours. Can anyone please help me on this?

Create a file named YOURAPP.RC containing the line
AAA ICON MOVEABLE PRELOAD YOURICON.ico
in the directory with the YOURICON.ico icon.
Then, compile to a resource file:
RC.EXE /v /r /fo YOURAPP.RES YOURAPP.RC
(C:\Program Files (x86)\Microsoft Visual Studio\VB98\Wizards\RC.EXE)
Finally, add the resulting YOURAPP.RES as a Resource to the VB6 project and recompile it.

Click on the Form your are working with then find the "Icon" entry in the properties page.
Then, go to project properties and in the second tab your icon will be set to your startup form's icon or whatever you choose.

Related

Godot: Rename application name used by file explorer in "open with" menu

I'm creating a media player using Godot. The application is already able to play .mp3 files by using the open with option in the file explorer. The name of the project is "Media player" and the executable is called "Media Player.exe" yet when presented in the open with menu it is displayed as "Godot Engine".
So my question: Is it possible to change this? If so, how?
Note: The option is only visible after first opening a .mp3 file by manually navigating to the executable. The .mp3 file is thus not opened with the Godot game engine but by an application made with it.
Here is an example.
In Godot, when you are exporting for Windows (with export templates installed, with a Window Desktop preset), on the "Options" tab, at the bottom you will find an "Application" section.
There you can find fields to set:
Icon
File Version
Product Version
Company Name
Product Name
File Description
Copyright
Trademarks
These match the fields you see in the properties of the exe.
In my tests I find I need to put the name I want in the Open With dialog in the "File Description" field.
But that would not work if you didn't configure rcedit. Download rcedit, then go to Menu Editor -> Editor Settings -> Export -> Windows -> Rcedit and set the path to where you downloaded it.
Godot will use rcedit to edit the exe (similar to using resourcehacker) to insert those values. If rcedit is not configured, Godot will skip the step silently.
By the way, Windows will copy "Company Name" and "File Description" fields to:
Equipo\HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache
There you will find two string values with a name that start with the path of your exe. One of the string value has a name that ends with ".ApplicationCompany" and has the value of the "Company Name" field. The other string value has a name that ends with ".FriendlyName" and has the the value of the value of the "File Description" field.
If you don't see these values update in the Open With dialog, it is because Windows is reading them from there.
You may also be interested in: Changing application icon for Windows.
Found the solution.
By editing the .exe file using resourcehacker you can adjust the file description and icon. By editing the product name will give the correct name.
Thanks to cybereality from the Godot forum to enlighten me on this solution.

Code Blocks(New project/Rename main file)

When I create a new project in code blocks File->New->project->console application->Go->C++-><project title>->GNU compiler->finish (both debug and release box are checked), Then a project is created having .cpp file with name of main.
My question is how to rename this main file.
Before asking this question I have tried to solve it, but it includes many steps.
I have tried two ways (one way gives me a solution, and the other way indicates that file has been corrupted).
Actually I want to find a quick way to rename this main file?
If there is any method please tell me.
Two methods which I used(mentioning below)
File->New->project->console application->Go->C++-><project title>->GNU compiler->finish
then go to local disc (where project is saved) rename main file. Open project again in code blocks. Open main file it says file does not exist.
This method was quick but failed to rename main.
File->New->project->console application->Go->C++-><project title>->GNU compiler->finish.
then in code blocks at left side bar Sources/main/right click on main/remove file from project (then code blocks indicate you have deleted this main file but actually its not when I checked in local disk, main file was there). Then I create a new.cpp` file as File/New/File and next simple steps.
So finally I got what I want. A new project with .cpp file (name of .cpp file that I want). But I'm not satisfied, I want a quick method.
As of Code::Blocks 13.12 you can rename a file within a project
like this: Say the file to be renamed is main.cpp in project
MyApp.
In the C::B Management pane navigate in the Projects tree-view to
Projects -> MyApp -> Sources -> main.cpp.
Right-click on the file-icon of main.cpp. A pop-up menu appears.
The third item on the menu is Rename file. You can take it from there
Capture your code in a text file.
Close code::blocks
In the folder containing the files, rename all *.cpp and *.h or whatever your using including the cbp file. Don't need to change the depend or layout. Delete the bin and debug folders.
Double click the cbp (project file).
Remove the old files (right mouse click remove).
Then right mouse click on the project and select "add files".
Choose your newly named files, build and run.
In Code::Blocks 16.01, assuming your project and files are open:
If you want to rename main.cpp then, in the Management window, Projects tab, navigate to the Sources folder of your project and right-click on main.cpp. In the context menu that appears, if you find Close main.cpp menu item — click it! otherwise click Rename file...
If you want to rename the title of your project, in the Management window, Projects tab, right-click on the title of your project. In the context menu that appears click Properties... to open the Project/targets options window, and type the new title of your project in the Title field. NOTE that this will not change the name of the project folder or the name of your project's .cbp file, because the title of your project is stored inside the .cbp file.
If you want to rename any file or folder in your project, first close the project using the File menu, then, in the Management window, Files tab, navigate to the desired file or folder, right-click on it and choose Rename.... Proceed with care. You might want to delete old .dependand .layout files that are no longer associated with your project.
In newer versions of CodeBlocks, simply close the file editor and right click on the file (at left tree) -> Rename File.

Visual Studio icon looks bad

I'm having trouble with my application icon looking bad after adding it into my project, building it, and creating a shortcut to it.
Here's what I've done:
1) I started with a 256x256 PNG file that looks great.
2) I used IcoFX to generate a .ICO file with all the recommended sizes.
3) I add the icon to my project as follows:
A) Open project properties -> Resources -> Add Resource -> Add Existing File
B) Choose the .ICO file that I created in step 2.
4) Go to "Application" section of project properties.
5) In "Icon and Manifest", drop down "Icon" and choose the icon that I added in step 3.
6) Save my project and build it.
7) Go to Windows Explorer and find the newly built EXE.
8) Create a shortcut to the EXE on the desktop.
The icon looks like this:
As you can see, it doesn't look very good. The edges are jagged, etc.
At first, I thought it was an issue with my .ICO file, but here's the kicker... I then did the following:
9) Right-click on the desktop icon, and go to Properties.
10) Go to the Shortcut tab and click "Change Icon".
11) Click "Browse", and select the EXACT SAME ICON FILE that I added to my project in step 3.
Now, my desktop icon looks like this:
Now, the icon looks pretty and smooth!
Again, both icons used the exact same source .ICO file. The only difference is that the first one was imported into Visual Studio and embedded in my .EXE, and the other one was directly used via the OS.
What is Visual Studio doing to my icon to make it look so crummy, and how can I prevent it?
This could be a problem with the windows icon cache. I had the same problem that I fixed by clearing the cache.
The first version of your code that you copied to the desktop - did this have a low res icon ?
Windows will cache the icon when it first sees the EXE, and then does not refresh even when you rebuild your executable if it has the same filename. You will also see the same behavior in windows explorer.
I think by changing the icon through the OS, you've just manually refreshed the icon cache.
You can quickly test this by renaming the EXE before copying it to the desktop. This will bypass the cache and show the actual icon in your EXE.
To get rid of any old icons in the icon cache, you can clear it as described in this link
http://www.winability.com/how-to-erase-icon-thumbnail-cache-windows-8/

How to configure post-build events for setup/deployment projects in Visual Studio

My solution has two projects. One is my actual project and another one is setup project.
My actual project has one report folder where I store my all ssrs report. I have one folder in the setup project called "SSRS_Repor". Now I want that when I will do a batch build then setup for my project regenerate, and then I want to copy all files from the report folder of my actual project to SSRS_Repor in my setup project.
If I can do this kind of automation of copying files from one location to another folder of my setup project, then I could be get rid of manual copying of rdls files. I heard this is possible by setup/deployment projects. I searched Google for this for details step-by-step instruction, but I didn't get any good links. So please guide me how can I do it.
I posted it to another forum too, and some one told me below this:
Open or create a setup/deployment project in Visual Studio 2005
Press F4 to display the Properties window
Click on the name of your setup/deployment project in the Solution Explorer
Click on the PostBuildEvent item in the Properties window to cause a button labeled "..." to appear
Click on the "..." button to display the Post-build Event Command Line dialog
Add a command line of your choice in the Post-build event command line text box
Build your project in Visual Studio and verify that the post-build event is executed after the main MSI build
So it is OK, but what do I need to write for copying files from one location to another location? That is not clear to me. So now this is most important for me what to write for copying file during setup generation.
I got another clue like below one. A script for setup Pre/Post Build Event, but not aware properly. I got a sample like
copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)lib\$(ProjectName).dll"
The above statement or line is not clear to me. What do I need to write in my case? I need a step-by-step guide.
Here is the screenshot of my project structure
To answer your question simply:
The commands that you input in the build events (be it pre or post) are the same as you would enter in a command line box.
In your example:
copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)lib\$(ProjectName).dll"
copy is the actual DOS copy command.
/Y is a regular switch that prevents confirmation prompts.
"$(TargetDir)$(ProjectName).dll" is the source file to copy.
"$(SolutionDir)lib\$(ProjectName).dll" is the destination where to copy the file.
You can refer here to have additional information on batch file commands: Batch command list
The $({Identifier}) are macros you can use in Visual Studio Pre/Post Build event designer.
You can refer to the MSDN online help for more details on macros: MSDN Macros List
The line provided to you would not do what you want. It's usually used to copy DLL files to a library folder used by some other projects or solution.
The solution you found to create a new build event is correct.
All you have left to do is write down the command that will actually copy the files.
It would look something like this:
XCOPY "$(SolutionDir)TestProject\Reports\*.*" "$(SolutionDir)TestSetup1\SSRS_Repor" /Q /E /I
/Q : Quiet | Don't display files being copied
/E : Recursive (copy subfolder structure and files)
/I : Consider that destination is a folder if it does not already exist (will create a new folder if required)

How does one copy a dialog resource from one project to another in Visual Studio 6.0 or Embedded VC++ (eVC)?

I've got two branches of code. 1 has a dialog box that the other doesn't, but because of politics the dialog box wasn't moved into the newest branch. Now they want it in...
So is it possible to copy a dialog box from one project to another.
There apears to be an export and import feature however it's greyed out.
.RC files are simple text files. You can simply copy/paste the DIALOG text from one .RC file to the other. Make sure that you copy the corresponding RESOURCE.H entries as well.
Alternatively, you might be able to open both .RC files and then simply drag-and-drop the dialog from one to the other.
Update for Visual Studio 2010 - 2013:
You can still drag-drop and copy-paste, but only outside of your project / solution.
Close solution, open both RC as files without any open solution, and go. For drag, "Hold down the CTRL key and drag the resource to the second .rc file. For example, drag IDD_DIALOG1 from Source1.rc to Source2.rc."
Microsoft - How to Copy Resources
Drag and drop doesn't work in Visual Studio 2010. Editing the .RC file does work but be careful. For me the ID for the dialog showed up with *ID_etc*. I copied it and removed the *'s and it seemed to fix the problem.
I finally figure it out how to copy a Dialog from one solution to another.
Steps:
Open both solutions in separte windows.
Add a new Blank Dialog -Add Resources-> add->newDialog
Open Both Dialogs Open Binary data.
Copy the Binary data from source solution dialog to Destination Dialog
This is just to add some visual detail to the accepted answer (by Roger Lipscombe) along with its steps.
In order to copy a resource such as a Dialog from one project another project, below steps can be followed.
Start a new instance of Visual Studio.
Open both source and destination .RC file as files, as shown in the picture.
From the source RC file, copy required dialog.
Switch to the destination RC file tab and simply paste it.
Please note that this operation would have updated the resource.h file. That is an excellent help by Visual Studio.
One will have to make sure that no duplicate resource IDs are present in the resource.h file. When working with some legacy projects, it is found that there came some duplicate resource Ids that had to be manually corrected. It looks like such an effort is worth considering the mammoth task required otherwise.

Resources