函数参考


_WinAPI_SelectClipRgn

选取区域作为当前设备场景的剪切区域

#Include <WinAPIEx.au3>
_WinAPI_SelectClipRgn ( $hDC, $hRgn )

参数

$hDC 设备场景句柄
$hRgn 选定的区域句柄. 设置为0则移除设备场景的剪切区域.

返回值

成功: 返回指定剪切区域复杂性的值. 可为下列值:
$COMPLEXREGION - 多个矩形
$NULLREGION - 空区
$SIMPLEREGION - 单一矩形
失败: 返回 0设置@error 非0

注意/说明

只有一个选定区域的副本可用. 区域自身可被任意数量场景选定或被删除.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global Const $STM_SETIMAGE = 0x0172
Global Const $STM_GETIMAGE = 0x0173

Global $hForm, $Pic, $hPic, $hObj, $hRgn, $hBitmap, $hDC, $hMemDC, $hMemSv
Global $aVertex[3][3] = [[140, -50, 0xFFFF00], [-50, 244, 0x00F0FF], [331, 244, 0xFF00FF]]

; 创建 GUI
$hForm = GUICreate('MyGUI', 281, 281)
$Pic = GUICtrlCreatePic('', 0, 0, 281, 281)
$hPic = GUICtrlGetHandle($Pic)

; 创建位图
$hDC = _WinAPI_GetDC($hPic)
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 281, 281, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
$hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
$hRgn = _WinAPI_CreateEllipticRgn(_WinAPI_CreateRectEx(40, 40, 201, 201))
_WinAPI_SelectClipRgn($hMemDC, $hRgn)
_WinAPI_GradientFill($hMemDC, $aVertex)
_WinAPI_DeleteObject($hRgn)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; 设置位图到控件
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState()

Do
Until GUIGetMsg() = -3