回复 16# vuivui
#include <Array.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hGui0 = GUICreate('', 400, 300)
$Label1 = GUICtrlCreateLabel('Label1', 10, 10, 380, 280, $WS_BORDER)
GUICtrlSetBkColor(-1, 0xC0DCC0)
$hLabel1 = GUICtrlGetHandle($Label1)
$hRgn1 = _WinAPI_CreateRectRgn(0, 0, 400, 300)
$Label2 = GUICtrlCreateLabel('Label2', 250, 50, 100, 30, 0x01 + 0x0200 + $WS_BORDER)
_SetCtrlRegion($hRgn1, $Label2)
$Button1 = GUICtrlCreateButton('Button1', 150, 120, 100, 30)
_SetCtrlRegion($hRgn1, $Button1)
$Checkbox1 = GUICtrlCreateCheckbox('Checkbox1', 150, 190, 100, 30)
_SetCtrlRegion($hRgn1, $Checkbox1)
_WinAPI_SetWindowRgn($hLabel1, $hRgn1)
$sText = GUICtrlCreateLabel('1', 150, 240, 100, 30, 0x01 + 0x0200)
GUICtrlSetFont(-1, 10, 400, 0, '微软雅黑')
GUICtrlSetBkColor(-1, 0xC0DCC0)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Label1
GUICtrlSetData($sText, 'Label1')
Case $Label2
GUICtrlSetData($sText, 'Label2')
Case $Button1
GUICtrlSetData($sText, 'Button1')
Case $Checkbox1
GUICtrlSetData($sText, 'Checkbox1')
EndSwitch
WEnd
Func _SetCtrlRegion($hFullRgn, $iCtrlID)
Local $aCtrlPos, $hCtrlRgn
$aCtrlPos = ControlGetPos($hGui0, '', $iCtrlID)
If Not @error Then
$hCtrlRgn = _WinAPI_CreateRectRgn($aCtrlPos[0] - 10, $aCtrlPos[1] - 10, ($aCtrlPos[0] + $aCtrlPos[2]) - 10, ($aCtrlPos[1] + $aCtrlPos[3]) - 10)
_WinAPI_CombineRgn($hFullRgn, $hFullRgn, $hCtrlRgn, $RGN_XOR)
_WinAPI_DeleteObject($hCtrlRgn)
EndIf
EndFunc ;==>_SetCtrlRegion
这是另一种方法,不过这种方法也有弊端。 |