Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Panarchy on April 22, 2009, 01:05:22 pm

Title: How do I add an icon to Code::Blocks Win32 GUI project?
Post by: Panarchy on April 22, 2009, 01:05:22 pm
Hello

How do I add an icon to a CodeBlocks project?

Here is the code;
Code
#include <windows.h>

int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE hprevious, LPSTR cmdline, int cmdshow) {
   
ShellExecute(NULL, TEXT("open"), TEXT("\"\"%ProgramFiles%\\Symantec\\LiveUpdate\\LUALL.exe\"\""), NULL, NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("explorer"), TEXT("\\Panarchy\\share"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("schedtasks\0"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("sysdm.cpl"), NULL, SW_HIDE);
ShellExecute(NULL, TEXT("open"), TEXT("diskmgmt.msc"), NULL, NULL, SW_HIDE);
   
    return 0;
}

Please tell me how to give it an icon!

Thanks in advance,

Panarchy
Title: Re: How do I add an icon to Code::Blocks Win32 GUI project?
Post by: MortenMacFly on April 22, 2009, 05:04:17 pm
Please tell me how to give it an icon!
Create an icon, place it in a resource file and add the resource file to your project so it's being compiled 7 linked into you application.
Title: Re: How do I add an icon to Code::Blocks Win32 GUI project?
Post by: Panarchy on April 22, 2009, 11:44:03 pm
The first icon in your resource file will be used as the icon of the executable. You'll have to create your resource file manually though, AFAIK Code::Blocks does not have a dialog for it like Dev-cpp. It's not extremely hard, just put something like this in it:
Code
MY_ICON ICON "my_icon.ico"
The first word is the name of the icon (not important unless you want to refer to it in your code), the second word indicates it's an icon and then comes the name of the file to use.

 8)

That worked for me!

SWEET - My project has been perfected!