Click here to Skip to main content
11,638,173 members (75,830 online)
Rate this: bad
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.

Posted 6-Apr-11 18:57pm
Edited 6-Apr-11 19:28pm
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
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.
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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 314
1 302
2 stibee 253
3 Richard Deeming 180
4 Mika Wendelius 178
0 OriginalGriff 9,051
1 Sergey Alexandrovich Kryukov 8,773
2 Mika Wendelius 7,034
3 Suvendu Shekhar Giri 2,425
4 F-ES Sitecore 2,408

Advertise | Privacy | Mobile
Web04 | 2.8.150728.1 | Last Updated 7 Apr 2011
Copyright © CodeProject, 1999-2015
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