程式是使用VS2010 開發,有兩個界面一個是父表單(form1)一個是子表單((child1Form)
父表單打開子表單代碼如下:
Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SetParent(child1Form.Handle, Me.Handle)
child1Form.Top = Me.Top
child1Form.Left = Me.Left
child1Form.Show()
End Sub
當父表單在螢屏的不同位置時,子表單相對父表單的位置一直在變化,感覺上面的代碼沒用,焦急。。。。。。。
uj5u.com熱心網友回復:
什么亂七八糟的,MDI有專門的屬性啊!'MDI父表單'
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
child1Form.MdiParent = Me '父子關聯'
child1Form.Show() '顯式子表單'
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Panel1.Dock = DockStyle.Left '按鈕要放在Panel1上,Panel1要停靠'
Me.IsMdiContainer = True '設為MDI父表單'
End Sub
uj5u.com熱心網友回復:
把括號里的.handle改為.whd轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/91020.html
標籤:VB基礎類
上一篇:VB陣列溢位問題
