Function Reference


_WinAPI_SelectClipRgn

Selects a region as the current clipping region for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SelectClipRgn ( $hDC, $hRgn )

Parameters

$hDC Handle to the device context.
$hRgn Handle to the region to be selected. To remove a device-context's clipping region, set this parameter to 0.

Return Value

Success: The value that specifies the new clipping region's complexity; it can be one of the following values.
$COMPLEXREGION
$NULLREGION
$SIMPLEREGION
Failure: 0.

Remarks

Only a copy of the selected region is used. The region itself can be selected for any number of other device
contexts or it can be deleted.

See Also

Search SelectClipRgn in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIMisc.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 281, 281)
Local $idPic = GUICtrlCreatePic('', 0, 0, 281, 281)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 281, 281, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
Local $hRgn = _WinAPI_CreateEllipticRgn(_WinAPI_CreateRectEx(40, 40, 201, 201))
_WinAPI_SelectClipRgn($hMemDC, $hRgn)
Local $aVertex[3][3] = [[140, -50, 0xFFFF00], [-50, 244, 0x00F0FF], [331, 244, 0xFF00FF]]
_WinAPI_GradientFill($hMemDC, $aVertex)
_WinAPI_DeleteObject($hRgn)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE