创建一个多边形区域.
#Include <WinAPIEx.au3>
_WinAPI_CreatePolygonRgn ( Const ByRef $aPoint [, $iStart [, $iEnd [, $iMode]]] )
$aPoint | 包含多边形的顶点逻辑单位的二维数组: ([x1, y1], [x2, y2], ... [xN, yN]). 假定多边形是封闭的.每个顶点可以只需指定一次. |
$iStart | [可选参数] 多边形开始点的数组索引. |
$iEnd | [可选参数] 多边形结束点的数组索引. |
$iMode | [可选参数] 填充模式.参数可以是以下值之一: $ALTERNATE --- 交替填充奇数和偶数之间的扫描线. $WINDING --- 填充任何曲折值非零的地区 |
成功: | 返回多边形区域的句柄. |
失败: | 返回 0,并设置@error标志为非 0 值. |
在MSDN中搜索
#Include <APIConstants.au3>
#include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $hForm, $Button, $hRgn
Global $aPoint[10][2] = [[0, 180], [190, 180], [250, 0], [308, 180], [500, 180], [344, 294], [404, 475], [250, 362], [94, 475], [154, 294]]
; 创建 GUI
$hForm = GUICreate('MyGUI', 500, 475, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$Button = GUICtrlCreateButton('Exit', 215, 255, 70, 23)
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUISetBkColor(0xAA0000)
; Create polygonal region and set it to the window
$hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_SetWindowRgn($hForm, $hRgn, 0)
GUISetState()
Do
Until GUIGetMsg() = $Button
Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST