是否应该释放?

zwjchina 2003-06-26 09:36:11
使用CreateRectRgn,是否应该DeleteObject该区域

例子1
Rgn1 = CreateRectRgn
Rgn2 = CreateRectRgn
CombineRgn(Rgn3, Rgn1, Rgn2, RGN_AND);

此处是否要释放,该释放些什么?

例子2
Rgn1 = CreateRectRgn
GetClipRgn(ADC, Rgn2);
SelectClipRgn(ADC, Rgn1);
...
SelectClipRgn(ADC, Rgn2) //恢复

此处又该释放些什么? Rgn1? Rgn2?

例子3
BeginPath(ADC)
...//构造一个路径
EndPath(ADC);
GetClipRgn(ADC, Rgn1);
SelectClipPath(ADC);
...
SelectClipRgn(Rgn1); //恢复

此处又该释放些什么??????

...全文
73 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
superyys 2003-06-26
  • 打赏
  • 举报
回复
yup
bluenightsky 2003-06-26
  • 打赏
  • 举报
回复
gz
firetoucher 2003-06-26
  • 打赏
  • 举报
回复
1 释放Rgn1 Rgn2
2 释放Rgn1
3 不释放

CreateRectRgn其实是返回一个数组,在没有select时,应该删除,不过因为只是数组,并不是资源,所以应该一般不会有什么问题出在这里吧。
myling 2003-06-26
  • 打赏
  • 举报
回复
CreateRectRgn不用时一定要用DeleteObject函数删除该区域

1.释放Rgn1, Rgn2

2.释放Rgn1

3.不用释放


就是创建什么,就释放什么

DeleteObject

不要删除一个已选入设备场景的画笔、刷子或位图。如删除以位图为基础的阴影(图案)刷子,位图不会由这个函数删除——只有刷子被删掉


SelectClipRgn

为指定设备场景选择新的剪裁区

该函数拷贝剪裁区;
这样同一剪裁区可用于多个设备场景,删除它不会影响每个设备场景的剪裁区。
ghostmirror 2003-06-26
  • 打赏
  • 举报
回复
The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object. After the object is deleted, the specified handle is no longer valid.

BOOL DeleteObject(
HGDIOBJ hObject // handle to graphic object
);

Parameters
hObject
Handle to a logical pen, brush, font, bitmap, region, or palette.
Return Values
If the function succeeds, the return value is nonzero.

If the specified handle is not valid or is currently selected into a device context, the return value is zero.

Windows NT: To get extended error information, callGetLastError.

Remarks
Do not delete a drawing object (pen or brush) while it is still selected into a device context.

When a pattern brush is deleted, the bitmap associated with the brush is not deleted. The bitmap must be deleted independently.

MSDN资料只提到不要删除pen和brush的,个人觉得应该删除~~反正留着也没什么用
。。。。
sheepcyk 2003-06-26
  • 打赏
  • 举报
回复
zwjchina 2003-06-26
  • 打赏
  • 举报
回复
dz_w 2003-06-26
  • 打赏
  • 举报
回复
Create出来的,不用了都要Delete
nik_Amis 2003-06-26
  • 打赏
  • 举报
回复
up
zwjchina 2003-06-26
  • 打赏
  • 举报
回复
谢谢关注,继续请高手帮忙。
USTCTony 2003-06-26
  • 打赏
  • 举报
回复
一可以把1,2都delete掉啊。你combine之后,那两个区域已经没用了。
zwjchina 2003-06-26
  • 打赏
  • 举报
回复
高手帮忙

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