Results 1 to 8 of 8

Thread: guru question?

  1. #1

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222
    This has been sitting here all day (different post though) with no answer, so perhaps a guru can answer?

    I have a MDI application that will be launching another application (a helper wizard that I wrote).

    Is there any way where I can get app # 2 to be a MDI child of app # 1 (MDI app)?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    I think this was discussed a few days ago, I believe the solution was to get the handle of the window opened, then use the SetParent API to make it like a child form...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    For example, I just did notepad, but you can use your own form, just supply caption name.

    Code:
    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()
        SetParent FindWindow(vbNullString, "Untitled - Notepad"), hWnd
    End Sub
    Last edited by Lethal; Apr 4th, 2001 at 03:55 PM.

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    What a team, me and you, Lethal
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Yep, we chew up the questions and spit them out..(Spit)...

  6. #6

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222
    Thanks guys

  7. #7

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222


    Ok - I got it to work pulling the outside app into the MDI form - here is the new problem I am having though:

    If the new Child exe/window is still open when the MDI form is unloaded, the Child exe continues running in the background.

    I have tried using different API calls (CloseWindow, DestroyWindow, etc) but nothing seems to do it. Perhaps I am just calling them wrong or something?

    Any help?

  8. #8

    Thread Starter
    Addicted Member finn0013's Avatar
    Join Date
    Jan 2001
    Location
    Charleston, SC
    Posts
    222

    Nevermind

    Nevermind;

    I found an old post that Lethal had answered using the SendMessage API call...

    I tried this too, but evidently was passing the wrong window handle.

    Code:
    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 Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
                    ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    
    Private Const WM_CLOSE = &H10
    
    
    
    Public theID As Long
    
    
    
    Private Sub MDIForm_Load()
    
        Form1.Show
        
        Shell "Wizard.exe", vbNormalFocus
        
        theID = FindWindow(vbNullString, "Wizard")
        
        SetParent theID, hwnd
        
    End Sub
    
    
    
    
    Private Sub MDIForm_Unload(Cancel As Integer)
        Dim frm As Form
    
        SendMessage theID, WM_CLOSE, 0, 0
    
        
        For Each frm In Forms
            Unload frm
        Next
    End Sub

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