Click here to Skip to main content
13,052,163 members (38,905 online)
Rate this:
Please Sign up or sign in to 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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 Apr 2011
Copyright © CodeProject, 1999-2017
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