Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC10.0
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 6-Apr-11 19:57pm
Edited 6-Apr-11 20:28pm
v2
Comments
Kozlov_Sergey at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Laje at 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;
}
Laje at 7-Apr-11 1:36am
   
The quotes are put for just emphasizing..
«_Superman_» at 7-Apr-11 1:51am
   
Forget about that function.
Just try this -
int rsIDVal = IDR_BUTTON1;
cout << rsIDVal;
Albert Holguin at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 7 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100