Function Reference


Creates a GDI region from a GDI+ Region object

#include <GDIPlus.au3>
_GDIPlus_RegionGetHRgn ( $hRegion [, $hGraphics = 0] )


$hRegion Pointer to a Region object
$hGraphics [optional] Pointer to a Graphics object that contains the world and page transformations required to calculate the device coordinates of the region

Return Value

Success: a handle to a GDI region (HRGN) object.
Failure: 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetRegionHRgn in MSDN Library.


#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>


Func Example()
    Local $hGUI, $hPath, $hFamily, $tLayout, $aSize, $hRegion, $hRGN


    $hGUI = GUICreate("GDI+", 620, 100)
    GUISetBkColor(0x80) ;Set window background color to blue

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 85, 0) ;Add the outline of the string to the path

    $aSize = WinGetPos($hGUI) ;Get windowsize

    $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, 110, $aSize[3]) ;Create region from a rectangle
    _GDIPlus_RegionCombineRect($hRegion, $aSize[2] - 110, 0, 110, $aSize[3], 2) ;Combine rectangle_left AND rectangle_right
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 3) ;Combine rectangles XOR string

    $hRGN = _GDIPlus_RegionGetHRgn($hRegion, 0) ;Create GDI region from GDI+ region
    _WinAPI_SetWindowRgn($hGUI, $hRGN) ;Set window region

    ;Loop until user exits
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;Clean up resources
EndFunc   ;==>Example