作者stwinkle (好忙喔~~~)
看板Visual_Basic
标题请问如何在表单内显示另一个表单
时间Tue Jul 11 17:41:57 2006
小妹是VB新手,想要Form2的表单显示在Form1的表单内
我在网上找到一个写法,可是还是不成功,Form2还是在Form1外面
想请教各位大大是哪里出错呢?
===========================================================
那个网页的写法先宣告
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
然後再用这段coding
Public Function FormWithinForm(Parent As Object, _
Child As Object)
'This will display a form within a form,
'but can also be used to display and kind of child
'control within a container. You can adjust the
'positioning of the parent or child as needed
'Example:
'Form2.Show
'FormWithinForm Me, Form2
'*************************************************************
On Error Resume Next
SetParent (Child.hWnd, Parent.hWnd)
FormWithinForm = (Err.Number = 0 And Err.LastDllError = 0)
End Function
===============================================================
这两段code我写在Form1.vb
呼叫Form2的方法亦如coding内的写法一样
Form2.Show()
FormWithinForm (Me, Form2)
请问是在Form2.vb也要这两段code吗?
还是是因为我用Visual Studio 2005的关系呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.76.157.169
※ 编辑: stwinkle 来自: 219.76.157.169 (07/11 17:42)