CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Location
    Riga, Latvia
    Posts
    128

    [RESOLVED] on regions (HRGN)

    Hello!

    I'm creating a window of arbitrary shape and have some questions about regions. ( I assume they could be generalized to objects. )

    Particularly:

    1)
    Code:
    {
                register HRGN hRgn = CreateRectRgn( tail, row, head, row+1 );
    
                CombineRgn( hRegion,
                            hRegion,
                            hRgn,
                            RGN_OR
                           );
    
                DeleteObject( hRgn ); // I do not use hRgn any more. Could(or should) I delete it?
    }
    2) May/Must/Should I delete a region passed to SetWindowRgn(), if I do not need it any more, but window still exists?

    3) I have a function HRGN build_region( HBITMAP hBitmap, COLORREF rgbTransparent ). It builds a region on basis of the bitmap, only non-rgbTransparent pixels form a region. I'm not a native English speaker. Are the names of identifiers correct?

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: on regions (HRGN)

    Quote Originally Posted by andrey_zh View Post
    2) May/Must/Should I delete a region passed to SetWindowRgn(), if I do not need it any more, but window still exists?
    Check API documentation on MSDN. It is clearly mentioned there.

  3. #3
    Join Date
    Mar 2009
    Location
    Riga, Latvia
    Posts
    128

    Re: on regions (HRGN)

    From MSDN:

    After a successful call to SetWindowRgn, the system owns the region specified by the region handle hRgn. The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not delete this region handle. The system deletes the region handle when it no longer needed.
    That's clear. Thanks!

    What about CombineRgn()? MSDN seems to be rather laconic on it:
    http://msdn.microsoft.com/en-us/libr...65(VS.85).aspx
    Last edited by andrey_zh; May 11th, 2009 at 04:12 PM.

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: on regions (HRGN)

    Quote Originally Posted by andrey_zh View Post
    What about CombineRgn()?
    After CombineRgn() returns, both source regions are no longer used (unless, of course, one of them is also used as a destination region).
    Also, I wouldn't use "register" with any modern compilers, unless you are 100% sure you can make that call (what to use registers for) better than compiler.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  5. #5
    Join Date
    Mar 2009
    Location
    Riga, Latvia
    Posts
    128

    Re: on regions (HRGN)

    Which tool could I use to determinate an "object leak"?
    What will be the result if occurs/after app closes on modern Windows ( NT-family )?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured