Autoit_WinAPI_SetParent在孩子移动时,孩子消失

时间:2014-02-11 15:42:25

标签: autoit

父窗口由以下代码创建:

Opt("WinTitleMatchMode", 3)
Opt("GUIResizeMode", 1)
$GUI2 = GUICreate("Consoles", 1020, 600, 0, 0, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_SIZEBOX, $WS_CLIPSIBLINGS))
$hwnd00 = WinGetHandle("Consoles")
DisableButton($GUI2, $SC_CLOSE)

子窗口由以下代码创建:

Func StartServer($Type, $loc, $ID, $chosen, $Handle, $Name)
    $ID = Run("java " & $chosen & " -Xms512M -XX:MaxPermSize=128M -jar " & '"' & $loc & "\" & $Type & '"', $loc, 5)
    Sleep(300)
    If Not ProcessWait($ID, 5) = 0 Then
        WinSetTitle("C:\Windows\system32\java.exe", "", $Name)
        WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", $Name)
        $Handle = WinGetHandle($Name)
        Sleep(100)
        _WinAPI_SetWindowLong($Handle, $GWL_EXSTYLE, $WS_EX_MDICHILD)
        _WinAPI_SetParent($Handle, $GUI2)
        Sleep(100)
    Else
        MsgBox(-1, "ERROR", "Either the server file was not found or the server crashed because of and internal or a java error. Please check if the jar excists and look after java errors. The program will now exit.")
        ControlSend("Bungee", "", $hwnd0, 'end' & '{ENTER}')
        ControlSend("Server1", "", $hwnd1, "stop" & '{ENTER}')
        ControlSend("Server2", "", $hwnd2, "stop" & '{ENTER}')
        ControlSend("Server3", "", $hwnd3, "stop" & '{ENTER}')
        ControlSend("Server4", "", $hwnd4, "stop" & '{ENTER}')
        ControlSend("Server5", "", $hwnd5, "stop" & '{ENTER}')
        Exit
    EndIf
    Sleep(500)
EndFunc   ;==>StartServer

子窗口可以自由移动。如果它接近父GUI的边界,它会开始出现故障或完全消失 如何定义边框并防止子窗户出门?

1 个答案:

答案 0 :(得分:0)

如stackOverflow中的另一个问题here所述,您可以使用_MouseTrap来防止这种情况发生。