Results 1 to 9 of 9

Thread: Outside applications inside MDI

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    14

    Outside applications inside MDI

    I'm thinking via some API calls, or maybe .NET has it, you can link in actual executables inside an MDI form. The reason I'm wanting to do this is the MDI is a suite of applications for the people in an office. I want to be able to develop applications totally seperate from the MDI form, yet I want them to be able to launch the application from within the MDI form. It would have to be a true child of the form, not just a shell out. Can anyone point me in the right direction on this? I'm an experience programmer, but not so much with the Win32 API. Thanks.

  2. #2

    Re: Outside applications inside MDI

    Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

    this routine offers a solution i believe, let me know if this turns out to be somthing really difficult, and i will try too. the only thing i've ever used it for is to set my program into the toolbar of AOL without subclassing, but i believe it can work for what you're trying

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Outside applications inside MDI

    It should work. Since you are starting the other application you can get it's handle, and you already have the handle (hwnd) of your form, so that API should do exactly what you want.


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Outside applications inside MDI

    There is a problem with SetParent.

    SetParent almost works if we set MDIClient as it's parent. (use FindWindow to get the handle of MDIClient).

    But the form does not send any WM_PARENTNOTIFY to MDIClient. For that reason, when we move/maximize our form, it doesn't acts as a normal MDIChild.

    I have tried setting both WS_CHILD and WS_EX_MDICHILD, but no effect.

    May be if we can send WM_PARENTNOTIFY to MDIClient, it will work.

    (Sorry I have no idea how to use WM_PARENTNOTIFY, also I haven't done any API programming in .NET, all I'm saying is from VB6's point of view. Most probably .NET will have same problem. )

    Here is a link : Start another program inside your MDI form
    Last edited by iPrank; Jan 20th, 2006 at 09:57 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Outside applications inside MDI

    In response to your PM, iPrank, I just fudged it.

    Essentially, i did something like this:

    VB Code:
    1. Private Sub MDIForm_Resize()
    2.     Timer1.Enabled = False
    3.     Timer1.Enabled = True
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7.     If Form1.WindowState = vbMaximized
    8.         LockWindowUpdate MDIForm1.hWnd
    9.             Form1.WindowState = vbNormal
    10.             Form1.WindowState = vbMaximized
    11.         LockWindowUpdate False
    12.     End If
    13.     Timer1.Enabled = False
    14. End Sub
    The exact details are lost admist a pile of sublassing for other reasons.

  6. #6
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Outside applications inside MDI

    Thanks.
    For the dragging problem on the new 'MDIChild', I found something like this in EE.
    But it still doesn't act like 'normal MDIChild'. Maximize Form2 and the titlebar doesn't merge with MDI.
    VB Code:
    1. ' Needs 2 forms. Form1 is MDIChild and startup form.
    2. ' Place one button in Form1
    3.  
    4. ' Inside Form1
    5. Option Explicit
    6. Private Declare Function SetParent Lib "user32" ( _
    7.     ByVal hWndChild As Long, _
    8.     ByVal hWndNewParent As Long) As Long
    9. Private Declare Function SetWindowLong Lib "user32" _
    10.     Alias "SetWindowLongA" ( _
    11.         ByVal hwnd As Long, _
    12.         ByVal nIndex As Long, _
    13.         ByVal dwNewLong As Long) As Long
    14. Private Declare Function GetWindowLong Lib "user32" _
    15.     Alias "GetWindowLongA" ( _
    16.         ByVal hwnd As Long, _
    17.         ByVal nIndex As Long) As Long
    18. Private Const GWL_STYLE = (-16)
    19. Private Const WS_CHILD = &H40000000
    20.  
    21. Private Sub Command1_Click()
    22.     Dim m_oldstyle As Long
    23.     Load Form2
    24.     SetParent Form2.hwnd, MDIForm1.hwnd
    25.     m_oldstyle = GetWindowLong(Form2.hwnd, GWL_STYLE)
    26.     Call SetWindowLong(Form2.hwnd, GWL_STYLE, (m_oldstyle Or WS_CHILD))
    27.     Form2.Show vbModeless
    28.     Form2.Move 0, 0
    29. End Sub
    Last edited by iPrank; Apr 4th, 2006 at 10:08 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Outside applications inside MDI

    What do you mean by the move problem?

    If you use the code you've just posted you'll find that the form you've made a child form will never be able to get focus.

    The way I was using SetParent was to create a sort of Desktop style environment within the MDIForm, so that style of Maximizing was perfect for me.

  8. #8
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Outside applications inside MDI

    Oh. Sorry. I didn't edited the EE code correctly. We need to setparent it to MDIClient. Not MDIForm1.

    BTW, here is the google cache. It was for a slightly different problem though.

    As I said in my earlier post, I have found in some sites/forums at that time which said we can set a form to a perfect MDIChild by sending WM_PARENTNOTIFY to the 'MDIClient' window. But didn't found any code. (Sorry I don't remember the links now)

    For this thread's problem, I don't know how to send WM_CREATE to the MDIClient, as the external window is already created.

    (But if we want to create our own toolbox like window, then may be it will work)
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  9. #9
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Outside applications inside MDI

    This reminded me of a CodeProject article I had bookmarked a long while ago but never went back to, so I havent actually tested it out... its for .NET (since you mentioned it at the beginning)...

    "ByPass difficult Automation and add applications "as is" in your .NET application"
    http://www.codeproject.com/vb/net/ByPassAutomation.asp

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