TommyDDR Posted February 1, 2012 Share Posted February 1, 2012 (edited) Hi,I've created an UDF for use a kind of GUICtrlSetResizing for child windows, for the description, see http://autoitscript.fr/forum/viewtopic.php?f=21&t=9252expandcollapse popup#include <guiconstantsex.au3> #include <windowsconstants.au3> #include "_Resize.au3" Opt("GUIOnEventMode", 1) Global $Gui Global $GuiEnfant Global $Bouton Global $Etat = False $Gui = GUICreate("test", 300, 300, -1, -1, $WS_OVERLAPPEDWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE, "quit") $GuiEnfant = GUICreate("", 200, 200, 50, 50, $WS_CHILD, -1, $Gui) $Bouton = GUICtrlCreateButton("Start resize", 90, 170, 100, 20) GUICtrlSetOnEvent($Bouton, "BoutonClick") GUICtrlSetResizing($Bouton, BitOR($GUI_DOCKBOTTOM, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT)) GUISetBkColor(0xFF0000, $GuiEnfant) GUISetState(@SW_SHOW, $GuiEnfant) GUISetState(@SW_SHOW, $Gui) While(True) Sleep(10) WEnd Func BoutonClick() $Etat = Not $Etat If($Etat) Then _Resize_AddWindow($GuiEnfant, BitOR($GUI_DOCKRIGHT, $GUI_DOCKWIDTH)) GUICtrlSetData($Bouton, "Stop resize") Else _Resize_StopWindow($GuiEnfant) GUICtrlSetData($Bouton, "Start resize") EndIf EndFunc Func quit() Exit EndFuncexpandcollapse popup#include <guiconstantsex.au3> #include <winapi.au3> #include <windowsconstants.au3> #include "_GUIRegisterMsg.au3" #include "WindowsEx.au3" Global $Resize_Windows[1][11] Global Const $RESIZE_HWND = 0 Global Const $RESIZE_PARENTHWND = 1 Global Const $RESIZE_DOCK = 2 Global Const $RESIZE_POSX1 = 3 Global Const $RESIZE_POSX2 = 4 Global Const $RESIZE_POSY1 = 5 Global Const $RESIZE_POSY2 = 6 Global Const $RESIZE_WIDTH = 7 Global Const $RESIZE_HEIGHT = 8 Global Const $RESIZE_WWIDTH = 9 Global Const $RESIZE_WHEIGHT = 10 ; #FUNCTION# ==================================================================================================== ; Name...........: _Resize_AddWindow ; Description....: Équivalent GUICtrlSetResizing pour une fenêtre $WM_CHILD ; Syntax.........: _Resize_AddWindow($hWnd, $Dock) ; ; Parameters.....: $hWnd - Handle de la fenêtre enfant ; $Dock - Toutes les veleurs $GUI_DOCKXXXX ; ; Return values..: Aucune ; ; Author.........: TommyDDR - http://tom-barthelemy.fr ; Modified.......: ; Remarks........: ; ; Related........: ; Link...........: ; Example........: ; =============================================================================================================== Func _Resize_AddWindow($hWnd, $Dock) Local $hParent = _WinAPI_GetParent($hWnd) If($hParent = 0) Then Return SetError(1, 0, False) EndIf Local $Indice = UBound($Resize_Windows, 1)-1 If($Indice = 0) Then _GUIRegisterMsg($WM_SIZE, "__Func_WM_SIZE") EndIf Local $ClientRelativePos = GetClientRelativePos($hWnd) Local $ParentPos = GetClientPos($hParent) $Resize_Windows[$Indice][$RESIZE_HWND] = $hWnd $Resize_Windows[$Indice][$RESIZE_PARENTHWND] = $hParent $Resize_Windows[$Indice][$RESIZE_DOCK] = $Dock $Resize_Windows[$Indice][$RESIZE_WWIDTH] = $ParentPos[2] $Resize_Windows[$Indice][$RESIZE_WHEIGHT] = $ParentPos[3] $Resize_Windows[$Indice][$RESIZE_WIDTH] = $ClientRelativePos[2] $Resize_Windows[$Indice][$RESIZE_HEIGHT] = $ClientRelativePos[3] If(BitAND($Dock, $GUI_DOCKLEFT)) Then $Resize_Windows[$Indice][$RESIZE_POSX1] = $ClientRelativePos[0] Else $Resize_Windows[$Indice][$RESIZE_POSX1] = $ClientRelativePos[0]/$Resize_Windows[$Indice][$RESIZE_WWIDTH] EndIf If(BitAND($Dock, $GUI_DOCKRIGHT)) Then $Resize_Windows[$Indice][$RESIZE_POSX2] = $Resize_Windows[$Indice][$RESIZE_WWIDTH]-($ClientRelativePos[0]+$Resize_Windows[$Indice][$RESIZE_WIDTH]) Else $Resize_Windows[$Indice][$RESIZE_POSX2] = ($Resize_Windows[$Indice][$RESIZE_WWIDTH]-($ClientRelativePos[0]+$Resize_Windows[$Indice][$RESIZE_WIDTH]))/$Resize_Windows[$Indice][$RESIZE_WWIDTH] EndIf If(BitAND($Dock, $GUI_DOCKTOP)) Then $Resize_Windows[$Indice][$RESIZE_POSY1] = $ClientRelativePos[1] Else $Resize_Windows[$Indice][$RESIZE_POSY1] = $ClientRelativePos[1]/$Resize_Windows[$Indice][$RESIZE_WHEIGHT] EndIf If(BitAND($Dock, $GUI_DOCKBOTTOM)) Then $Resize_Windows[$Indice][$RESIZE_POSY2] = $Resize_Windows[$Indice][$RESIZE_WHEIGHT]-($ClientRelativePos[1]+$Resize_Windows[$Indice][$RESIZE_HEIGHT]) Else $Resize_Windows[$Indice][$RESIZE_POSY2] = ($Resize_Windows[$Indice][$RESIZE_WHEIGHT]-($ClientRelativePos[1]+$Resize_Windows[$Indice][$RESIZE_HEIGHT]))/$Resize_Windows[$Indice][$RESIZE_WHEIGHT] EndIf If(Not(BitAND($Dock, $GUI_DOCKWIDTH) And Not(BitAND($Dock, $GUI_DOCKLEFT) And BitAND($Dock, $GUI_DOCKRIGHT)))) Then $Resize_Windows[$Indice][$RESIZE_WWIDTH] = 0 EndIf If(Not(BitAND($Dock, $GUI_DOCKHEIGHT) And Not(BitAND($Dock, $GUI_DOCKHEIGHT) And BitAND($Dock, $GUI_DOCKHEIGHT)))) Then $Resize_Windows[$Indice][$RESIZE_WWIDTH] = 0 EndIf ReDim $Resize_Windows[UBound($Resize_Windows, 1)+1][UBound($Resize_Windows, 2)] EndFunc ; #FUNCTION# ==================================================================================================== ; Name...........: _Resize_StopWindow ; Description....: Stop un redimensionnement ; Syntax.........: _Resize_StopWindow($hWnd) ; ; Parameters.....: $hWnd - Handle de la fenêtre enfant ; ; Return values..: Aucune ; ; Author.........: TommyDDR - http://tom-barthelemy.fr ; Modified.......: ; Remarks........: ; ; Related........: ; Link...........: ; Example........: ; =============================================================================================================== Func _Resize_StopWindow($hWnd) Local $Cible = _Resize_VerifHwnd($hWnd) If($Cible >= 0) Then For $j = $Cible To UBound($Resize_Windows, 1)-2 For $i = $Cible To UBound($Resize_Windows, 2)-2 $Resize_Windows[$j][$i] = $Resize_Windows[$j+1][$i] Next Next ReDim $Resize_Windows[UBound($Resize_Windows, 1)-1][UBound($Resize_Windows, 2)] If(UBound($Resize_Windows, 1) = 1) Then _GUIUnRegisterMsg($WM_SIZE, "__Func_WM_SIZE") EndIf EndIf EndFunc Func __Func_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) Local $loWord = _WinAPI_LoWord($ilParam) Local $hiWord = _WinAPI_HiWord($ilParam) If($loWord <> 0 And $hiWord <> 0) Then For $i = 0 To UBound($Resize_Windows, 1)-2 If($hWnd = $Resize_Windows[$i][$RESIZE_PARENTHWND]) Then Local $ClientRelativePos = GetClientRelativePos($Resize_Windows[$i][$RESIZE_HWND]) Local $ParentPos = GetClientPos($Resize_Windows[$i][$RESIZE_PARENTHWND]) Local $NewPos[4] Local $Dock = $Resize_Windows[$i][$RESIZE_DOCK] If(BitAND($Dock, $GUI_DOCKLEFT)) Then $NewPos[0] = $Resize_Windows[$i][$RESIZE_POSX1] Else $NewPos[0] = $ParentPos[2]*$Resize_Windows[$i][$RESIZE_POSX1] EndIf If(BitAND($Dock, $GUI_DOCKRIGHT)) Then $NewPos[2] = $ParentPos[2]-$Resize_Windows[$i][$RESIZE_POSX2] Else $NewPos[2] = ($ParentPos[2]-($ParentPos[2]*$Resize_Windows[$i][$RESIZE_POSX2])) EndIf If(BitAND($Dock, $GUI_DOCKTOP)) Then $NewPos[1] = $Resize_Windows[$i][$RESIZE_POSY1] Else $NewPos[1] = $ParentPos[3]*$Resize_Windows[$i][$RESIZE_POSY1] EndIf If(BitAND($Dock, $GUI_DOCKBOTTOM)) Then $NewPos[3] = $ParentPos[3]-$Resize_Windows[$i][$RESIZE_POSY2] Else $NewPos[3] = ($ParentPos[3]-($ParentPos[3]*$Resize_Windows[$i][$RESIZE_POSY2])) EndIf If(BitAND($Dock, $GUI_DOCKWIDTH)) Then If(BitAND($Dock, $GUI_DOCKRIGHT)) Then $NewPos[0] = $NewPos[2]-$Resize_Windows[$i][$RESIZE_WIDTH] Else $NewPos[2] = $NewPos[0]+$Resize_Windows[$i][$RESIZE_WIDTH] EndIf EndIf If(BitAND($Dock, $GUI_DOCKHEIGHT)) Then If(BitAND($Dock, $GUI_DOCKBOTTOM)) Then $NewPos[1] = $NewPos[3]-$Resize_Windows[$i][$RESIZE_HEIGHT] Else $NewPos[3] = $NewPos[1]+$Resize_Windows[$i][$RESIZE_HEIGHT] EndIf EndIf WinMove($Resize_Windows[$i][$RESIZE_HWND], "", $NewPos[0], $NewPos[1], $NewPos[2]-$NewPos[0], $NewPos[3]-$NewPos[1]) EndIf Next EndIf Return $GUI_RUNDEFMSG EndFunc Func _Resize_VerifHwnd($hWnd) Local $Cible = -1 For $i = 0 To UBound($Resize_Windows, 1)-2 If($Resize_Windows[$i][$RESIZE_HWND] = $hWnd) Then $Cible = $i ExitLoop EndIf Next Return $Cible EndFunc Edited February 6, 2012 by TommyDDR _GUIRegisterMsg (Register more than 1 time the same Msg), _Resize_Window (GUICtrlSetResizing for children windows), _GUICtrlSetOnHover (Link a function when mouse go on, left, clic down, clic up, on a control), _InputHeure (Create an input for hour contain), _GUICtrlCalendar (Make a complete calendar), _GUICtrlCreateGraphic3D (Create a 3D graph), _ArrayEx.au3 (Array management), _GUIXViewEx.au3 (List/Tree View management). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now