CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 47
  1. #16
    Join Date
    Feb 2009
    Posts
    201

    Re: How do I give my program an icon?

    I will try that, thank you so much!

    But at 1.; Do I have to create a new .cpp file? And then in the solution explorer, I add the .rc file?

    Or just create a blank .rc file with notepad and add 3. into it?

    I don't use the "project" stuff.

    I just use "New File" and then I set it to .cpp and then I start coding.

  2. #17
    Join Date
    Jan 2008
    Location
    California, USA
    Posts
    822

    Re: How do I give my program an icon?

    Quote Originally Posted by realchamp View Post
    Or just create a blank .rc file with notepad and add 3. into it?
    Sure you can do that.
    A resource file is just a text file with .rc extension.
    VC++ 2008 express edition doesn't have a resource editor,
    but that doesn't mean you can manage your resources

    in all, you need a total of three files.
    1. whatever.cpp
    2. whateverName.rc
    3. whateverIcon.ico

    unless you can follow richard_tominez's answer on how to manually bind the resource file
    to the exe file,
    your best chance is to let your project manager (or solution manager) to do the job.

    I don't use the "project" stuff.
    Hehe, you might want to start using it because you will eventually need it.
    For example, NetBeans (another cool IDE) PM checks code file dependancy by refactoring,
    something you can definitely appreciate.

  3. #18
    Join Date
    Feb 2009
    Posts
    201

    Re: How do I give my program an icon?

    Okay... I tryed both ways. The one of them gave me 78 errors. (Using the project).

    I tryed the one with compiling, just getting unknown command "windres".

    I wanna use the windres.

    However with this in my code:

    Code:
    #define MY_ICON
    
    using namespace std;
    
    int main()
    {	
    	MY_ICON ICON "icon.ico";
    
    	bool quit = false;
        while (! quit)
    	{
    And this in my icon.rc:

    Code:
    ICON "icon.ico"

    Both my icon.ico and .rc are in the same folder as my main .cpp is.
    However when I use the 1 you both set, I get errors. Without it, no errors at all. But the ICON didn't work on my program.
    Last edited by realchamp; March 21st, 2009 at 07:17 PM.

  4. #19
    Join Date
    Jan 2008
    Location
    California, USA
    Posts
    822

    Re: How do I give my program an icon?

    Quote Originally Posted by realchamp View Post
    Both my icon.ico and .rc are in the same folder as my main .cpp is.
    Great, stay on this track.
    this is how the rest of the files might look like
    main.cpp
    Code:
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello world!" << std::endl;
        return 0;
    }
    myresource.rc
    Code:
    101 ICON "icon.ico"
    Build your project all together.

    Let me know how it goes

  5. #20
    Join Date
    Feb 2009
    Posts
    201

    Re: How do I give my program an icon?

    Quote Originally Posted by potatoCode View Post
    Build your project all together.
    What do you exactly mean? Also, when I don't try to add any "icon" stuff, the program doesn't give me errors or so.

    Also if you would like to, I can give you TeamViewer 4 access. Then you can see it with your own eyes.

    Or we can just chat over MSN or Steam.

    Only if you want.

    (I hope I didn't break any forum rules there?)
    Last edited by realchamp; March 21st, 2009 at 08:34 PM.

  6. #21
    Join Date
    Jan 2008
    Location
    California, USA
    Posts
    822

    Re: How do I give my program an icon?

    I think we can still solve your problem here.
    (and for those who might need the same help later on)

    you followed everything I told you but it still didn't work?
    Hm, that's odd.

    What IDE are you using?

  7. #22
    Join Date
    Feb 2009
    Posts
    201

    Re: How do I give my program an icon?

    Okay, that's fine.

    However, I'm not sure what you mean about "IDE?".. I haven't found out of what that is yet. Only guessing.

  8. #23
    Join Date
    Mar 2008
    Posts
    30

    Re: How do I give my program an icon?

    windres is one of the utilities of Mingw package.
    To compile your .rc file in command-line using cmd shell:
    Code:
    c:\mingw\bin> windres -i c:\resource.rc -o c:\resource.o
    where:
    c:\mingw\bin> is the directory where windres is
    windres is the program itself
    c:\resource.rc is the input file in C:\ directory
    c:\resource.o is the outpuit file in C:\ directory

    The commands I gave previously are for MSYS.

  9. #24
    Join Date
    Feb 2009
    Posts
    201

    Re: How do I give my program an icon?

    Ohh okay.

    Is the folder on my c drive a standard one? (mingw?) Or do I have to DL something?

    Okay, I tryed setting it up as you created it. It works. But I don't have any resource.o file.

    I ran it in a batch script.


    Code:
    c:\mingw\bin> windres -i c:\Plugins\srcds\resource.rc -o c:\Plugins\srcds\resource.o
    Didn't work. I'm getting invalid directory or no files. Even though my files are in that directory.
    (It wouldn't let me save it into c:\srcds.

    However I get a new file: windres. But it's a empty and it's only a "file" (none of these .dll, .exe, .bat extensions)
    Last edited by realchamp; March 22nd, 2009 at 05:57 AM.

  10. #25
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How do I give my program an icon?

    Quote Originally Posted by realchamp View Post
    However, I'm not sure what you mean about "IDE?".. I haven't found out of what that is yet. Only guessing.
    Rather than ask in each your post just use google. The first link does explain it.

    http://www.google.com/search?sourcei...,GGLJ:en&q=ide
    Victor Nijegorodov

  11. #26
    Join Date
    Feb 2009
    Posts
    201

    Re: How do I give my program an icon?

    Quote Originally Posted by VictorN View Post
    Rather than ask in each your post just use google. The first link does explain it.

    http://www.google.com/search?sourcei...,GGLJ:en&q=ide
    - Sorry.

    I just completely forgot about Google :P

    Thanks

    ps. Anyone there can help me with this?

  12. #27
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How do I give my program an icon?

    [QUOTE=realchamp;1825171ps. Anyone there can help me with this?[/QUOTE]Help you with what?
    What is the current state of your problem?
    What IDE (VC++ 6,0, VS2002/2003/2005/2008, ...) are you using?
    Victor Nijegorodov

  13. #28
    Join Date
    Jan 2008
    Location
    California, USA
    Posts
    822

    Re: How do I give my program an icon?

    Quote Originally Posted by realchamp View Post
    Also, when I don't try to add any "icon" stuff, the program doesn't give me errors or so.
    You're not... you didn't do anything like change "myicon.gif" to "myicon.ico"... did you?

  14. #29
    Join Date
    Feb 2009
    Posts
    201

    Re: How do I give my program an icon?

    Quote Originally Posted by potatoCode View Post
    You're not... you didn't do anything like change "myicon.gif" to "myicon.ico"... did you?
    I didn't create the .ico.

    I think he compilied it, using a template for Adobe Photoshop.
    (#define "he" a freind.)


    Quote Originally Posted by VictorN View Post
    Help you with what?
    What is the current state of your problem?
    What IDE (VC++ 6,0, VS2002/2003/2005/2008, ...) are you using?
    I use VC++ 2008 Express Edition.

    My current state is that I can't get an icon on my program.

  15. #30
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How do I give my program an icon?

    Quote Originally Posted by realchamp View Post
    I use VC++ 2008 Express Edition.

    My current state is that I can't get an icon on my program.
    What have you already tried to do to add an icon?
    Victor Nijegorodov

Page 2 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured