none
SetWindowRgn所使用的CRgn对象是否需要调用DeleteObject释放 RRS feed

  • 问题

  • 这样的一段代码:

    CRgn rgnWnd;

    rgnWnd.CreateRectRgn(10, 10, 20, 20);

    SetWindowRgn((HRGN)rgnWnd, TRUE);

    //rgnWnd.DeleteObject();

    最后一行需要吗?

    MSDN对SetWindowRgn这样提到:

    After a successful call to SetWindowRgn, the operating system owns the region specified by the region handle hRgn. The operating system does not make a copy of the region, so do not make any further function calls with this region handle, and do not close this region handle.

    这个怎么处理呢?谢谢!


    2012年8月17日 17:03

答案

  • 你好,

    欢迎来到MSDN论坛。

    根据MSDN上的说明:In particular, do not delete this region handle. The system deletes the region handle when it no longer needed (参考链接) 。‘SetWindowRgn所使用的CRgn对象’句柄由于系统不会复制存档,因此只有在您确实确定不需要的时候才去删除。

    此致


    Elegentin Xie [MSFT]
    MSDN Community Support | Feedback to us


    2012年8月20日 10:31
    版主
  • MSDN里对CRgn::CreateRectRgn()函数有一段说明:

    When it has finished using a region created by CreateRectRgn, an application should use the CGDIObject::DeleteObject member function to remove the region.


    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.


    2012年8月22日 1:23
    版主

全部回复

  • 你好,

    欢迎来到MSDN论坛。

    根据MSDN上的说明:In particular, do not delete this region handle. The system deletes the region handle when it no longer needed (参考链接) 。‘SetWindowRgn所使用的CRgn对象’句柄由于系统不会复制存档,因此只有在您确实确定不需要的时候才去删除。

    此致


    Elegentin Xie [MSFT]
    MSDN Community Support | Feedback to us


    2012年8月20日 10:31
    版主
  • MSDN里对CRgn::CreateRectRgn()函数有一段说明:

    When it has finished using a region created by CreateRectRgn, an application should use the CGDIObject::DeleteObject member function to remove the region.


    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.


    2012年8月22日 1:23
    版主