Alan Benett
June 4th, 1999, 09:30 AM
Hello!
I'm writing on a class that mainly encapsulates a CRgn.
As I want to use this class in a container (mainly an array), i added
a copy constructor and assignment operator that should copy the
CRgn encapsulated in my class to the new instance.
However i get an error (access violation) when i try to create a CRgn
using CreateFromData and GetRegionData.
Here's the code:
class CMyRgn : public CObject
{
CRgn m_rgn;
CMyRgn (CMyRgn&);
CMyRgn operator= (CMyRgn&);
...
};
CMyRgn operator= (CMyRgn&)
{
// copy the region data
RGNDATA RgnData;
int nDataSize;
nDataSize = rgnSrc.m_rgn.GetRegionData (NULL, 0);
rgnSrc.m_rgn.GetRegionData (&RgnData, nDataSize); // this one fails
m_rgn.CreateFromData (NULL, nDataSize, &RgnData);
...
}
I'm writing on a class that mainly encapsulates a CRgn.
As I want to use this class in a container (mainly an array), i added
a copy constructor and assignment operator that should copy the
CRgn encapsulated in my class to the new instance.
However i get an error (access violation) when i try to create a CRgn
using CreateFromData and GetRegionData.
Here's the code:
class CMyRgn : public CObject
{
CRgn m_rgn;
CMyRgn (CMyRgn&);
CMyRgn operator= (CMyRgn&);
...
};
CMyRgn operator= (CMyRgn&)
{
// copy the region data
RGNDATA RgnData;
int nDataSize;
nDataSize = rgnSrc.m_rgn.GetRegionData (NULL, 0);
rgnSrc.m_rgn.GetRegionData (&RgnData, nDataSize); // this one fails
m_rgn.CreateFromData (NULL, nDataSize, &RgnData);
...
}