Author Topic: Icon Help  (Read 4080 times)

Offline The Techo

  • Single posting newcomer
  • *
  • Posts: 6
Icon Help
« on: July 29, 2009, 06:35:52 am »
Hello I am new to Code Blocks, c++ and Win32 programming. i need help on Icons i have an icon in my project's root folder with a icon named o.ico. in my .rc I typed:

#include "Resource.h"

IDI_main ICON "o.ico"

In my resource file I typed:

#define IDI_main 1000

And in my .cpp file I typed:

..........More code.......
   WndClsEx.hIcon         = WndClsEx.hIconSm       = LoadIcon(hInstance,
                 MAKEINTRESOURCE(IDI_main));
   WndClsEx.hCursor       = LoadCursor(NULL, IDC_ARROW);
   WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
   WndClsEx.lpszMenuName  = NULL;
   WndClsEx.lpszClassName = ClsName;
   WndClsEx.hInstance     = hInstance;
   WndClsEx.hIconSm       = WndClsEx.hIconSm       = LoadIcon(hInstance,
                 MAKEINTRESOURCE(IDI_main));
..........More code.......
 
But when i compile i get the following:

||warning: `-x c' after last input file has no effect|
||preprocessing failed.|

can someone please help me?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Icon Help
« Reply #1 on: July 29, 2009, 08:01:24 am »
||warning: `-x c' after last input file has no effect|
||preprocessing failed.|
First of all -> this error is not related to your code. I assume your project setup / compiler options, linker options etc. are mis-configured. Please enable full compiler logging and post the result here (see my sig how to do that).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline The Techo

  • Single posting newcomer
  • *
  • Posts: 6
Re: MortenMacFly
« Reply #2 on: July 29, 2009, 10:38:58 am »
I did what you said and in the build log I got the following message:


-------------- Build: Debug in test ---------------

windres.exe -i C:\DOCUME~1\ADMINI~1\Desktop\CTESTS~1\test\1.rc -J rc -o obj\Debug\1.res -O coff -I"C:\Documents and Settings\Administrator\Desktop\C Tests\test\"
gcc: and\: No such file or directory
gcc: Settings\Administrator\Desktop\C\: No such file or directory
gcc: Tests\test C:\DOCUME~1\ADMINI~1\Desktop\CTESTS~1\test\1.rc: Invalid argument
gcc: warning: `-x c' after last input file has no effect
gcc: no input files
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 1 warnings
  


Is this what you wanted?

P.s. I am using the gcc compiler which is included with the installation package
« Last Edit: July 29, 2009, 10:43:23 am by The Techo »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: MortenMacFly
« Reply #3 on: July 29, 2009, 11:13:45 am »
windres.exe -i C:\DOCUME~1\ADMINI~1\Desktop\CTESTS~1\test\1.rc -J rc -o obj\Debug\1.res -O coff -I"C:\Documents and Settings\Administrator\Desktop\C Tests\test\"
gcc: and\: No such file or directory
That's what I wanted. And as you see: You have an issue with spaces in the path. Some resource compilers do *not* support that - as yours.

You now have the following options:
1.) Move your project to a folder without spaces in the path
2.) Update the compiler suite to a more recent one - especially the resource compiler (which depends on the other compilers, to so do *n ot* only update the resource compiler).
3.) In the compiler setup under "other settings" click on the "advanced options". Then select the tab "Others" and enable "force quotes for filenames in compiler command-line", probably the same for the linker.

The latter may not work or even break the compilation, too if not done with care.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline The Techo

  • Single posting newcomer
  • *
  • Posts: 6
Re: Morten Mac Fly
« Reply #4 on: July 29, 2009, 12:08:40 pm »
Thanks it works perfectly :D