C2682: cannot use __try_cast to convert from 'gcroot<T>'
-
Hello All, I have a standard C++ class with MC++ member defined as
gcroot < System::Drawing::Brush __gc* > m_pDotNetBrush;
Somewhere in the codes, I wish to use the brush and trying to cast it to the appropriate type:
System::Drawing::SolidBrush \_\_gc\* pBrush = \_\_try\_cast < System::Drawing::SolidBrush \_\_gc\* >(m\_pDotNetBrush);
This, however, generates error in the form:
error C2682: cannot use __try_cast to convert from 'gcroot < T >' to 'System::Drawing::SolidBrush __gc *'
I tried the other standard C++ casts and all failed with same error. What is supposed to be done in this case? Best regards, Paul. Jesus Christ is LOVE! Please tell somebody. -
Hello All, I have a standard C++ class with MC++ member defined as
gcroot < System::Drawing::Brush __gc* > m_pDotNetBrush;
Somewhere in the codes, I wish to use the brush and trying to cast it to the appropriate type:
System::Drawing::SolidBrush \_\_gc\* pBrush = \_\_try\_cast < System::Drawing::SolidBrush \_\_gc\* >(m\_pDotNetBrush);
This, however, generates error in the form:
error C2682: cannot use __try_cast to convert from 'gcroot < T >' to 'System::Drawing::SolidBrush __gc *'
I tried the other standard C++ casts and all failed with same error. What is supposed to be done in this case? Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.Got this response from one Jochen Kalmbach, and it works :) Normaly you should do:
System::Drawing::Brush *b;
b = m_pDotNetBrush;Then you can try to cast it...
System::Drawing::SolidBrush *pBrush =
__try_cast < System::Drawing::SolidBrush* > (b);-- Greetings Jochen Jesus Christ is LOVE! Please tell somebody.