Hi,
Consider an unmanaged ATL class, that has to keep the track of two
managed member variables of two different types: Image and Color. I've
got no problem using the Image member variable, where it's declared as
follows:
class ATL_NO_VTABLE CMyClass :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMyClass , &CLSID_MyClass>,
public ISupportErrorInfo,
public IDispatchImpl<IMyClass, &IID_IMyClass, &LIBID_WmeLib, /*wMajor
=*/ 1, /*wMinor =*/ 0>
{
///////////////////
//removed for brevity
///////////////////
private:
gcroot<Image *> m_pImgSrc; //Has got no problem
}
However, I need to have another variable, say, m_clBackLayer of Color
type. However, if I try to declare it as gcroot<Color *>, I've got no
idea how to set that at the desired method of the class. Imagine that
the variable is declared as follows:
gcroot<Color *> m_clBackLayer;
I would like to know that how can I set the m_clBackLayer to, say, a
given argb?
this
m_clBackLayer = Color::FromArgb(lAlpha, lRed, lGreen, lBlue);
ends up to the following error code:
error C2679: binary '=' : no operator found which takes a right-hand
operand of type 'System::Drawing::Color' (or there is no acceptable
conversion)
and the most amazing thing is that it does not let me declare this
value type without using the gcroot class. i.e., if I declare
m_clBackLayer as
Color m_clBackLayer;
I'll get the following error code:
error C3265: cannot declare a managed 'c' in an unmanaged 'CMyClass'
Any idea how to solve this problem?
Thank you for your time,
Mehdi