Jump to content

[solved] Some school on this ?


Recommended Posts

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

#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 by armoros

[font="verdana, geneva, sans-serif"] [/font]

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you Melba23

OK.. 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 this

GUICtrlCreateLabel("", 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 ok

and 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 by armoros

[font="verdana, geneva, sans-serif"] [/font]

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...