Code::Blocks

User forums => Using Code::Blocks => Topic started by: temujin on August 25, 2007, 10:57:56 pm

Title: Adding resources
Post by: temujin on August 25, 2007, 10:57:56 pm

Dear Forum,

Newcomer here...sorry if I have posted in the wrong forum, or if this is not really about C::B.

Im trying to grasp the Win32 API, coding under XP, using Code::Blocks IDE and the resource editor "Resource editor 1.1.4.2" http://www.radasm.com/resed/ (http://www.radasm.com/resed/)

With the resource editor I have created a resource file containing two new icons (16x16 and 32x32) called IDI_NEWICON.

Now, renaming the .rc resource file to xrc (for use with Code::Blocks) I add this file to my Win32 project, which consists of nothing more than a window.

In the main file I change the WinMain to

wincl.hIcon = LoadIcon (hThisInstance, MAKEINTRESOURCE(IDI_NEWICON));
...and the "wincl.hIconSm" accordingly.

Compiling I get the error message:
error 'IDI_NEWICON' undecleared (first use this function)

I suspect that I need to add another header file or something , but what should be in it ?
Any suggestions would be appreciated

regards
t.
Title: Re: Adding resources
Post by: TDragon on August 25, 2007, 11:02:58 pm
This isn't really about C::B, but I'll answer it anyway.

A good resource editor will usually automatically create (or have the option to create) a header file containing integer defines for the identifiers -- i.e. "#define IDI_NEWICON 1001", or similar. Find this header file (or create it if you can't have it automatically created), and #include it where necessary.
Title: Re: Adding resources
Post by: JGM on August 25, 2007, 11:08:04 pm
Now, renaming the .rc resource file to xrc (for use with Code::Blocks)

Try not renaming the file to xrc extension leave the rc extension. codeblocks automatically detect the rc extension as a resource and compile it with the right tool.
Title: Re: Adding resources
Post by: temujin on August 26, 2007, 01:09:52 am
Thanks,

Now it worksperfectly...

 :D

t.