ผมมีโค้ดตัวอย่างแต่เอามาใช้งานกับ ของผมไม่ถูกแหะๆ
#include
#include
#include
Global $htit = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
Global $frame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)
$gui = GUICreate("Test Windows regions", 350, 210)
$btn_default = GUICtrlCreateButton("Default", 100, 30, 150)
$btn_transparent = GUICtrlCreateButton("Cut tool", 100, 60, 150)
$btn_exit = GUICtrlCreateButton("Exit", 100, 150, 150)
GUISetState(@SW_SHOW)
$pos = WinGetPos($gui)
Global $width = $pos[2]
Global $height = $pos[3]
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
ExitLoop
Case $msg = $btn_default
$rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height)
_WinAPI_SetWindowRgn($gui, $rgn)
Case $msg = $btn_transparent
_GuiHole($gui, 0, 0, 360, 20)
EndSelect
WEnd
Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh)
Local $outer_rgn, $inner_rgn, $combined_rgn
$outer_rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height)
$inner_rgn = _WinAPI_CreateRectRgn($i_x, $i_y, $i_x + $i_sizew, $i_y + $i_sizeh)
$combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
_WinAPI_CombineRgn($combined_rgn, $outer_rgn, $inner_rgn, $RGN_DIFF)
_WinAPI_DeleteObject($outer_rgn)
_WinAPI_DeleteObject($inner_rgn)
_AddCtrlRegion($combined_rgn, $btn_default)
_AddCtrlRegion($combined_rgn, $btn_transparent)
_AddCtrlRegion($combined_rgn, $btn_exit)
_WinAPI_SetWindowRgn($h_win, $combined_rgn)
EndFunc
Func _AddCtrlRegion($full_rgn, $ctrl_id)
Local $ctrl_pos, $ctrl_rgn
$ctrl_pos = ControlGetPos($gui, "", $ctrl_id)
$ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos[0] + $frame, $ctrl_pos[1] + $htit + $frame, _
$ctrl_pos[0] + $ctrl_pos[2] + $frame, $ctrl_pos[1] + $ctrl_pos[3] + $htit + $frame)
_WinAPI_CombineRgn($full_rgn, $full_rgn, $ctrl_rgn, $RGN_OR)
_WinAPI_DeleteObject($ctrl_rgn)
EndFunc