Thread: Resources in Visual Studio

  1. #1
    Registered User
    Join Date
    Aug 2006

    Resources in Visual Studio

    I have been posting on the gpwiki website for an answer to my question yet no body has replied. So I'm bringing my question here. Once upon a time, I bought a wonderfull book called game programming in 24 hours. This seemed a good book until I got up to the bit where it asked me to create a resource file. I then was forced to leave this book and migrate to other things. i tried my hand at SDL, VB and even Python before deciding to try and learn the Windows API. This was again doing fine until I stumbled upon the resource problem again. I could not proceed any further through this tutorial without knowing how to create a resource file and it seemed that no body on the net knew how to either! There were approximately 0 tutorials involving creating resources in Visual Studio on the net, so I posted on various message boards but no one could help. This is what I though was the way to do it:

    Whilst creating the window class I wanted to load an icon from a resource file so I created a resource file which created its own little header file named resource.h. This had the file ID's in it and some mumbo jumbo which looked like this:
    #define _APS_NEXT_RESOURCE_VALUE        102
    #define _APS_NEXT_COMMAND_VALUE         40001
    #define _APS_NEXT_CONTROL_VALUE         1001
    #define _APS_NEXT_SYMED_VALUE           101
    This was considerably confusing. I then imported my icon into the resource file and compiled it. Then I used the ID in my code:

    wc.hIconSm = LoadIcon( NULL, IDI_ICON1 );
    I also tried:

    wc.hIconSm = LoadIcon( NULL, "IDI_ICON1 );
    Both of these times the project was built and ran perfectly fine without any errors but there was no change to the default icon in the top left of the window. I tried this with other ersources but it still compiled but did not work. What am I doing wrong! Can someone please help!

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    a few things. 1 your icon has to be in the same dir as your prog. 2. if i remember correctly the prog defaults to the low number icon to use first. 3. has a win tut with some resoure info in it 4.
     HICON LoadIcon(
        HINSTANCE hInstance,	// handle of application instance
        LPCTSTR lpIconName 	// icon-name string or icon resource identifier
    i think you have to change the null to hinstance need to look up else it defaults to the low id icon
    Last edited by kryptkat; 08-04-2006 at 10:30 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM