实现窗体内部的左右移动
2006-02-27 21:15:20 来源:WEB开发网核心提示:'分割区的宽度PRivateConstSPLITTERWIDTH=45'最小移动宽度PrivateConstHMIN=15'picLeft和picRight的宽度相对于窗体的比例PrivatePercentAsSingle'正在拖动的标志PrivateDragFlagAsBoolean&
'分割区的宽度
PRivateConstSPLITTERWIDTH=45
'最小移动宽度
PrivateConstHMIN=15
'picLeft和picRight的宽度相对于窗体的比例
PrivatePercentAsSingle
'正在拖动的标志
PrivateDragFlagAsBoolean
'每次拖动后需要重排窗体上的控件
PrivateSubRedrawMe()
DimNewWidthAsSingle
'忽略窗体缩小的情况
IfWindowState=vbMinimizedThenExitSub
NewWidth=(ScaleWidth-SPLITTERWIDTH)*Percent
Picleft.Move0,0,NewWidth,ScaleHeight
Picright.MoveNewWidth SPLITTERWIDTH,0,ScaleWidth-NewWidth-SPLITTERWIDTH,ScaleHeight
EndSub
PrivateSubForm_Load()
'PicLeft和PicRight的MousePointer=1
Percent=0.5
EndSub
PrivateSubForm_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
DragFlag=True
EndSub
PrivateSubForm_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
'定义鼠标为vbSizeWE型
MousePointer=vbSizeWE
Percent=X/ScaleWidth
RedrawMe
EndSub
PrivateSubForm_MouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
DragFlag=False
MousePointer=0'此行语句实际没有起作用
EndSub->
PRivateConstSPLITTERWIDTH=45
'最小移动宽度
PrivateConstHMIN=15
'picLeft和picRight的宽度相对于窗体的比例
PrivatePercentAsSingle
'正在拖动的标志
PrivateDragFlagAsBoolean
'每次拖动后需要重排窗体上的控件
PrivateSubRedrawMe()
DimNewWidthAsSingle
'忽略窗体缩小的情况
IfWindowState=vbMinimizedThenExitSub
NewWidth=(ScaleWidth-SPLITTERWIDTH)*Percent
Picleft.Move0,0,NewWidth,ScaleHeight
Picright.MoveNewWidth SPLITTERWIDTH,0,ScaleWidth-NewWidth-SPLITTERWIDTH,ScaleHeight
EndSub
PrivateSubForm_Load()
'PicLeft和PicRight的MousePointer=1
Percent=0.5
EndSub
PrivateSubForm_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
DragFlag=True
EndSub
PrivateSubForm_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
'定义鼠标为vbSizeWE型
MousePointer=vbSizeWE
Percent=X/ScaleWidth
RedrawMe
EndSub
PrivateSubForm_MouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
DragFlag=False
MousePointer=0'此行语句实际没有起作用
EndSub->
更多精彩
赞助商链接