Eman Resu
07-04-2002, 11:01 AM
Hey all,
Does anyone know if it is possible to load an external application (such as a dos prompt, or notepad.exe) as a child form to an MDI parent?
Agent
07-04-2002, 11:19 AM
If it was possible, you would get the window's handle and use
SetParent to make the window a child to the MDI form.
But no, I don't know if it is possible.
Agent
07-04-2002, 11:38 AM
Yes, it is possible. I opened notepad (no file) and added the
following code to my MDI form:
' This example is assuming you have notepad
' open with the title being "Untitled - Notepad".
Option Explicit
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Sub MDIForm_Load()
Dim lngNotepad As Long
' Get notepad's window handle...
lngNotepad = FindWindow(vbNullString, "Untitled - Notepad")
' Place it inside the MDI form...
SetParent lngNotepad, Me.hWnd
Me.WindowState = vbMaximized
End Sub
It placed Notepad in my MDI form. I had to maximize to see it
though. It was in the lower-right corner and the scrollbars don't
scroll. :(
You could use the SetWindowPos function to make sure
the new child window is viewable to the user. :)
Eman Resu
07-04-2002, 11:58 AM
Originally posted by Agent
Yes, it is possible. I opened notepad (no file) and added the
following code to my MDI form:
' This example is assuming you have notepad
' open with the title being "Untitled - Notepad".
Option Explicit
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Sub MDIForm_Load()
Dim lngNotepad As Long
' Get notepad's window handle...
lngNotepad = FindWindow(vbNullString, "Untitled - Notepad")
' Place it inside the MDI form...
SetParent lngNotepad, Me.hWnd
Me.WindowState = vbMaximized
End Sub
It placed Notepad in my MDI form. I had to maximize to see it
though. It was in the lower-right corner and the scrollbars don't
scroll. :(
You could use the SetWindowPos function to make sure
the new child window is viewable to the user. :)
Thanks man, that helps alot. I got it to work also. the operation is a little messy but I think I can clean it up with the setwindowpos like you said. Also the minimize seems to send it to lala-land.
I'll figure it out... thanks again!