Author Topic: Adding resources  (Read 11179 times)

Offline temujin

  • Single posting newcomer
  • *
  • Posts: 5
Adding resources
« 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.

I´m 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/

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.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Adding resources
« Reply #1 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.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Adding resources
« Reply #2 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.

Offline temujin

  • Single posting newcomer
  • *
  • Posts: 5
Re: Adding resources
« Reply #3 on: August 26, 2007, 01:09:52 am »
Thanks,

Now it worksperfectly...

 :D

t.