直接添加一個(gè)MID父窗體或在已有窗體的屬性中找到IsMDIContainer屬性,然后設(shè)置為True,然后創(chuàng)建第二個(gè)窗體 ,需要加載子窗體的時(shí)候:
創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計(jì)制作、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的臺安網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
Dim NewMDIChild As New Form2
NewMDIChild.MdiParent = Me
NewMDIChild.Show()
Public?Shared?Sub?CheckMDIChildForm(ByVal?MDIForm?As?Windows.Forms.Form,?ByVal?MDIChildForm?As?Windows.Forms.Form,?ByVal?MDIChildFormName?As?String)
If?MDIForm.MdiChildren.Length??1?Then
'如果沒有任何一個(gè)MDI子窗體,則創(chuàng)該MDI子窗體的窗體實(shí)例
Dim?MDIChildFrm?As?Windows.Forms.Form?=?MDIChildForm?'?定義MDI子窗體
MDIChildFrm.MdiParent?=?MDIForm?'指定父窗體
MDIChildFrm.Show()?'打開窗體
Exit?Sub
Else
Dim?x?As?Integer
Dim?frmyn?As?Boolean
For?x?=?0?To?(MDIForm.MdiChildren.Length)?-?1
Dim?tempChild?As?Windows.Forms.Form?=?CType(MDIForm.MdiChildren(x),?Windows.Forms.Form)
If?tempChild.Name?=?MDIChildFormName?Then
'檢測到有該MDI子窗體,設(shè)為激活?并退出循環(huán)
frmyn?=?True
tempChild.BringToFront()
Exit?For
Else
frmyn?=?False
End?If
Next
If?Not?frmyn?Then
'在打開的窗體中沒檢測到則新建
Dim?MDIChildFrm?As?Windows.Forms.Form?=?MDIChildForm?'?定義MDI子窗體
MDIChildFrm.MdiParent?=?MDIForm?'指定父窗體
MDIChildFrm.Show()?'打開窗體
End?If
End?If
End?Sub
VB.net 加載窗體 form2.show() 卸載窗體 me.close()加載窗體和VB沒啥區(qū)別,而卸載就截然不同了。附:VB 加載窗體 form2.show 卸載窗體 unload me
加以一個(gè)panel用來顯示應(yīng)用程序的,就是放你那個(gè)easycap的,代碼如下
Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Int32, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Int32) As Int32
Private Const WM_SYSCOMMAND As Int32 = H112
Private Const SC_MAXIMIZE As Int32 = HF030
Private Const SC_MINIMIZE As Int32 = HF020
Private Const SC_RESTORE As Int32 = HF120
Public Const SW_HIDE = 0
Public Const SW_SHOW = 5
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Int32, ByVal nCmdShow As Int32) As Int32
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ShellExecute(Me.Panel1.Handle, "open", "c:\windows\system32\cmd.exe", Nothing, ".", SW_HIDE)
System.Threading.Thread.Sleep(50)
Dim h As IntPtr = FindWindow(Nothing, "c:\windows\system32\cmd.exe")
ShowWindow(h, SW_HIDE)
SetParent(h, Me.Panel1.Handle) '嵌到panel1內(nèi)
SendMessage(h, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
把其中的c:\windows\system32\cmd.exe換成你要嵌入的應(yīng)用程序