Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Experts,

Is to possible to return the Resource ID form its name ? ie, in Resource.h there are values like IDR_BUTTON1 100 . I needed to return the value 100 by specifying its name as"IDR_BUTTON1". Please help me.

Thanks,
Laje.
Posted
Updated 6-Apr-11 19:28pm
v2
Comments
[no name] 7-Apr-11 3:41am    
You can create the table: Resource_Name L"Resource_Name" Something like class resource_table { public: INT name; WCHAR value[50]; }; const resource_table local_program_resource_table = { {Resource_Name_1 L"Resource_Name_1"}, {Resource_Name_2 L"Resource_Name_2"}, };

1 solution

IDR_BUTTON1 without the double quotes is in-fact the actual value itself.
If you look at the resource.h file you will see a line called #define IDR_BUTTON1 100.
 
Share this answer
 
Comments
Satheesh1546 7-Apr-11 1:35am    
Actually i needed to get the integer value assigned to a particular resource (From resource.h) by specifying it's name. Something like
int fnReturnResourceValue(CString strResourecName)
{
.............
return rsIDVal;
}
Satheesh1546 7-Apr-11 1:36am    
The quotes are put for just emphasizing..
«_Superman_» 7-Apr-11 1:51am    
Forget about that function.
Just try this -
int rsIDVal = IDR_BUTTON1;
cout << rsIDVal;
Albert Holguin 7-Apr-11 9:48am    
I can't believe this is even a question... but my 5 to you for answering! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900