D�finit une r�gion de fen�tre
#include <WinAPIGdi.au3>
_WinAPI_SetWindowRgn ( $hWnd, $hRgn [, $bRedraw = True] )
$hWnd | Handle de la fen�tre dont la r�gion est � d�finir. |
$hRgn | Handle d'une r�gion. La fonction d�finit la r�gion de la fen�tre � cette r�gion. |
$bRedraw | [optionnel] Sp�cifie si le syst�me doit redessiner la fen�tre apr�s la d�finition de la r�gion de fen�tre. |
Succ�s: | Retourne True |
�chec: | Retourne False |
La r�gion de la fen�tre d�termine la zone � l'int�rieur de la fen�tre, o� le syst�me permet le dessin.
Le syst�me n'affiche pas une partie quelconque d'une fen�tre qui se trouve en dehors de la r�gion de la fen�tre
Lorsque cette fonction est appel�e, le syst�me envoie les messages WM_WINDOWPOSCHANGING et WM_WINDOWPOSCHANGED � la fen�tre.
Les coordonn�es de la r�gion de fen�tre d'une fen�tre sont relatives au coin sup�rieur gauche de la fen�tre, pas � la zone cliente de la fen�tre.
Apr�s un appel r�ussi � SetWindowRgn, le syst�me devient propri�taire de la r�gion indiqu�e par le handle de la r�gion $hRgn.
Le syst�me ne fait pas de copie de la r�gion. Ainsi, vous ne devriez pas faire d'autres appels de fonction avec ce handle de r�gion.
En particulier, ne supprimez pas ce handle de r�gion. Le syst�me supprime le handle de r�gion quand il n'en a plus besoin.
_WinAPI_CombineRgn, _WinAPI_CreateRectRgn, _WinAPI_CreateRoundRectRgn, _WinAPI_GetWindowRgn
Consultez SetWindowRgn dans la librairie MSDN.
#include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> ; Obtient la hauteur de titre de la fen�tre et la largeur de cadre de fen�tre - peut �tre diff�rent suivant que les th�mes XP sont ON/OFF Global $g_iHtit = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Global $g_iFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) Global $g_hGui = GUICreate("Test Windows regions", 350, 210) Local $id_Default = GUICtrlCreateButton("Default region", 100, 30, 150) Local $id_Round = GUICtrlCreateButton("Round region", 100, 60, 150) Local $id_Buble = GUICtrlCreateButton("Buble region ", 100, 90, 150) Local $id_Transparent = GUICtrlCreateButton("Transparent region", 100, 120, 150) Local $id_Exit = GUICtrlCreateButton("Exit", 100, 150, 150) GUISetState(@SW_SHOW) Local $aPos = WinGetPos($g_hGui) ; Obtient la taille enti�re de la fen�tre (pas la taille de la zone client d�finie dans GUICreate) Global $g_iWidth = $aPos[2] Global $g_iHeight = $aPos[3] Local $hRgn, $iMsg = GUIGetMsg() While $iMsg <> $GUI_EVENT_CLOSE And $iMsg <> $id_Exit Select Case $iMsg = $id_Default $hRgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight) _WinAPI_SetWindowRgn($g_hGui, $hRgn) Case $iMsg = $id_Round $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth, $g_iHeight, $g_iWidth / 3, $g_iHeight / 3) _WinAPI_SetWindowRgn($g_hGui, $hRgn) Case $iMsg = $id_Buble Local $hRgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth / 2, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; sup�rieur gauche Local $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, 0, $g_iWidth, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; en haut � droite _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR) _WinAPI_DeleteObject($hRgn2) $hRgn2 = _WinAPI_CreateRoundRectRgn(0, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; inf�rieur gauche _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR) _WinAPI_DeleteObject($hRgn2) $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, $g_iHeight / 2, $g_iWidth, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; en bas � droite _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR) _WinAPI_DeleteObject($hRgn2) $hRgn2 = _WinAPI_CreateRoundRectRgn(10, 10, $g_iWidth - 10, $g_iHeight - 10, $g_iWidth, $g_iHeight) ; milieu _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR) _WinAPI_DeleteObject($hRgn2) _WinAPI_SetWindowRgn($g_hGui, $hRgn1) Case $iMsg = $id_Transparent _GuiHole($g_hGui, 40, 40, 260, 170) EndSelect $iMsg = GUIGetMsg() WEnd ; D�finit la zone int�rieure transparente, mais ajoute des contr�les Func _GuiHole($hWin, $iX, $iY, $iSizeW, $iSizeH) Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight) $hInner_rgn = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iSizeW, $iY + $iSizeH) $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($hOuter_rgn) _WinAPI_DeleteObject($hInner_rgn) _AddCtrlRegion($hCombined_rgn, $id_Default) _AddCtrlRegion($hCombined_rgn, $id_Round) _AddCtrlRegion($hCombined_rgn, $id_Buble) _AddCtrlRegion($hCombined_rgn, $id_Transparent) _AddCtrlRegion($hCombined_rgn, $id_Exit) _WinAPI_SetWindowRgn($hWin, $hCombined_rgn) EndFunc ;==>_GuiHole ; Ajoute une zone de contr�le � la r�gion donn�e ; en respectant aussi les tailles du titre/cadre de la fen�tre Func _AddCtrlRegion($hFull_rgn, $idCtrl) Local $aCtrl_pos, $hCtrl_rgn $aCtrl_pos = ControlGetPos($g_hGui, "", $idCtrl) $hCtrl_rgn = _WinAPI_CreateRectRgn($aCtrl_pos[0] + $g_iFrame, $aCtrl_pos[1] + $g_iHtit + $g_iFrame, _ $aCtrl_pos[0] + $aCtrl_pos[2] + $g_iFrame, $aCtrl_pos[1] + $aCtrl_pos[3] + $g_iHtit + $g_iFrame) _WinAPI_CombineRgn($hFull_rgn, $hFull_rgn, $hCtrl_rgn, $RGN_OR) _WinAPI_DeleteObject($hCtrl_rgn) EndFunc ;==>_AddCtrlRegion