Jump to content

Embed external application as child


ws6vert
 Share

Recommended Posts

Might be a noob question, but is there anyway to embed an external application as a child inside a parent GUI?

I have tried many variations of the GUICreate function to do this, but with no success.

Here is my last attempt:

#include<guiconstants.au3>
#include<WindowsConstants.au3>


GUICreate("CJ Embedder",800,600,-1,-1)
GUISetState(@SW_SHOW)
ShellExecuteWait("C:\Program Files\Coverjuke\Coverjuke.exe")
$CJ_Title = WinGetTitle("[CLASS:FREEGLUT]")
$CJ_Handle = WinGetHandle($CJ_Title)
$gui_pos = WinGetPos("CJ Embedder")
$CJ_child = GUICreate($gui_pos[2]+8,$gui_pos[3]+36,$gui_pos[0]-8,$gui_pos[1]-36,$WS_CHILD,$WS_EX_MDICHILD,$CJ_Handle)


While 1
    $nMSG = GUIGetMsg() 
    Switch $nMSG
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd
Link to comment
Share on other sites

Might be a noob question, but is there anyway to embed an external application as a child inside a parent GUI?

I have tried many variations of the GUICreate function to do this, but with no success.

Here is my last attempt:

#include<guiconstants.au3>
 #include<WindowsConstants.au3>
 
 
 GUICreate("CJ Embedder",800,600,-1,-1)
 GUISetState(@SW_SHOW)
 ShellExecuteWait("C:\Program Files\Coverjuke\Coverjuke.exe")
 $CJ_Title = WinGetTitle("[CLASS:FREEGLUT]")
 $CJ_Handle = WinGetHandle($CJ_Title)
 $gui_pos = WinGetPos("CJ Embedder")
 $CJ_child = GUICreate($gui_pos[2]+8,$gui_pos[3]+36,$gui_pos[0]-8,$gui_pos[1]-36,$WS_CHILD,$WS_EX_MDICHILD,$CJ_Handle)
 
 
 While 1
     $nMSG = GUIGetMsg()    
     Switch $nMSG
     Case $GUI_EVENT_CLOSE
         Exit
     EndSwitch
 WEnd
I think you need something like this.

#include<guiconstants.au3>
#include<WindowsConstants.au3>


$hGui1 = GUICreate("CJ Embedder",800,600,-1,-1)
GUISetState(@SW_SHOW)
ShellExecuteWait("C:\Program Files\Coverjuke\Coverjuke.exe")

;allow time for window to be created
;might be better to have winwait
sleep(1000)
$CJ_Title = WinGetTitle("[CLASS:FREEGLUT]")
$CJ_Handle = WinGetHandle($CJ_Title)

WinMove($CJ_Handle, "", 0, 0, 600,600)
;Sleep(100)
$origParent = DllCall("user32.dll", "int", "SetParent", "hwnd", $CJ_Handle, "hwnd",$hGui1)
;$gui_pos = WinGetPos("CJ Embedder")
;$CJ_child = GUICreate($gui_pos[2]+8,$gui_pos[3]+36,$gui_pos[0]-8,$gui_pos[1]-36,$WS_CHILD,$WS_EX_MDICHILD,$CJ_Handle)

While 1
    $nMSG = GUIGetMsg() 
    Switch $nMSG
    Case $GUI_EVENT_CLOSE
       ;set child back To Original parent or it will be destroyed with ouyr window
        DllCall("user32.dll", "int", "SetParent", "hwnd", $CJ_Handle, "hwnd", $origParent[0])
        Exit
    EndSwitch
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

First of all, thanks for the support with my first issue, I now have a new problem I am trying to sort out.

I have created a Gui winddow called "CJ_Embedder" that containes a child gui called "CJ_container." In this container window, I want to maximize the external application that start using the run command. The problem I am having is when I call winsetstate() to maximize the external application within the container window, it maximizes but does not fill the container window, instead it maximizes and only shows about 1/4 of the window within the contianer window. I think the problem lies in the coordinates of the application window in reference to the container. I have posted the code, any suggestions?

My last attempt:

;Attempt to create a window container that will hold coverjuke

#include<guiconstants.au3>
#include<WindowsConstants.au3>
#include<WinAPI.au3>
#include<constants.au3>

Opt("Winsearchchildren",1)

$CJ_Fudge_Up = 0;
$CJ_Fudge_Over = 0;


$CJ_Gui = GUICreate("CJ Embedder",800,480,-1,-1);Main GUI
GUISetBkColor(0x000000,$CJ_Gui)
GUISetState(@SW_SHOW,$CJ_Gui)

;Determine Border width and height for optimum contianer placement
$CJ_Gui_pos = WinGetPos("CJ Embedder"); array for x,y,width,height
$Gui_borderW = 3
$Gui_TitlebarH = 29

;Create Container Gui
$Container_Gui = GUICreate("CJ_container",$CJ_Gui_pos[2]/1.2,$CJ_Gui_pos[3]/1.2,0,0,$WS_CHILD,"",$CJ_Gui)
GUISetState(@SW_SHOW,$Container_Gui)
DllCall("user32.dll", "int", "SetParent", "hwnd", $Container_Gui, "hwnd",$CJ_Gui)
sleep(100)

;Determine if Coverjuke is open and if not, open it
if Not WinExists("[CLASS:FREEGLUT]") Then
    Run("C:\Program Files\Coverjuke\Coverjuke.exe")
    WinWait("[CLASS:FREEGLUT]")
EndIf

;Make Coverjuke maximize within the Container
$CJ_Handle = WinGetHandle("[CLASS:FREEGLUT]")
$CJ_Style = BitOR($WS_POPUP,$WS_VISIBLE,$WS_CLIPSIBLINGS)
DllCall("user32.dll", "int", "SetParent", "hwnd", $CJ_Handle, "hwnd",$Container_Gui)
_WinAPI_SetWindowLong($CJ_Handle,$GWL_STYLE,$CJ_Style)
$CJ_Flags = BitOR($SWP_NOZORDER,$SWP_SHOWWINDOW)
_WinAPI_SetWindowPos($CJ_Handle,$HWND_BOTTOM,0,0,500,300,$CJ_Flags)
WinSetState("[CLASS:FREEGLUT]","",@SW_MAXIMIZE)


While 1
    $nMSG = GUIGetMsg() 
    Switch $nMSG
    Case $GUI_EVENT_CLOSE
        WinKill("[CLASS:FREEGLUT]")
        Exit
    EndSwitch
WEnd
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...