积极答复者
如何序列化CRgn对象?

问题
答案
-
的确是一行一个rect的,这是用网格来逼近直线,在不同的计算机上可能有不同的结果。如果光是序列化rgndata的话当然可以这么做,但是如果用来还原Path的话未必精确。
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已建议为答案 Elegentin XieModerator 2012年6月22日 1:05
- 已标记为答案 yshkcj 2012年6月23日 7:37
全部回复
-
MSDN上有讲到如何序列化
Five main steps are required to make a class serializable. They are listed below and explained in the following sections:-
Deriving your class from CObject (or from some class derived from CObject).
-
Using the DECLARE_SERIAL macro in the class declaration.
-
Using the IMPLEMENT_SERIAL macro in the implementation file for your class.
If you call Serialize directly rather than through the >> and << operators of <link keywords="9E950D23-B874-456E-AE4B-FE00781A7699" tabIndex="0" />, the last three steps are not required for serialization.
CRgn派生自CGdiObject,CGdiObject派生自CObject类,重载Serialize函数。Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.
-
-
CRgn不支持序列化。不过你可以序列化创建了这个对象的步骤,比如如果是line to出来的结果的话,把起始点和线宽记录下来。
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP -
这个大概可以吧:
DWORD GetRegionData( HRGN hRgn, // handle to region
DWORD dwCount, // size of region data buffer
LPRGNDATA lpRgnData // region data buffer );HRGN ExtCreateRegion( CONST XFORM *lpXform, // transformation data
DWORD nCount, // size of region data
CONST RGNDATA *lpRgnData // region data buffer ); -
这个只对CreateFromRect的有用吧?CreateFromPath的呢?
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP -
没试过但是,这是RGNDATA的定义
typedef struct _RGNDATAHEADER { DWORD dwSize; DWORD iType; DWORD nCount; DWORD nRgnSize; RECT rcBound; } RGNDATAHEADER, *PRGNDATAHEADER; typedef struct _RGNDATA { RGNDATAHEADER rdh; char Buffer[1]; } RGNDATA, *PRGNDATA, NEAR *NPRGNDATA, FAR *LPRGNDATA;
所以,RGNDATA是变长的结构,应该不仅仅支持RECT。GetRegionData函数的参数dwCount是字节,不是RGNDATA数组的大小。- 已建议为答案 Elegentin XieModerator 2012年6月22日 1:06
-
那个butter[1]是Rect数组的首地址……
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP -
的确是一行一个rect的,这是用网格来逼近直线,在不同的计算机上可能有不同的结果。如果光是序列化rgndata的话当然可以这么做,但是如果用来还原Path的话未必精确。
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已建议为答案 Elegentin XieModerator 2012年6月22日 1:05
- 已标记为答案 yshkcj 2012年6月23日 7:37