Jump to content
Sign in to follow this  
NELyon

Problem setting window into GUI

Recommended Posts

I'm working on a manager for the Adcall PC-to-Telephone program. I'm implementing a custom phone book, and many other features.

I'm using a script Holger posted a while back to make the Adcall's window child to my GUI. The only problem is Sometimes the windows will display just fine, but other times... I will let the pictures do the talking.

GOOD:

BAD:

Heres the script i'm using currently:

#include <GUIConstants.au3>
$file = FileOpenDialog("Please Find Adcalls Dialer","","Executable Files (*.exe)")

$hGUI = GUICreate("Test", 800, 600, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN))

$PID    = Run($file, "", @SW_HIDE)
$hWnd    = 0
$stPID    = DllStructCreate("int")
ApplyWinChild()

GUISetState()


While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then ExitLoop
WEnd
    

Func ApplyWinChild()
Do
    $WinList = WinList()
    For $i = 1 To $WinList[0][0]
        If $WinList[$i][0] <> "" Then
            DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $WinList[$i][1], "ptr", DllStructGetPtr($stPID))
            If DllStructGetData($stPID, 1) = $PID Then
                $hWnd = $WinList[$i][1]
                ExitLoop
            EndIf
        EndIf
    Next
    Sleep(100)
Until $hWnd <> 0

If $hWnd <> 0 Then
    $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20)
    $nExStyle = $nExStyle[0]
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOr($nExStyle, $WS_EX_MDICHILD))
    DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI)    
    WinSetState($hWnd, "", @SW_SHOW)
    WinMove($hWnd, "", 0, 0, 600, 700)
EndIf
EndFunc

Anyone know whats going on here?

Share this post


Link to post
Share on other sites

So... can anyone help me? If i take out the Do...Until $hWnd <>0 then it displays right, but it doesen't become a child window.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...