Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

CombineRgn (gdi32)
 
.
Summary

C# Signature:

[DllImport("gdi32.dll")]
static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1,
   IntPtr hrgnSrc2, int fnCombineMode);

VB.Net Signature:

<DllImport("gdi32.dll")>
Private Shared Function CombineRgn(ByVal hrgnDest As IntPtr,
   ByVal hrgnSrc1 As IntPtr, ByVal hrgnSrc2 As IntPtr,
   ByVal fnCombineMode As Integer) As Integer
End Function
    <DllImport("gdi32.dll")>
    Private Shared Function CombineRgn(ByVal hrgnDest As IntPtr, ByVal hrgnSrc1 As IntPtr,
    ByVal hrgnSrc2 As IntPtr, ByVal fnCombineMode As Integer) As Integer
    End Function

User-Defined Types:

public enum CombineRgnStyles:int
{
    RGN_AND         =1,
    RGN_OR          =2,
    RGN_XOR         =3,
    RGN_DIFF        =4,
    RGN_COPY        =5,
    RGN_MIN         =RGN_AND,
    RGN_MAX         =RGN_COPY
}

Return Values:

public const int ERROR = 0;
public const int NULLREGION = 1;
public const int SIMPLEREGION = 2;
public const int COMPLEXREGION = 3;

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

// This Sample xors the two different shapes and redraw the complete window by the resultant shapes

    [DllImport("gdi32.dll")]
    public static extern IntPtr CreateEllipticRgn(int nLeftRect, int nTopRect,int nRightRect, int nBottomRect);

    [DllImport("user32.dll")]
    static extern System.UInt16  SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw);

    [DllImport("gdi32.dll")]
    static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1,IntPtr hrgnSrc2, int fnCombineMode);

// And the code lies here

InitializeComponent();

            IntPtr r1 = CreateEllipticRgn(0,0,300,300);
            IntPtr r2 = CreateEllipticRgn(100,100,300,300);
            IntPtr r3= CreateEllipticRgn(100,100,300,300);
            CombineRgn(r3,r1,r2,0);
            SetWindowRgn(this.Handle,r3,true);

// by - S.C.

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
CombineRgn on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions