Storing a Refrence in a Tag
-
I've got a Wizard Form where i create controls in runtime. I need to attach the reference of a String/double variable to a control. This variables exists in another class. so when the Wizard finishes, i iterate through all the controls and each control updates it's own referenced varaible. In .NET i used the Control.Tag property (is of type Object - that was easy). Want to do the same in C++ but the Control->Tag is of int type.:doh: Im missing something. Help me to convert the parameter Value:
void ExcuteWizard(..., AnsiString &Value) { TTextbox ctrl = new ....; ctrl->Tag = Value; //<< how do i convert the Value parameter? } void FinnishWizard() { for each control{ ((&AnsiString)Control->Tag) = Control->Text; //< Have someone a theory or explanation with regards to pointer and reference conversions? Thanks.
-
I've got a Wizard Form where i create controls in runtime. I need to attach the reference of a String/double variable to a control. This variables exists in another class. so when the Wizard finishes, i iterate through all the controls and each control updates it's own referenced varaible. In .NET i used the Control.Tag property (is of type Object - that was easy). Want to do the same in C++ but the Control->Tag is of int type.:doh: Im missing something. Help me to convert the parameter Value:
void ExcuteWizard(..., AnsiString &Value) { TTextbox ctrl = new ....; ctrl->Tag = Value; //<< how do i convert the Value parameter? } void FinnishWizard() { for each control{ ((&AnsiString)Control->Tag) = Control->Text; //< Have someone a theory or explanation with regards to pointer and reference conversions? Thanks.
-
Please guys! Ok at least how do i translate a integer that is a address e.g. 1247075 to the original AnsiString variable refrence?
you may use a pointer instead of a reference, provided you
Tag
property ha a compatible size. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
you may use a pointer instead of a reference, provided you
Tag
property ha a compatible size. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Compile Error: Cannot convert 'AnsiString*' to 'int' I don't understand :
CPallini wrote:
Tag property ha a compatible size.
It's a int-type - one size.
InOut.NET wrote:
Compile Error: Cannot convert 'AnsiString*' to 'int'
What compiler are you using?
InOut.NET wrote:
I don't understand : CPallini wrote: Tag property ha a compatible size. It's a int-type - one size.
if
sizeof(int)
is the same ofsizeof(AnsiString*)
then conversion should be possible (and allowed). If the condition above doesn't hold you can use theint
value as index of a array of pointers (i.e. adding a level of indirection). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
InOut.NET wrote:
Compile Error: Cannot convert 'AnsiString*' to 'int'
What compiler are you using?
InOut.NET wrote:
I don't understand : CPallini wrote: Tag property ha a compatible size. It's a int-type - one size.
if
sizeof(int)
is the same ofsizeof(AnsiString*)
then conversion should be possible (and allowed). If the condition above doesn't hold you can use theint
value as index of a array of pointers (i.e. adding a level of indirection). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
Builder C++ 2006 Yeah i used Tag = (int)AnsiString* I could not get the int address from the Tag back to AnsiString*. I decided to ditch AnsiString* and go for a struct* with a few AnsiSting in it. All work so much easier. I think theres something about the AnsiString type that I don;t understand. Thanks for your help.
-
Builder C++ 2006 Yeah i used Tag = (int)AnsiString* I could not get the int address from the Tag back to AnsiString*. I decided to ditch AnsiString* and go for a struct* with a few AnsiSting in it. All work so much easier. I think theres something about the AnsiString type that I don;t understand. Thanks for your help.
InOut.NET wrote:
I decided to ditch AnsiString* and go for a struct* with a few AnsiSting in it.
Probably the
struct *
will give you the same sort of problem theAnsiString *
gave (I hope the countrary, of course). :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.