相关帖子:相关帖子:http://bbs.youkuaiyun.com/topics/390255831
根据不同分辨率自行调整大小、位置可以用 vfp9.0 的 anchor 属性,如果不是 vfp9.0,就需要自己写代码实现
左边的树和右边的的容器中间可以左右拖动(分隔条),用 vfp 代码即可。
下面是例子代码,将以下代码粘帖到一个prg中后运行,然后左右拖动分隔条,也可最大化或手动改变表单大小。
**************************************************
*!* 作者:十豆三
*!* 日期:2012-10-25
*!* vfp版本:vfp9.0(SP2 7423)
*!* 操作系统:Windows XP(SP3)
*!* 功能:表单分隔条示例
**************************************************
Public oform1
oform1=Newobject("form1")
oform1.Show
Return
Define Class form1 As Form
Top = 6
Left = 10
Height = 403
Width = 448
DoCreate = .T.
Caption = "by:十豆三(表单分隔条示例)"
Name = "Form1"
Add Object container1 As Container With;
Anchor = 7, ;
Top = 2, ;
Left = 2, ;
Width = 133, ;
Height = 399, ;
SpecialEffect = 1, ;
BackColor =Rgb(200,200,255), ;
Name = "Container1"
Add Object list1 As ListBox With;
Anchor = 14, ;
Height = 63, ;
Left = 143, ;
Top = 338, ;
Width = 301, ;
ItemBackColor =Rgb(150,255,150), ;
Themes = .F., ;
Name = "List1"
Add Object grid1 As Grid With;
Anchor = 15, ;
Height = 332, ;
Left = 143, ;
Top = 2, ;
Width = 303, ;
BackColor =Rgb(255,200,200), ;
Name = "Grid1"
Add Object shape1 As Shape With;
Top = -12, ;
Left = 136, ;
Height = 448, ;
Width = 7, ;
Anchor = 7, ;
BorderStyle = 1, ;
MousePointer = 9, ;
SpecialEffect = 0, ;
BackColor =Rgb(0,255,255), ;
Name = "Shape1"
Procedure shape1.Init
This.Move(This.Left,-10,This.Width,Thisform.Height+20)
Endproc
Procedure shape1.MouseMove
Lparameters nButton, nShift, nXCoord, nYCoord&&系统代码
If (nButton=1 And Thisform.CurrentX#0) And (Thisform.CurrentX<>nXCoord) And Between(nXCoord,40,Thisform.Width-40)&& nButton=1 只允许鼠标左键移动,Between 是移动范围
This.Left=This.Left+(nXCoord-Thisform.CurrentX)
Thisform.Container1.Width=Thisform.Container1.Width+(nXCoord-Thisform.CurrentX)
Thisform.Grid1.Move(Thisform.Grid1.Left+(nXCoord-Thisform.CurrentX),Thisform.Grid1.Top,Thisform.Grid1.Width-(nXCoord-Thisform.CurrentX))
Thisform.List1.Move(Thisform.List1.Left+(nXCoord-Thisform.CurrentX),Thisform.List1.Top,Thisform.List1.Width-(nXCoord-Thisform.CurrentX))
Thisform.CurrentX=nXCoord
Endif
Endproc
Procedure shape1.MouseDown
Lparameters nButton, nShift, nXCoord, nYCoord&&系统代码
If nButton=1&& 只允许鼠标左键移动
Thisform.CurrentX=nXCoord&& 只记录水平位置,也就是只能左右移动。
Endif
Endproc
Enddefine