Click to See Complete Forum and Search --> : Running Independent App
tcorrigan
August 27th, 2001, 11:43 AM
How can I start up an independent executable (Notepad, say) and force it to "live" (look like it's executing) inside a window on my VB form (e.g., inside a BIG textbox)? I've tried using CreateProcess specifying a position and size but only the positioning seems to work. Also I want to be able to move my VB form around and have the child executable move with it.
Cakkie
August 28th, 2001, 02:02 AM
If you manage to retrieve the hWnd, you could use the SetParent API to change the programs parent. This allows you to change it to some MDI window, or any other container that has a hWnd, like a picturebox.
I can't really remember, but there is a way to get the hWnd from a process, and there is a way to get the process from the value you get from the Shell function, so it is possible, just havent done this before.
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
DSJ
August 29th, 2001, 10:17 AM
Try this...
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 Command1_Click()
Dim hWnd as Long
Shell "Notepad.exe", vbNormalFocus
hWnd = FindWindow("Notepad", "Untitled - Notepad")
If hWnd <> 0 then
SetParent hWnd, me.hWnd
End If
End Sub
tcorrigan
August 30th, 2001, 06:04 PM
This kind of works. The Notepad clone I am using (MetaPad) works fine, but other (VB) exe's seem to ignore the SetParent request completely. I'm going to continue looking into this. Thanks for your input tho.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.