News:

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

Main Menu

Resources with code blocks

Started by chrishowarth, April 19, 2007, 02:17:14 PM

Previous topic - Next topic

chrishowarth

Hello ~ my first post!! :D

I've just downloaded the Code::Blocks IDE, and I was wondering how to use resource (.rc) files with it?  I had to delete the one already included with my Dev-cpp project, as I got the error while compiling it in Code::Blocks... oh, I've forgotten.  I'm not on my computer.  A 'Win something.exe' errors.  But anyway, I haven't been able to find any support for them yet.  Prove me wrong!  Is there anything that I can do?

~ Christopher Howarth

TDragon

Yes, Code::Blocks has full support for using .rc files!

Enable full command line logging (Settings->Compiler and debugger->Global compiler settings->Other->Compiler logging), and post the contents of the Build Log here.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

chrishowarth

I think this is it?  After I had done what you asked I re-added the resource, attempted to build, and copied to contents of the 'Build Log' tab.  Is this correct?  If it is, here is what I got:

QuoteProject   : main
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Christopher\My Documents\Christopher's Stuff\Personal\C++\My Projects\Win32 Code Blocks\
--------------------------------------------------------------------------------
Switching to target: default
windres.exe -i about.rc -J rc -o .objs\about.res -O coff   
windres.exe: about.rc:2: syntax error
Process terminated with status 1 (0 minutes, 1 seconds)

TDragon

It's telling you there's an error in the syntax on line two of your resource file. Let's see that line and its immediate context.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

chrishowarth

OK - Oh, and by the way, I tried another resource file, and got an error.  Code::Blocks also didn't recognisr the file extention and asked me how to open it.  The resource file syntax was taken from a WinAPI tutorial website.

ABOUTDLG DIALOG 0, 0, 155, 102
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "About Elixir ID3 Editor"
FONT 8, "MS Sans Serif"
{
   CONTROL "&OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 6, 83, 50, 14
   CONTROL "&Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 95, 83, 50, 14
   CONTROL "About This Program", -1, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 5, 144, 73
   CONTROL "© 2007 by Christopher Howarth, Elixir Software.\n\nNote: This application was created in pure C/C++, and is open source. ", -1, "static", SS_CENTER | WS_CHILD | WS_VISIBLE, 10, 27, 120, 50
}

TDragon

Quote from: chrishowarth on April 19, 2007, 05:42:42 PM
Code::Blocks also didn't recognisr the file extention and asked me how to open it.
Just tell it to open it in the Code::Blocks editor, and it'll never ask you again.

As far as the code you posted, all you should need to do is add the following line to the top:

#include <windows.h>

[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

chrishowarth

It works!!!  Thankyou!  Silly me, I forgot all about that...  :o