用于调用其他 exe 充当 MDI 子窗体的 VB.NET 示例代码?是否可以?
好的,这是场景。
1.我创建了一个项目,其中有 1 个名为 form1.exe 的表单
2.我还创建了一个具有 1 个 MDI 表单的项目。
在此 MDI 表格中。我想调用“form1.exe”,其行为类似于 MDI 表单子项。 我尝试过使用这段代码:
Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndParent As IntPtr) As IntPtr
End Function
Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewToolStripButton.Click, NewWindowToolStripMenuItem.Click
Dim myProcess As Process = New Process()
myProcess.StartInfo.FileName = "D:\tesVB.exe"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
myProcess.Start()
myProcess.WaitForInputIdle()
SetParent(myProcess.MainWindowHandle, Me.Handle)
myProcess.WaitForExit()
End Sub
上面的代码可以工作,但是新的子表单(form1.exe)的行为并不像它应该的那样!当我最大化或最小化它时。它的行为不像 MDI 子窗体。
谁能给我另一个更好的示例代码?谢谢之前。
ok here is the scenario.
1. i've create a project that has 1 form named form1.exe
2. i've also create a project that has 1 MDI form.
in this MDI Form. i'would like to call "form1.exe" act like / behave like MDI Form child.
i've tried using this code :
Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndParent As IntPtr) As IntPtr
End Function
Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewToolStripButton.Click, NewWindowToolStripMenuItem.Click
Dim myProcess As Process = New Process()
myProcess.StartInfo.FileName = "D:\tesVB.exe"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
myProcess.Start()
myProcess.WaitForInputIdle()
SetParent(myProcess.MainWindowHandle, Me.Handle)
myProcess.WaitForExit()
End Sub
Above code is worked but that new child form(form1.exe) doesn't act like it should be! When i maximized or minimized it. it don't act like MDI Child Form.
Can anyone give me another better example code ? thx before.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哈哈哈……我自己发现的。希望这个解决方案对其他人有好处。
hahaha.... found it my self. hope this solution would be good for others.
运行时错误
Runtime error