|
-
Jan 18th, 2006, 01:39 PM
#1
Thread Starter
New Member
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.
-
Jan 18th, 2006, 07:25 PM
#2
Lively Member
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
-
Jan 20th, 2006, 06:13 AM
#3
-
Jan 20th, 2006, 09:53 AM
#4
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.
-
Apr 4th, 2006, 09:51 AM
#5
Re: Outside applications inside MDI
In response to your PM, iPrank, I just fudged it.
Essentially, i did something like this:
VB Code:
Private Sub MDIForm_Resize()
Timer1.Enabled = False
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Form1.WindowState = vbMaximized
LockWindowUpdate MDIForm1.hWnd
Form1.WindowState = vbNormal
Form1.WindowState = vbMaximized
LockWindowUpdate False
End If
Timer1.Enabled = False
End Sub
The exact details are lost admist a pile of sublassing for other reasons.
-
Apr 4th, 2006, 09:56 AM
#6
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:
' Needs 2 forms. Form1 is MDIChild and startup form.
' Place one button in Form1
' Inside Form1
Option Explicit
Private Declare Function SetParent Lib "user32" ( _
ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CHILD = &H40000000
Private Sub Command1_Click()
Dim m_oldstyle As Long
Load Form2
SetParent Form2.hwnd, MDIForm1.hwnd
m_oldstyle = GetWindowLong(Form2.hwnd, GWL_STYLE)
Call SetWindowLong(Form2.hwnd, GWL_STYLE, (m_oldstyle Or WS_CHILD))
Form2.Show vbModeless
Form2.Move 0, 0
End Sub
Last edited by iPrank; Apr 4th, 2006 at 10:08 AM.
-
Apr 4th, 2006, 10:04 AM
#7
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.
Last edited by bushmobile; Apr 4th, 2006 at 10:07 AM.
-
Apr 4th, 2006, 10:21 AM
#8
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)
-
Apr 4th, 2006, 03:13 PM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|