473,480 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

get reference to a text object with the name of object

bcarey
5 New Member
In Visual Studio 2010 C++
I have a series of existing text objects
The text properties names are
item1_lbl,
item2_lbl,
item3_lbl,
….
Based on a selection I want to change an object. I generate the name of the object I want to change in a string so from this string is there a way to get a pointer to the correct text object that is same name?
Aug 23 '13 #1
3 1302
weaknessforcats
9,208 Recognized Expert Moderator Expert
There are no names at run time. No class names, no variable names. All of it has been converted by the compiler to binary code.

If you have 3 objects and you want to alter one of them, then you need a pointer to each object and to make your change using the correct pointer. That is, you code using addresses rather then names.
Aug 23 '13 #2
bcarey
5 New Member
Thanks for your reply weaknessforcats,
I actually have about 54 groups each have three text items that need to be changed based on a selection. I was trying to create one callback/method to handle all of them. Since each group has a XXX_Tst1, XXX_Tst2, XXX_Tst3 text items where XXX is arg1 I pass in and I set the three items to the same agr2 string that is passed in. I can create the names of the items just wanted to see if I could avoid having to map them.
Aug 23 '13 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
Maybe I misunderstand but let's see if this is anywhere close:

Fact: there are 54 groups
Fact: each member of the 54 groups has the same three data elements.

So that would mean you have a polymorphic hierarchy where the base class is:

Expand|Select|Wrap|Line Numbers
  1. class Group
  2. {
  3.    public:
  4.       void ChangeTst1( int arg);
  5.       void ChangeTst2( int arg);
  6.       void ChangeTst3( int arg);
  7.    private:
  8.       int tst1;
  9.       int tst2;
  10.       int tst3;
  11. };
  12.  
Then you declare a type of the Group:

Expand|Select|Wrap|Line Numbers
  1. class Blue : public Group
  2. {
  3.     stuff unique to the Blue group..
  4. };
Then you declare a member of the group:

Expand|Select|Wrap|Line Numbers
  1. class Violet : public Blue
  2. {
  3.     stuff unique to Violet...
  4. };
Now you create a Violet object and modify it:

Expand|Select|Wrap|Line Numbers
  1. Group* ptr = new Violet;
  2.         ptr->ChangeTst1(32);  //changes tst1 in the Violet object
Is this close to what you need? I have omitted some details.
Aug 23 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2448
by: lawrence | last post by:
How dangerous or stupid is it for an object to have a reference to the object which contains it? If I have a class called $controllerForAll which has an arrray of all the objects that exist, what...
17
31637
by: warteschlange | last post by:
is there a way to find out the object/function name from inside object/function. function coffee(){ alert(this.someHowGetMyNameFuncOrVar); => should give me 'coffee' } var milk = new...
8
2451
by: Robert | last post by:
Hello all, Why reference cannot be able to represent a NULL object? Best regards, Robert
6
3521
by: Trevor Hartman | last post by:
Hi, I need to refer to my objects dynamically. I have a 7 table cells (sunCell, monCell, tueCell....). I am looping through some data, checking its date and adding it to the correct cell. I...
3
3658
by: Mr.KisS | last post by:
Hello all, I'm working with : WinXP PRO SP1, MS SQL 2005 Express, Visual Web Dev 2005 Express. I have an aspx page which must execute a stored procedure : ______________ try {...
8
1843
by: wASP | last post by:
Hi, I'm having a problem referencing the elements within an object after a method of that object (a member function) has been activated with an onsubmit handler: - - - - - - - - ...
3
1840
by: TheLostLeaf | last post by:
I am trying to dynamically create the object name..... but i can't get it to work... >From This (works) ------------------------------------------------------------------ label1.Text =...
4
3332
by: Curious | last post by:
I got an exception when executing the SQL statement in my code below. The error is "Invalid object name 'db_dynamic_trading.dbo.TrdRpt_broker_list'". I know for a fact that...
23
4307
by: Hugh Oxford | last post by:
How do I get an object's name? EG. $obj_FOO = new Bar; echo $obj_FOO->getName(); 'obj_FOO'
28
2754
by: shivasusan | last post by:
I don't know how to change the text box name? for ex:(my table like this) sl. country from to 1 aaa (txt_c1) 5/4/09 (txt_f1) 5/13/09 (txt_t1) // Now i delete this row. 2 bbb (txt_c2) 5/18/09...
0
6903
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6726
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4468
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
557
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
170
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.