﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » Stuck on a programming issue</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 04 Jun 2026 15:32:03 GMT</lastBuildDate><ttl>20</ttl><item><title>Stuck on a programming issue</title><link>http://forum.strataframe.net/FindPost5111.aspx</link><description>I'm&amp;nbsp;wondering if someone could help me out with a&amp;nbsp;programming problem I'm having. (VB.NET)&lt;/P&gt;&lt;P&gt;I am developing a 'outlook style' menu system which basically has a main menu bar, tool bar, navigation panel on the left side of the form and a mdi container consuming the rest of the form.&amp;nbsp; When the user clicks on one of the&amp;nbsp;navigation buttons I want to launch the associated program within the mdi container.(I'm not&amp;nbsp;committed to the mdi container, it's just something I was experimenting with and seemed to work okay).&amp;nbsp;I have it working fine with forms within the actual menu assembly but I need to launch external&amp;nbsp;applications, which could be VB6 or VB.NET exe's or .NET DLL's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have experimented with 'Process.Start', which works fine, however it opens up the application in a new &amp;#119;indow. I really want to run the applications within a panel in the menu application, similar to the outlook inbox etc... I assume it's possible.&lt;/P&gt;&lt;P&gt;I'm open to any suggestions as I am still in the experimental stage.&amp;nbsp;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tim Dol</description><pubDate>Thu, 07 Dec 2006 21:38:02 GMT</pubDate><dc:creator>Tim Dol</dc:creator></item><item><title>RE: Stuck on a programming issue</title><link>http://forum.strataframe.net/FindPost5112.aspx</link><description>This is basically what we have done in our medical software.&amp;nbsp; We still have a fair share of the medical software in a VFP EXE which is automatically launched and then seamlessly brought into the .NET MDI &amp;#119;indow.&amp;nbsp; This is just the first step in our case because we also needed the .NET menu to launch programs within the VFP EXE.&amp;nbsp; But that is for another post.&amp;nbsp; Here is what you need to do.&amp;nbsp; First launch the application:&lt;FONT color=#0000ff&gt; &lt;P&gt;&lt;/FONT&gt;[codesnippet]Dim loStart As New System.Diagnostics.ProcessStartInfo("c:\yourapplication.exe")&lt;BR&gt;Dim lnHandle As IntPtr&lt;BR&gt;&lt;BR&gt;loStart.WindowStyle = Diagnostics.ProcessWindowStyle.Normal&lt;BR&gt;loStart.WorkingDirectory = lcPath&lt;BR&gt;System.Diagnostics.Process.Start(loStart)[/codesnippet]&lt;/P&gt;&lt;P&gt;Next you are going to want to obtain the window handle to your launched application&lt;/P&gt;&lt;FONT color=#008000&gt;&lt;P&gt;&lt;/FONT&gt;[codesnippet]'-- Get the PS Window Handle&lt;BR&gt;lnHandle = System.Diagnostics.Process.GetProcessesByName("yourapplication")(0).MainWindowHandle&lt;BR&gt;'-- Stay here until we can get a handle on the application's main window&lt;BR&gt;Do While lnHandle.ToInt32() = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lnHandle = System.Diagnostics.Process.GetProcessesByName("yourapplication")(0).MainWindowHandle&lt;BR&gt;Loop[/codesnippet]&lt;/P&gt;&lt;P&gt;After a handle has been obtained, you will then need to force the main window handle of the application into the .NET MDI environment.&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;'-- Set the parent window to the MDI client&lt;BR&gt;WinAPI.SetParent(lnHandle, _MDI.Handle)&lt;/P&gt;&lt;P&gt;'-- Set the window styles&lt;BR&gt;WinAPI.SetWindowLong(lnHandle.ToInt32(), -16, WinAPI.WS_CLIPCHILDREN Or WinAPI.WS_CLIPSIBLINGS Or WinAPI.WS_MAXIMIZE Or WinAPI.WS_OVERLAPPED Or WinAPI.WS_SYSMENU Or WinAPI.WS_VISIBLE)&lt;/P&gt;&lt;P&gt;'-- Set the window position&lt;BR&gt;WinAPI.SetWindowPos(lnHandle.ToInt32(), 0, 0, 0, _MDI.Width, _MDI.Height, &amp;amp;H20)&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;The WINAPI reference above is just a shared class I created within the application that calls the Windows API methods.&amp;nbsp; It would look something like this:&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;/FONT&gt;Imports System.ComponentModel&lt;BR&gt;Imports System.Runtime.CompilerServices&lt;BR&gt;Imports System.Runtime.InteropServices&lt;/P&gt;&lt;P&gt;&lt;BR&gt;Public&amp;nbsp;NotInheritable Class&amp;nbsp;WinAPI&lt;BR&gt;&lt;BR&gt;Public Shared Const WS_OVERLAPPED As Integer = &amp;amp;H0&lt;BR&gt;Public Shared Const WS_POPUP As Integer = &amp;amp;H80000000&lt;BR&gt;Public Shared Const WS_CHILD As Integer = &amp;amp;H40000000&lt;BR&gt;Public Shared Const WS_MINIMIZE As Integer = &amp;amp;H20000000&lt;BR&gt;Public Shared Const WS_VISIBLE As Integer = &amp;amp;H10000000&lt;BR&gt;Public Shared Const WS_DISABLED As Integer = &amp;amp;H8000000&lt;BR&gt;Public Shared Const WS_CLIPSIBLINGS As Integer = &amp;amp;H4000000&lt;BR&gt;Public Shared Const WS_CLIPCHILDREN As Integer = &amp;amp;H2000000&lt;BR&gt;Public Shared Const WS_MAXIMIZE As Integer = &amp;amp;H1000000&lt;BR&gt;Public Shared Const WS_CAPTION As Integer = &amp;amp;HC00000&lt;BR&gt;Public Shared Const WS_BORDER As Integer = &amp;amp;H800000&lt;BR&gt;Public Shared Const WS_DLGFRAME As Integer = &amp;amp;H400000&lt;BR&gt;Public Shared Const WS_VSCROLL As Integer = &amp;amp;H200000&lt;BR&gt;Public Shared Const WS_HSCROLL As Integer = &amp;amp;H100000&lt;BR&gt;Public Shared Const WS_SYSMENU As Integer = &amp;amp;H80000&lt;BR&gt;Public Shared Const WS_THICKFRAME As Integer = &amp;amp;H40000&lt;BR&gt;Public Shared Const WS_GROUP As Integer = &amp;amp;H20000&lt;BR&gt;Public Shared Const WS_TABSTOP As Integer = &amp;amp;H10000&lt;BR&gt;Public Shared Const WS_EX_LAYERED As Integer = &amp;amp;H80000&lt;/P&gt;&lt;P&gt;&lt;BR&gt;&amp;lt;DllImport("user32.dll")&amp;gt; _&lt;BR&gt;Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr&lt;BR&gt;End Function&lt;/P&gt;&lt;P&gt;&amp;lt;DllImport("user32.dll")&amp;gt; _&lt;BR&gt;Public Shared Function SetWindowLong(ByVal WindowHandle As Integer, ByVal Index As Integer, ByVal Settings As Integer) As Integer&lt;BR&gt;End Function&lt;/P&gt;&lt;P&gt;&amp;lt;DllImport("user32.dll")&amp;gt; _&lt;BR&gt;Public Shared Function SetWindowPos(ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Integer) As Boolean&lt;BR&gt;End Function&lt;BR&gt;&lt;BR&gt;End Class&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;FONT size=+0&gt;&lt;FONT size=2&gt;You may not need the SetWindowLong and the SetWindowPos statements.&amp;nbsp; The SetParent is the API call that moves the parent window from being it's own main window handle into the .NET MDI.&amp;nbsp; The reference above to _MDI is an actual MDIClient control that is added to the main form rather than just setting the MDIContainer property.&amp;nbsp; This way you can change the backcolor of the control etc.&amp;nbsp; If you are just going to use the MDIContainer property, the you will just use the Handle property of the main form.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Thu, 07 Dec 2006 21:38:02 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>