請問如何在表單內顯示另一個表單

看板Visual_Basic作者 (好忙喔~~~)時間19年前 (2006/07/11 17:29), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
小妹是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)
文章代碼(AID): #14iszxO0 (Visual_Basic)
文章代碼(AID): #14iszxO0 (Visual_Basic)