Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Decrius on February 05, 2006, 04:32:00 pm

Title: Resources
Post by: Decrius on February 05, 2006, 04:32:00 pm
Hello all, I'm new here. Code::Blocks is great, but I have one problem.

I have Icon's and Menu's that I want to place in a resource file. The Icon I define with LoadImage...

But I couldn't find anything in the editor to do something with resources.

What extension should a resource have?
How to 'link' them to your file?
A comprehensive question: What and how with resources.

I hope someone can answer here, I tried the DevShed forum, but they didn't knew anything about resources in Code::Blocks.

Decrius
Title: Re: Resources
Post by: TDragon on February 05, 2006, 04:51:03 pm
The underlying structure for Win32 resources in any IDE is the .rc file. In Code::Blocks, if you add a file with the .rc extension to your project, it will be compiled with the resource compiler and linked into your program.

Unfortunately I've never come across a good reference for the structure of a .rc file (maybe someone else can chime in here?); I just learned by looking at the contents of the files Visual Studio produces.

Also, I've started using wxWidgets for all my GUI development, which sits on top of all the Win32 functionality and uses a different format for its resources, and is in my humble opinion far and away easier to work with.
Title: Re: Resources
Post by: Decrius on February 05, 2006, 04:53:26 pm
Okay, thank you, with project you mean just a .c file? Or that thing they put into the program which does everything except what I need (GUI project thing)?
Title: Re: Resources
Post by: Decrius on February 05, 2006, 04:59:24 pm
I tried the console application project, deleted the main.c, added the .c file of my GUI program, added the resource file (.rc). But when I try to compile (is that the same as 'build'?) it says in the build log:

gcc: Files\CodeBlocks\include\taco\resources\resource.rc: No such file or directory
gcc: warning: `-x c' after last input file has no effect
gcc: no input files
windres.exe: no resources
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 1 warnings

While I selected the resource from the list!

Decrius
Title: Re: Resources
Post by: Decrius on February 05, 2006, 05:14:17 pm
I think I got it working, maybe project are better than I thought :D

Decrius
Title: Re: Resources
Post by: kkez on February 05, 2006, 05:22:58 pm
Unfortunately I've never come across a good reference for the structure of a .rc file (maybe someone else can chime in here?);

Resource definition statement. (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tools/tools/resource_definition_statements.asp)

Oh, hi Decrius  :P
Title: Re: Resources
Post by: kkez on February 05, 2006, 06:00:54 pm
btw, my .rc file no longer have the syntax highlighting even if the filemask for the lexer is .rc... (bug?)

Now, if i change the highlight mode in the edit menu, all the [ + ] to unfold the blocks of code disappear even if the line count remains the same. I just can't unfold it again  :( (bug?)

EDIT: wait, all the lexers switched by one from the D lexers: the D lexer has the fortran77 filemask and so on... better go look inside the default.conf file...
Title: Re: Resources
Post by: takeshimiya on February 05, 2006, 06:35:19 pm
btw, my .rc file no longer have the syntax highlighting even if the filemask for the lexer is .rc... (bug?)

Now, if i change the highlight mode in the edit menu, all the [ + ] to unfold the blocks of code disappear even if the line count remains the same. I just can't unfold it again  :( (bug?)

EDIT: wait, all the lexers switched by one from the D lexers: the D lexer has the fortran77 filemask and so on... better go look inside the default.conf file...

That's a bug: the lexers are indexed by IDs.
Title: Re: Resources
Post by: kkez on February 06, 2006, 12:12:04 pm
everything is fine now, i just deleted everything between <color_sets> and </color_sets>. Maybe in the previous revision the lexers were read in the order they are and my conf file still had the old list...
Title: Re: Resources
Post by: takeshimiya on February 06, 2006, 07:18:37 pm
everything is fine now, i just deleted everything between <color_sets> and </color_sets>. Maybe in the previous revision the lexers were read in the order they are and my conf file still had the old list...
Yes, that's because they're being indexed by IDs, which will screw up all the lexers when a new lexer get's added. :)