armoros Posted May 5, 2012 Share Posted May 5, 2012 Autoiters how to embed a gui in another gui ? For example i want to embed this gui that has already an embeded cmd on another gui. i want this because when i maximize the cmd it overlaps other controls-buttons that i may have in the first gui. Thank you in advance #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $Init_Dir = "C:\" $Main_GUI = GUICreate("Embedded CMD", 800, 600, 10, 10) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUIRegisterMsg(0xF, "WM_PAINT") $iCmd_PID = Run(@ComSpec & " /k CD " & $Init_Dir, "", @SW_HIDE) ProcessWait($iCmd_PID) $Embed_hWnd = _GetHWndByPID($iCmd_PID) WinMove($Embed_hWnd, "", -2, -23, 800, 500) WinSetState($Embed_hWnd, "", @SW_SHOWMINIMIZED) GUISetState(@SW_SHOW, $Main_GUI) DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $Embed_hWnd, "hwnd", $Main_GUI) While 1 Sleep(100) If WinActive($Main_GUI) Then WinActivate($Embed_hWnd) WEnd Func Quit() ProcessClose($iCmd_PID) Exit EndFunc Func _GetHWndByPID($iPID) Local $aWinList = WinList() For $i = 1 To UBound($aWinList)-1 If WinGetProcess($aWinList[$i][1]) = $iPID Then Return $aWinList[$i][1] Next Return 0 EndFunc Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "ptr", 0, "int", 0) EndFunc [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
armoros Posted May 5, 2012 Author Share Posted May 5, 2012 Well i found something to work on.. expandcollapse popup#include <GUIConstants.au3> ;Globals Global $View = 0 ;GUI SETUP $hGUI = GUICreate("Parent", 620, 500, -1, -1) ;- Main GUI Window $okbutton = GUICtrlCreateButton("OK", 500, 450, 75) $POS = WinGetPos($hGUI) $Child = GUICreate("Child", 425, 440, 0, 30, "", -1, $hGUI) GUISetState(@SW_SHOW, $hGUI) DllCall("user32.dll", "int", "SetParent", "hwnd", $Child, "hwnd", $hGUI) GUISetState(@SW_HIDE, $Child) ;;Main loop While 1 $Msg = GUIGetMsg() Switch $Msg Case $okbutton Child() Case $GUI_EVENT_CLOSE If WinActive($Child) Then GUISetState(@SW_HIDE, $Child) $View = 0 Else Exit EndIf EndSwitch WEnd ;;Child funtion Func Child() If $View = 0 Then WinSetState($Child, "", @SW_SHOW) GUISwitch($Child) GUISetState() $View = 1 Else $View = 0 WinSetState($Child, "", @SW_HIDE) GUISwitch($hGUI) EndIf EndFunc [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
martin Posted May 5, 2012 Share Posted May 5, 2012 You will need to add some styles I expect. In your second post, if the child window is dragged to be partly over the button and then you move the mouse cursor over the button then the button will be drawn over the child and when you move the child it will have a bit of a button drawn on it. So you might want to do this $okbutton = GUICtrlCreateButton("OK", 500, 450, 75,22,BitOr($Gui_SS_DEFAULT_BUTTON, $WS_CLIPSIBLINGS)) With your first post, the child window might not be drawn correctly when the parent is redrawn, so you might want to do this $Main_GUI = GUICreate("Embedded CMD", 800, 600, 10, 10,BitOr($Gui_SS_DEFAULT_GUI,$WS_CLIPCHILDREN)) 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 More sharing options...
armoros Posted May 5, 2012 Author Share Posted May 5, 2012 I appreciate your help martin you are very correct... Thank you.. [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now