Using Resources - help needed
I''m using Vis Studio 6 from MS. All I''m trying to do is get the DX icon on the window instead of the usual one assigned.
I noticed that on the DX Framework MS don''t use the .rc file for the resource. They just create a resource.h file and put the icon in the resource area.
I have the icon in the resource area, I have created a resource.h file with the following line,
#define IDI_ICON1 101
Then when creating the window I have added,
wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1)); // Load in the app icon
I just get the usual icon unless I change hInst to NULL and then I get a yellow triangle with an exlamnation point in.
Anyone use resources, know what I''m doing wrong here?
You *do* need an .rc file in your project. I don''t know how the DX Framework gets away with it, but having one is the ''correct'' way to do things.
Scrap your resource.h file, and create the .rc script (which will create a new resource.h). Add the icon to it as IDI_APPICON or whatever you want (APPICON is usually easier to understand). In code, you can then use MAKEINTRESOURCE(IDI_APPICON) to reference your icon.
If you want to know what''s really going on:
When you build your project, LINK puts in a ''data chunk'' - if you''ve used Mac, you might know it as a ''resource fork'' - containing all the app resources specified in your .RC file. Each one has a unique ID number (such as 101 that you saw in the resource.h file).
In code, when you call LoadIcon(), it can EITHER load an icon from your own project, OR it can load from the system - it loads from the system by passing NULL for the first parameter. And it just so happens that system icon id# 101 is the yellow exclamation sign. Instead, you want to pass it your app''s own hInst - so that the system knows which data chunk to look in to find the icon.
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Scrap your resource.h file, and create the .rc script (which will create a new resource.h). Add the icon to it as IDI_APPICON or whatever you want (APPICON is usually easier to understand). In code, you can then use MAKEINTRESOURCE(IDI_APPICON) to reference your icon.
If you want to know what''s really going on:
When you build your project, LINK puts in a ''data chunk'' - if you''ve used Mac, you might know it as a ''resource fork'' - containing all the app resources specified in your .RC file. Each one has a unique ID number (such as 101 that you saw in the resource.h file).
In code, when you call LoadIcon(), it can EITHER load an icon from your own project, OR it can load from the system - it loads from the system by passing NULL for the first parameter. And it just so happens that system icon id# 101 is the yellow exclamation sign. Instead, you want to pass it your app''s own hInst - so that the system knows which data chunk to look in to find the icon.
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement