Resources in Visual Studio

This is a discussion on Resources in Visual Studio within the Windows Programming forums, part of the Platform Specific Boards category; I have been posting on the gpwiki website for an answer to my question yet no body has replied. So ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    3

    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:
    Code:
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        102
    #define _APS_NEXT_COMMAND_VALUE         40001
    #define _APS_NEXT_CONTROL_VALUE         1001
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif
    This was considerably confusing. I then imported my icon into the resource file and compiled it. Then I used the ID in my code:

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

    Code:
    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
    Posts
    638
    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. winnprog.org has a win tut with some resoure info in it 4.
    Code:
     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 11: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, 09: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, 01: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, 09:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21