扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
VB.net 加载窗体 form2.show() 卸载窗体 me.close()加载窗体和VB没啥区别,而卸载就截然不同了。附:VB 加载窗体 form2.show 卸载窗体 unload me
10余年的湘桥网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整湘桥建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“湘桥网站设计”,“湘桥网站推广”以来,每个客户项目都认真落实执行。
加以一个panel用来显示应用程序的,就是放你那个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内
SendMessage(h, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
把其中的c:\windows\system32\cmd.exe换成你要嵌入的应用程序
直接添加一个MID父窗体或在已有窗体的属性中找到IsMDIContainer属性,然后设置为True,然后创建第二个窗体 ,需要加载子窗体的时候:
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
'如果没有任何一个MDI子窗体,则创该MDI子窗体的窗体实例
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子窗体,设为激活 并退出循环
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
确实如xjnzhidao 讲的,很可能你没实例化,模块中的代码你不调用也是不执行的,尤其是写到模块里面的函数或者过程。一个很简单的办法,就是在你模块代码中声明数据库库读取的地方设置一个断点,然后调试程序(把窗体调用该代码部分先注释掉),看看是否执行到了断点,如果没执行就说明根本没执行模块
你这个要求实在是不对路子。是思路不对。
应该是将窗体一和窗体二中的控件分别用一个panel装起来,设为隐含状态。都放在主窗体的panel1中。
点击 窗体一时,第一个panel的Visible=True,第二个panel的Visible=False
点击 窗体二时,第一个panel的Visible=False,第二个panel的Visible=True
就达到你要的效果了。
窗体不能装来装去的。
再有一个方法就是创建自定义控件。那个说起来太麻烦,看看书吧。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流