How to change Icon

The Partridge Family were neither partridges nor a family. Discuss.
NeonAfro
Posts: 2
Joined: November 14th, 2013, 6:06 pm

How to change Icon

Post by NeonAfro » November 15th, 2013, 4:08 am

Hello, I am new here so I am sorry if I breach code of conduct, I do apologize;
I will be sure to change my behavior as appropriate.

I was wondering if it would be possible to change the Icon on the framework.

EG: making my own icon for the dash and in top left of the window. I know that in Windows.cpp it calls some stuff, in a .res file... Is there a way to edit this?

the code says:

wc.hIconSm = (HICON)LoadImage( hInst,MAKEINTRESOURCE( IDI_APPICON16 ),IMAGE_ICON,16,16,0 );
wc.hIcon = (HICON)LoadImage( hInst,MAKEINTRESOURCE( IDI_APPICON32 ),IMAGE_ICON,32,32,0 );

I already know how to change the title, and name of the window but this extra bit of info would be nice. Thanks!

*note*

I would have uploaded the Windows.cpp but there was not much code and it is in every framework.

NeonAfro
Posts: 2
Joined: November 14th, 2013, 6:06 pm

Re: How to change Icon

Post by NeonAfro » November 15th, 2013, 4:21 am

I did find a topic already talking about it here

http://www.planetchili.net/forum/viewto ... f=3&t=1440

and am using the XN editor, would someone please give a short explanation on how to use it and incorporate the .res file into the program, thanks.

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: How to change Icon

Post by LuisR14 » November 15th, 2013, 5:13 am

well you pretty much open up the .res file in XN editor and find the icon and replace it with your custom icon, then save and replace the .res file in the project and rebuild the project :)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

ghilllie
Posts: 72
Joined: May 2nd, 2012, 3:25 am

Re: How to change Icon

Post by ghilllie » November 15th, 2013, 3:02 pm

Hi everyone and I welcome myself on returning on chili +++ tuts. Anyway changing the icon is very much possible. The format below is your key in making it.

Code: Select all

	wcx.hIcon = (HICON)LoadImage( // returns a HANDLE so we have to cast to HICON
	  NULL,             // hInstance must be NULL when loading from a file
	  L"youtube.ico",   // the icon file name
	  IMAGE_ICON,       // specifies that the file is an icon
	  0,                // width of the image (we'll specify default later on)
	  0,                // height of the image
	  LR_LOADFROMFILE|  // we want to load a file (as opposed to a resource)
	  LR_DEFAULTSIZE|   // default metrics based on the type (IMAGE_ICON, 32x32)
	  LR_SHARED|         // let the system release the handle when it's no longer used
	  LR_LOADTRANSPARENT	//flag for transparent icon
	);
the rest you should be able to figure out how...
Chili++ for President :)

User avatar
bobloblaw
Posts: 100
Joined: April 15th, 2013, 3:05 am
Location: Earth, USA, California, SF Bay Area
Contact:

Re: How to change Icon

Post by bobloblaw » November 15th, 2013, 3:33 pm

Creating and changing the .exe icon

Like all things done on the computer there are multiple ways to accomplish a task.

You can use various software freely available from the net to accomplish the creation and loading of icon images.
I have listed a few options below to get you started:

- XN Resource Editor - http://www.wilsonc.demon.co.uk/d10resourceeditor.htm
- - Not widely documented but seems to be used by other users on the Chili Forums.
- - Created by Colin Wilson

- Resource Hacker - http://www.angusj.com/resourcehacker/
- - An older program than the formerly stated but is thus more widely documented.
- - A useful tutorial is available for those looking for a little more hand holding.
- - http://www.askvg.com/tutorial-all-about ... -tutorial/

- IcoFx v.1.6.4 - - http://www.filehippo.com/download_icofx/6890/
- - v.1.6.4 is free but if you download any of their newer versions it's only free for 30 days.

My favorite software of the bunch is IcoFx. Developed as an icon editor it is by far the most polished compared to the other two above. There is a resource editor built into this software as well.

So without any further ado I am going to walk you through the process of how I create, alter, and save icon files to be held in the resource file.

1. I start out by saving the original resource file found in the Assets folder. It's the file that ends with ( .res ). I save the original in a new folder in Assets called "OriginalResourceFile". You can name it whatever you like. This serves as a backup in case something fouls up during the changes we are going to make.

2. Renaming the resource file:
It can be renamed from inside Visual Studio by right clicking the file name in the solution explorer and choosing rename or double left clicking on the name will accomplish the same.

