armoros Posted June 2, 2012 Share Posted June 2, 2012 (edited) Hello my friends i have this script that runs a cmd in a framed (thank you Melba) GUI . Everything is ok but just want to ask why when $hGUI_Child = $Embed_hWnd is OK [ the cmd is locked in the upper frame and when $hGUI_Child = $Embed_hWnd = _GetHWndByPID($iCmd_PID) is not locked in the upper frame Maybe this is stupid qusetion for the most of you but it stacked on my brain so i want an explanation if possible complete script expandcollapse popup#include #include #include #include "GUIFrame.au3" Global $Init_Dir = "C:\" $Form1 = GUICreate("Form1", 700, 644, 193, 34, BitOr($Gui_SS_DEFAULT_GUI,$WS_CLIPCHILDREN)) 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, 668, 200) WinSetState($Embed_hWnd, "", @SW_SHOWMINIMIZED) $iFrame = _GUIFrame_Create($Form1, 1) _GUIFrame_SetMin($iFrame, 250, 250) GUISetState(@SW_SHOW,$Form1) DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $Embed_hWnd, "hwnd", $Form1) $hTopFrame = _GUIFrame_GetHandle($iFrame, 1) _GUIFrame_Switch($iFrame, 1) GUICtrlCreateLabel("", 0, 0, 0, 0) $hGUI_Child = $Embed_hWnd _WinAPI_SetParent($hGUI_Child, $hTopFrame) GUISetState(@SW_SHOW) While 1 Sleep(100) If WinActive($Form1) 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 Thank you people Edited June 2, 2012 by armoros [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2012 Moderators Share Posted June 2, 2012 armoros,"Some clarity on this" would be welcome! Can you please explain in more detail what you are talking about because I have not the foggiest idea other than it has to do with the child GUI. Perhaps 2 scripts showing the difference you speak of would be of use in helping us understand. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
armoros Posted June 2, 2012 Author Share Posted June 2, 2012 (edited) Thank you Melba23OK.. in the above script in witch i use your script/method i want to call my cmd.exe and wanted to be embedded in the upper frame only, as you guide me how to do it with a child Gui. Everything works ok.But based in your i change thisGUICtrlCreateLabel("", 0, 0, 0, 0) $hGUI_Child = GUICreate("GUI_Child", 100, 100, 50, 50, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetBkColor(0xFF0000) _WinAPI_SetParent($hGUI_Child, $hTopFrame) GUISetState(@SW_SHOW)With this so to be able to embed the cmd.exe$hGUI_Child = $Embed_hWnd _WinAPI_SetParent($hGUI_Child, $hTopFrame) GUISetState(@SW_SHOW)And the reason why i bother you all is why when i use the above part of script is okand when i use this instead the cmd.exe is not embedded$hGUI_Child = $Embed_hWnd = _GetHWndByPID($iCmd_PID) _WinAPI_SetParent($hGUI_Child, $hTopFrame) GUISetState(@SW_SHOW)What is the difference between this [ $hGUI_Child = $Embed_hWnd ] and this [ $hGUI_Child = $Embed_hWnd = _GetHWndByPID($iCmd_PID) ]I know i am pain on the a$$ Thank you again Melba23 Edited June 2, 2012 by armoros [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 2, 2012 Moderators Share Posted June 2, 2012 armoros,Because a double assignment like this:$hGUI_Child = $Embed_hWnd = _GetHWndByPID($iCmd_PID)is not correct syntax. Have you checked what $hGUI_Child contains? It is certainly not what you think Just use a single assignment and it should work properly: $hGUI_Child = _GetHWndByPID($iCmd_PID) _WinAPI_SetParent($hGUI_Child, $hTopFrame)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
armoros Posted June 2, 2012 Author Share Posted June 2, 2012 Thank you Melba23 this clears a lot to me. I want bother you no more...at least for today [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