News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How do I add an icon to Code::Blocks Win32 GUI project?

Started by Panarchy, April 22, 2009, 01:05:22 PM

Previous topic - Next topic

Panarchy

Hello

How do I add an icon to a CodeBlocks project?

Here is the 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

MortenMacFly

Quote from: Panarchy on April 22, 2009, 01:05:22 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Panarchy

Quote from: Urxae on September 30, 2005, 12:44:40 AM
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:
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!