Results 1 to 3 of 3

Thread: opening an app within VB

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281
    Hi,

    Is there any way I can open an App into a form of my VB.exe? At present I open the App by clicking a command button. The App is in a fixed location.

    I use this code:

    Private Sub CmdAnimations_Click()
    Dim shellProgram As String
    Dim res
    shellProgram = App.Path & "\Part 1\cycling.exe"
    res = Shell(shellProgram, vbNormalFocus)
    End Sub

    I was hoping that, instead of opening the App and having it running outside my VB program, I could have it running somewhere in my form. Is this possible?

    Any help would be greatly appreciated!

  2. #2
    Lively Member
    Join Date
    Jun 1999
    Location
    East Anglia, England
    Posts
    73

    Hope this helps

    Hello,
    Here is some code that might help you, personnaly I think if you're gonna do this sort of thing then you should load the program into a MDI program instead of an SDI program.

    Code:
    Option Explicit
    
    '//API CALLS NEEDED
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    
    '//CONSTANT NEEDED TO SHOW NOTEPAD
    Const SW_SHOW = 5
    
    '//THE HWND FOR NOTEPAD
    Dim lNotepad As Long
    
    Private Sub Command1_Click() '//OPENS NOTEPAD INTO YOUR FORM
        
        Shell "c:\windows\notepad.exe", vbHide '//SHELLS A HIDDEN NOTEPAD
        lNotepad = FindWindow("Notepad", vbNullString) '//GETS THE HWND OF NOTEPAD
        SetParent lNotepad, Me.hwnd '//SETS NOTEPADS PARENT FROM THE DESKTOP TO YOUR APP
        ShowWindow lNotepad, SW_SHOW '//SHOWS NOTEPAD
    End Sub
    
    Private Sub Command2_Click() '// RETURNS NOTEPAD BACK TO THE DESKTOP
        Dim lDesktop As Long
        
        
        lDesktop = GetDesktopWindow '//GETS THE HWND OF THE DESKTOP
        SetParent lNotepad, lDesktop '//SETS NOTEPADS PARENT BACK TO THE DESKTOP
    End Sub

  3. #3
    Member
    Join Date
    May 2000
    Posts
    41

    why not just use an OLE box????

    it would be alot simpler doing it that way.
    Here I doeh again

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