User forums > Using Code::Blocks

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

(1/1)

Panarchy:
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;
}
--- End code ---

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!

--- End quote ---
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.

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:

--- Code: ---MY_ICON ICON "my_icon.ico"
--- End code ---
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.

--- End quote ---

 8)

That worked for me!

SWEET - My project has been perfected!

Navigation

[0] Message Index

Go to full version