3. Saving multiple image sizes in one icon file using IcoFx:

- File -> Import Image: navigate to your image file you wish to replace chili's image with.
- - CLICK "Open".

- - Then CLICK on the windows symbol in the tool bar, a popup window will appear for you to choose the sizes of images saved inside the icon file.
- - Choose the sizes you wish and CLICK "OK".

- - File -> Save As: navigate to where you wish to save your file, name the file and CLICK "Save".

If you wish to not download the IcoFx software one can also use the online upload ICO converter - http://www.icoconverter.com/

You can also create icon files using photoshop by downloading the .ico save file type. If I want to just replace one specific file like the chili framework uses I will use photoshop.

4. Now that we have our file to upload open Resource Hacker or like software.
- File -> Open: Navigate to the resource file we renamed earlier and select "Open".
- If the file is not showing up make sure under Files Of Type: Resource(.res) is selected.
- On the left there is a tree of folders. Two root files named Icon and Icon Group.
- Clicking the "+" symbol next to the Icon Group folder. You should now see two sub folders name 101 and 103. 101 holds the 16x16 icon and 103 holds the 32x32 icon.
- Click the "+" next to each folder to see these files.
- Select the "0" next to the gear symbol in the 101 folder.
- Select "Action" -> replace Icon: CLICK "Open File With New Icon..." Navigate to the .ico file we created in the earlier steps.
- CLICK "Replace"

Follow the same procedure for the 103 file.

Congratulations! Back on Visual Studio Re-Compile your program ( Ctrl+F5 ) and you're done!

Advanced:

Sometimes having a taskbar icon of 32x32 on larger monitors looks a little pixelated. So for those of you that are still with me we are going to add 48x48 size support to the chili framework.

1. We need to create a 48x48 version of our icon and I'm going to assume since you got this far you can figure that out as described above.

2. Lets add some code. Open VS ( Visual Studio ) Resource.h:

Code: Select all

#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif

#define IDI_APPICON16 101 // 16x16
#define IDI_APPICON32 103 // 32x32
// Add the following
#define IDI_APPICON48 105 // 48x48
3. Now lets change some code. Windows.cpp

Code: Select all

int WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT )
{
	WNDCLASSEX wc = { sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0, 0, 
                      GetModuleHandle( NULL ), NULL, NULL, NULL, NULL, 
                      L"Chili DirectX Framework Window", NULL };
    wc.hIconSm = (HICON)LoadImage( hInst, MAKEINTRESOURCE( IDI_APPICON16 ), IMAGE_ICON, 16, 16, 0 );
// Commented the next line out
	//wc.hIcon   = (HICON)LoadImage( hInst, MAKEINTRESOURCE( IDI_APPICON32 ), IMAGE_ICON, 32, 32, 0 );
// Replacing it with the next line
	wc.hIcon   = (HICON)LoadImage( hInst, MAKEINTRESOURCE( IDI_APPICON48 ), IMAGE_ICON, 48, 48, 0 );
Here for your Artistic needs, Pixel or Vector I love it all. Check it out - Click Me

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: How to change Icon

Post by chili » November 30th, 2013, 5:07 pm

I just noticed this thread now. Very nice guide Boblolaw, I'll have to remember to link this if someone else asks about icons.

Also, welcome back ghillie. :)
Chili

Radix
Posts: 10
Joined: April 14th, 2013, 3:53 pm

Re: How to change Icon

Post by Radix » December 7th, 2013, 12:52 am

Hey Guys

I came up with a different way to do this, that doesn't require the use of a text editor or any code.

Checkout the attached gif
Attachments
Explanation.gif
Explanation.gif (117.24 KiB) Viewed 5512 times

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: How to change Icon

Post by LuisR14 » December 7th, 2013, 1:09 am

haha, that method would be for when using the non-empty new project option, the posts above were referring to the chili framework or just creating own framework (empty project) :)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

ghilllie
Posts: 72
Joined: May 2nd, 2012, 3:25 am

Re: How to change Icon

Post by ghilllie » December 7th, 2013, 12:44 pm

Yo Chili, Sorry for being inactive but I promise I'll find my way to catch your back from being far beyond :D
Chili++ for President :)

Radix
Posts: 10
Joined: April 14th, 2013, 3:53 pm

Re: How to change Icon

Post by Radix » December 7th, 2013, 4:21 pm

LuisR14 wrote:haha, that method would be for when using the non-empty new project option, the posts above were referring to the chili framework or just creating own framework (empty project) :)
Ohhh, I see. (Darn lol guess no shortcuts)

Post Reply