7、 ?磕愕谋韱
你現(xiàn)在可以用新的表單Dockable屬性把?啃袨榧尤氲侥愕某绦蛑小DJ(rèn)的Dockable值是0,跟以前版本的行為一致。然而,如果你把Dockable設(shè)為1或2,表單的標(biāo)題欄高度就會變成原來的一半,這時表單就支持?苛耍ㄔO(shè)為1表示表單已?浚。
表單支持?浚―ockable設(shè)為1或2)后,你可以用WINDOWS菜單的Dockable項或在表單的標(biāo)題欄點擊鼠標(biāo)右鍵來切換這2種設(shè)置。當(dāng)Dockable=1時,你可以將表單拖放到可?康奈恢,你也可以用以下代碼實現(xiàn)?浚 * 1=top, 2=left, 3=right, 4=bottom
THISFORM.Dock(nPosition)
* tab-dock to another form
THISFORM.Dock(4, oFormTarget)
* tab-dock to a window
DOCK NAME oFormRef POSITION 4 WINDOW WindowName 一個已停靠的表單也可以通過WINDOWS菜單的Dockable項或在表單的標(biāo)題欄點擊鼠標(biāo)右鍵來終止?,或用以下的代碼: * set form to "supports docking, but not docked"
THISFORM.Dockable = 2
* or call the form's dock method
THISFORM.Dock(-1) 你可以運行下面的代碼看看停靠的過程。這些代碼建了3個表單,并設(shè)定了TOP/LEFT,然后把它們?康紺OMMAND窗口上。你可以用上面的Dock/Undock按鈕來實現(xiàn)表單的?/不?,點擊3個中任一一個表單的X按鈕會關(guān)閉演示。
選中一個表單后,你可以用菜單來切換它的Dockable屬性,當(dāng)表單處于可停靠狀態(tài)時,你可以把它拖放到屏幕上的任一個可?康奈恢。圖2顯示了3個可互相切換的已?勘韱。
圖二:
LOCAL oform1 as Myform
oform1=CREATEOBJECT("Myform")
oform1.Caption="Customers"
oform1.lblName.Caption = "Customers"
oform1.top = 100
oform1.left = 0
LOCAL oform2 as Myform
oform2=CREATEOBJECT("Myform")
oform2.Caption="Employees"
oform2.lblName.Caption = "Employees"
oform2.top = 100
oform2.left = 325
LOCAL oform3 as Myform
oform3=CREATEOBJECT("Myform")
oform3.Caption="Invoices"
oform3.lblName.Caption = "Invoices"
oform3.top = 275
oform3.left = 0
DOCK NAME oform1 POSITION 4 WINDOW Command
DOCK NAME oform2 POSITION 4 WINDOW Command
DOCK NAME oform3 POSITION 4 WINDOW Command
oform1.show()
oform2.show()
oform3.Show()
READ EVENTS
DEFINE CLASS MyForm AS Form
Dockable = 1 && supports docking and is dockable
Height = 150
Width = 300
ADD OBJECT lblName AS MyLabel
ADD OBJECT btnUndock AS MyUndockButton
FUNCTION Destroy()
CLEAR EVENTS
ENDDEFINE DEFINE CLASS MyUndockButton AS CommandButton
Height = 25
Width = 100
Left = 180
Top = 100
Anchor = 12 && fixed distance bottom/right
Caption = "Dock/Undock"
FUNCTION Click()
IF THISFORM.Docked
THISFORM.Dock(-1)
ELSE
IF THISFORM.Dockable = 1
* error if not dockable
DOCK NAME THISFORM POSITION 4 WINDOW Command
ENDIF
ENDIF
ENDDEFINE
DEFINE CLASS MyLabel AS Label
FontSize= 18
Height = 50
Width = 150
Top = 50
Left = 75
Alignment = 2
Anchor = 240 && relative on all sides
Caption = []
FontSize = 14
FontBold = .T.
FontName = "Verdana"
ENDDEFINE