CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Posts
    2

    Running Independent App

    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.



  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Running Independent App

    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
    [email protected]

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Running Independent App

    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






  4. #4
    Join Date
    Aug 2001
    Posts
    2

    Re: Running Independent App

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured