Author Topic: How do I add an icon to Code::Blocks Win32 GUI project?  (Read 6070 times)

Offline Panarchy

  • Single posting newcomer
  • *
  • Posts: 4
How do I add an icon to Code::Blocks Win32 GUI project?
« on: April 22, 2009, 01:05:22 pm »
Hello

How do I add an icon to a CodeBlocks project?

Here is the code;
Code: [Select]
#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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: How do I add an icon to Code::Blocks Win32 GUI project?
« Reply #1 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Panarchy

  • Single posting newcomer
  • *
  • Posts: 4
Re: How do I add an icon to Code::Blocks Win32 GUI project?
« Reply #2 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: [Select]
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!