Start Here..
OptionExplicitPrivateFormOldWidthAsLong保存窗体的原始宽度PrivateFormOldHeightAsLong保存窗体的原始高度在调用ResizeForm前先调用本函数PublicSubResizeInit(FormNameAsForm)DimObjAsControlFormOldWidth=FormName.ScaleWidthFormOldHeight=FormName.ScaleHeightOnErrorResumeNextForEachObjInFormNameObj.Tag=Obj.Left&""&Obj.Top&""&Obj.Width&""&Obj.Height&""NextObjOnErrorGoTo0EndSub按比例改变表单内各元件的大小,在调用ReSizeForm前先调用ReSizeInit函数PublicSubResizeForm(FormNameAsForm)DimPos(4)AsDoubleDimiAsLong,TempPosAsLong,StartPosAsLongDimObjAsControlDimScaleXAsDouble,ScaleYAsDoubleScaleX=FormName.ScaleWidth/FormOldWidth保存窗体宽度缩放比例ScaleY=FormName.ScaleHeight/FormOldHeight保存窗体高度缩放比例OnErrorResumeNextForEachObjInFormNameStartPos=1Fori=0To4读取控件的原始位置与大小TempPos=InStr(StartPos,Obj.Tag,"",vbTextCompare)IfTempPos>0ThenPos(i)=Mid(Obj.Tag,StartPos,TempPos-StartPos)StartPos=TempPos+1ElsePos(i)=0EndIf根据控件的原始位置及窗体改变大小的比例对控件重新定位与改变大小Obj.MovePos(0)*ScaleX,Pos(1)*ScaleY,Pos(2)*ScaleX,Pos(3)*ScaleYNextiNextObjOnErrorGoTo0EndSubPrivateSubForm_Load()CallResizeInit(Me)在程序装入时必须加入EndSubPrivateSubForm_Resize()CallResizeForm(Me)确保窗体改变时控件随之改变EndSub
posted on 2012-05-25 14:56 ** 阅读(227) 评论(0) 编辑 收藏
Powered by: BlogJava Copyright © **