Voilà mon code actuel et je ne trouve pas d'où vient l'érreur...
En éffet pour fermer mes fenêtres (Parent et Child) je dois cliquer sur la croix de Child alors qu'il devrait-être sur Parent
Je souhaiterai aussi mettre un fond noir à Child pour changer de la couleur par défaut je pense que vous comprendrez l'utilisation de ce code
Merci d'avance
► Afficher le texte
Code : Tout sélectionner
#include "Include\AnyGui.au3"
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
AutoItSetOption("WinTitleMatchMode", 4)
AutoItSetOption("WinSearchChildren", 1)
AutoItSetOption("WinWaitDelay", 0)
Global $aUtil_MinMax[4]
$ParentTitle = 'Parent' ; Parent
$ChildTitle = 'Child' ; Child
$ShowHideWindowCaption = 'unset' ; unset = Hide Window Caption ; set = Show Window Caption
;InitMinMax("800","600",@DesktopWidth,@DesktopHeight) ;InitMinMax("320","200","800","600"); Cool Héééé ;-)
$ParentHandle = GUICreate($ParentTitle, 320, 200, 320, 200, BitOR($WS_SYSMENU + $WS_SIZEBOX + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX + $WS_Caption,$WS_CLIPCHILDREN))
$ChildHandle = GUICreate($ChildTitle, 160, 120)
;ShowHideWindowCaption()
_SetParent($ChildHandle, $ParentHandle) ; Fonction: Bind "Child" dans "Parent"
;_SetParent($ParentHandle, $ChildHandle) ; Fonction: Bind "Parent" dans "Child"
;_SetParent($ChildHandle, 0) ; Fonction: UnBind "Child" de "Parent"
WinSetState($ChildHandle, "", @SW_SHOW)
WinSetState($ParentHandle, "", @SW_SHOW)
;GUISetState(@SW_SHOW, $ChildHandle)
;GUISetState(@SW_SHOW, $ParentHandle)
;GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SIZING, "WM_SIZING")
#forceref $hWnd, $iMsg, $wParam, $lParam
WM_SIZING()
While 1
_GUIGetMsg()
Sleep(1)
WEnd
Func _GUIGetMsg()
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then _Exit()
If $msg = $GUI_EVENT_MAXIMIZE Or $GUI_EVENT_RESTORE Then WM_SIZING()
EndFunc ;==>_GUIGetMsg()
Func _SetParent($id_child, $h_parent) ; Fonction: Binder
If Not IsHWnd($h_parent) Then $h_parent = HWnd($h_parent)
If Not IsHWnd($id_child) Then $id_child = GUICtrlGetHandle($id_child)
If DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $id_child, "hwnd", $h_parent) <> 0 Then
Return 1
Else
seterror(1)
Return 0
EndIf
EndFunc ;==>_SetParent
Func ShowHideWindowCaption()
$xh = _GuiTarget($ChildHandle,1)
$Style = $WS_Caption
$ExStyle = -1
$result = _TargetStyle($ShowHideWindowCaption,1,$Style,$ExStyle,$xh) ; Show Caption Window
EndFunc ;==>ShowHideWindowCaption
Func InitMinMax($x0,$y0,$x1,$y1)
Local Const $WM_GETMINMAXINFO = 0x24 ; $WinGetHandle ; 0x24 ; Fixe la valeur de $WM_GETMINMAXINFO avec la valeur 0x24 (valeur hexadécimale attribuée de 36)
$aUtil_MinMax[0]=$x0
$aUtil_MinMax[1]=$y0
$aUtil_MinMax[2]=$x1
$aUtil_MinMax[3]=$y1
GUIRegisterMsg($WM_GETMINMAXINFO,'MY_WM_GETMINMAXINFO') ; Lance la fonction GUIRegisterMsg() pour la valeur $WM_GETMINMAXINFO et la re-dirige vers la fonction MY_WM_GETMINMAXINFO().
EndFunc ;==>InitMinMax
Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
Local $minmaxinfo = DllStructCreate('int;int;int;int;int;int;int;int;int;int',$lParam)
DllStructSetData($minmaxinfo,7,$aUtil_MinMax[0]) ; min X
DllStructSetData($minmaxinfo,8,$aUtil_MinMax[1]) ; min Y
DllStructSetData($minmaxinfo,9,$aUtil_MinMax[2]) ; max X
DllStructSetData($minmaxinfo,10,$aUtil_MinMax[3]); max Y
Return $GUI_RUNDEFMSG ; Renvois la valeur $GUI_RUNDEFMSG à la commande qui à lancé la fonction (c'est à dire GUIRegisterMsg()). Cette valeur est une valeur fixe qui est déterminée dans GUIConstantsEx.au3
EndFunc ;==>MY_WM_GETMINMAXINFO
Func WM_SIZING()
$SRC = -8
$ParentSize = WinGetClientSize($ParentHandle)
WinMove($ChildHandle, "", $SRC, $SRC, $ParentSize[0]-$SRC*2, $ParentSize[1]-$SRC*2)
EndFunc ;==>WM_SIZING
Func _Exit()
WinClose($ChildHandle, "")
Exit
EndFunc ;==>Exit



