Sign in to follow this  
Followers 0
Uten

Group frame does not draw correctly

3 posts in this topic

I have been playing with a WindowInWindow sample @Holger posted a while back.

But when I add a GroupBox to my main window it does not behave as expected. Anyone know how to make it draw correctly? Any style combination to make it all work?

;RESOURCE: @Holger: http://www.autoitscript.com/forum/index.php?showtopic=19605&hl=GetWindowThreadProcessId
#include <GUIConstants.au3>
Opt("GUIResizeMode",$GUI_DOCKALL)
$hGUI = GUICreate("Test", 800, 600, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_SIZEBOX, $WS_SYSMENU, $WS_CLIPCHILDREN))
   Global $ctlNavigate = GUICtrlCreateGroup("Test", 5, 0, 90, 200)
   Global $btnPlay = GUICtrlCreateButton("Play", 10, 20, 40, 25)
   GUICtrlCreateGroup("", -99, -99, 1, 1)
   
EmbedApp(@WindowsDir & "\notepad.exe")

GUISetState(@SW_SHOW)

While 1
   $msg = GUIGetMsg()
   Switch $msg
      case $GUI_EVENT_CLOSE
            ExitLoop
      Case $GUI_EVENT_MINIMIZE
         ConsoleWrite ("$GUI_EVENT_MINIMIZE" & @LF)
      Case $GUI_EVENT_MAXIMIZE
         ConsoleWrite ("$GUI_EVENT_MINIMIZE" & @LF)
      Case $GUI_EVENT_RESTORE
         ConsoleWrite ("$GUI_EVENT_MINIMIZE" & @LF)
      Case $GUI_EVENT_RESIZED
         ConsoleWrite ("$GUI_EVENT_MINIMIZE" & @LF)
   EndSwitch
    
WEnd

Exit

Func EmbedApp($appPathName)
    $PID    = Run($appPathName, "", @SW_HIDE)
    $hWnd   = 0
    $stPID  = DllStructCreate("int")

    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

    $stPID = 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, "", 100, 0, 600, 400)
    EndIf
EndFunc;==>EmbedApp()

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  
Followers 0