Function Reference


_WinAPI_CreatePolygonRgn

Creates a polygonal region

#include <WinAPIGdi.au3>
_WinAPI_CreatePolygonRgn ( Const ByRef $aPoint [, $iStart = 0 [, $iEnd = -1 [, $iMode = 1]]] )

Parameters

$aPoint The 2D array ([x1, y1], [x2, y2], ... [xN, yN]) that contains the vertices of the polygon in logical units.
The polygon is presumed closed. Each vertex can be specified only once.
$iStart [optional] The index of array to start creating at.
$iEnd [optional] The index of array to stop creating at.
$iMode [optional] The fill mode used to determine which pixels are in the region. This parameter can be one of the following values:
    $ALTERNATE (Default)
    $WINDING

Return Value

Success: The handle to the region.
Failure: 0.

Remarks

When you no longer need the HRGN object, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreatePolygonRgn in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 500, 475, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Local $idButton = GUICtrlCreateButton('Exit', 215, 255, 70, 23)
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUISetBkColor(0xAA0000)

; Create polygonal region and set it to the window
Local $aPoint[10][2] = [[0, 180], [190, 180], [250, 0], [308, 180], [500, 180], [344, 294], [404, 475], [250, 362], [94, 475], [154, 294]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_SetWindowRgn($hForm, $hRgn, 0)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $idButton

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam, $lParam

        Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST