#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
;#Include <APIConstants.au3>
#Include <WinAPIEx.au3>
$R = 32
$Rn2 = $R*2
$thick = 16
$leigh = 88
$point = 0
$gui = GUICreate("Test Windows regions", 450+$leigh, 150,-1,-1, $WS_POPUP)
$btn_default = GUICtrlCreateButton("Default region", 100, 30, 150)
$btn_buble = GUICtrlCreateButton("Buble region ", 100, 60, 150)
$btn_exit = GUICtrlCreateButton("Exit", 100, 90, 150)
GUISetState(@SW_SHOW)
$pos = WinGetPos($gui)
Global $width = $pos[2]-$leigh
Global $height = $pos[3]
Local $aPoint[15][2] = [[0, $R],[$R, $R],[$R, 0],[$width - $R, 0],[$width - $R, $R],[$width, $R], _
[$width, $height/2-$thick],[$width+$leigh, $point],[$width, $height/2+$thick], _
[$width,$height - $R],[$width - $R, $height - $R],[$width - $R, $height],[$R, $height],[$R, $height - $R],[0, $height - $R]]
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
ExitLoop
Case $msg = $btn_default
$rgn = _WinAPI_CreateRectRgn(0, 0, $pos[2], $pos[3])
_WinAPI_SetWindowRgn($gui, $rgn)
Case $msg = $btn_buble
$rgn1 = _WinAPI_CreatePolygonRgn($aPoint)
$rgn2 = _WinAPI_CreateRoundRectRgn(0, 0, $Rn2, $Rn2, $Rn2, $Rn2)
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
$rgn2 = _WinAPI_CreateRoundRectRgn($width-$Rn2, 0, $width, $Rn2, $Rn2, $Rn2)
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
$rgn2 = _WinAPI_CreateRoundRectRgn($width-$Rn2, $height-$Rn2, $width, $height, $Rn2, $Rn2)
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
$rgn2 = _WinAPI_CreateRoundRectRgn(0, $height-$Rn2, $Rn2, $height, $Rn2, $Rn2)
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
_WinAPI_DeleteObject($rgn2)
_WinAPI_SetWindowRgn($gui, $rgn1)
EndSelect
WEnd