手工“计算”了一张表单,发现三个问题,和一个思路
问题一:为什么Line1,2,3,4都是歪的呢?
问题二:刚Load的时候,标题和账单号都挤到一块了,Resize或再Activate,才能得出正确结果
问题三:我想给表单上所有控件加个MYRIGHT属性,,,,,,没成功,有可能做到吗?
思路:把类似正中标题,微调和它的说明Label这样的控件,都增加一个行属性,与下一行间的距离,要以上面同一行最大控件的底边和下面同一行最大控件的顶边为依据,整体设置“行间距”,就像WORD排版一样,这有可能让我的“放大控件和字号”更容易实现
下面是代码,太乱了。。。 困,明天继续
CLEAR ALL
CLOSE PROCEDURES
SET PROCEDURE TO "MyForm", "MyLogin","otherForm"
runShouliaoForm()
CLOSE PROCEDURES
&&CLOSE ALL
return
PROCEDURE runShouliaoForm
PUBLIC
ShouliaoForm
ShouliaoForm=CREATEOBJECT("m1Form")
ShouliaoForm.show
READ EVENTS
RETURN
ENDPROC
DEFINE CLASS m1Form as myForm
showWindow=2
caption="功能1——收料单"
autoCenter=.t.
windowType=1
minLabelFontSize=8
&&定义最小标签的字号
minOtherFontSize=9
&&定义最小文本框、列表框、按钮字号
minTitleFontSize=18
&&定义标题标签小号字号
minDistance=2
&&定义控件间最小间距
minControlTop=24
&&定义最顶端控件的最小顶边
minControlLeft=12
&&定义最左端控件的最小侧边距
formIsMinSize=.t.
ADD OBJECT titleLabel1 as label WITH caption="收",autoSize=.t.
ADD OBJECT titleLabel2 as label WITH caption="料",autoSize=.t.
ADD OBJECT titleLabel3 as label WITH caption="单",autoSize=.t.
ADD OBJECT howLineLabel as label WITH caption="本单有几项材料?",autoSize=.t.
ADD OBJECT howManyLine as spinner WITH spinnerHighValue=4,spinnerLowValue=1,value=1
ADD OBJECT addNewItemTo as checkBox WITH caption="将新列表项添加到相应库",autoSize=.t.
ADD OBJECT zhangdanTag as label WITH caption="账单号:",autoSize=.t.
ADD OBJECT zhangdanLabel as label WITH caption="0123456789ABCDEFGH",autoSize=.t.
ADD OBJECT line1 as line WITH borderWidth=3,left=this.minControlLeft-this.minDistance
ADD OBJECT gydwLabel as label WITH caption="供应单位:",autoSize=.t.
ADD OBJECT gydwCbx as comboBox
ADD OBJECT slrqTag as label WITH caption="收料日期:",autoSize=.t.
ADD OBJECT slrqLabel as label WITH caption="2015年12月25日",autoSize=.t.
ADD OBJECT line2 as line WITH borderWidth=1,left=this.minControlLeft-this.minDistance
ADD OBJECT clflTag as label WITH caption="材料分类",autoSize=.t.
ADD OBJECT clmcTag as label WITH caption="名称型号",autoSize=.t.
ADD OBJECT jldwTag as label WITH caption="计量单位",autoSize=.t.
ADD OBJECT ssslTag as label WITH caption="材料分类",autoSize=.t.
ADD OBJECT grdjTxt as label WITH caption="购入单价",autoSize=.t.
ADD OBJECT grjeTxt as label WITH caption="购入金额",autoSize=.t.
ADD OBJECT bzdjTxt as label WITH caption="标准单价",autoSize=.t.
ADD OBJECT bzjeTxt as label WITH caption="标准金额",autoSize=.t.
ADD OBJECT cjTxt as label WITH caption="差价",autoSize=.t.
ADD OBJECT bgddCbx as label WITH caption="保管地点",autoSize=.t.
ADD OBJECT line3 as line WITH borderWidth=1,left=this.minControlLeft-this.minDistance
ADD OBJECT canzhaoTextBox as textBox WITH autoSize=.t.,visible=.f.
&&两个参照性控件
ADD OBJECT canzhaoComboBox as comboBox WITH autoSize=.t.,visible=.f.
ADD OBJECT line4 as line WITH borderWidth=1,left=this.minControlLeft-this.minDistance
ADD OBJECT rtnMainBtn as commandButton WITH caption="返回主程序",autoSize=.t.
PROCEDURE Arrange
WITH this &&想给所有控件增加一个“右”属性,怎么搞定?
.setall("myRight",this.width+.width/2,"label")
ENDWITH
IF this.formIsMinSize
WITH this.titleLabel2
.fontSize=this.minTitleFontSize
.top=this.minControlTop
.left=(this.width-.width)/2
&&放大后此项不变 首次运行为什么不居中呢 什么情况?
ENDWITH
WITH this.titleLabel1
.fontSize=this.minTitleFontSize
.top=this.minControlTop
.left=this.width/2-.width*2.5
ENDWITH
WITH this.titleLabel3
.fontSize=this.minTitleFontSize
.top=this.minControlTop
.left=this.width/2+.width*1.5
ENDWITH
WITH this.howLineLabel
.fontSize=this.minOtherFontSize
.top=this.titleLabel1.top+this.titleLabel1.height/2-.height/2
&&参照标题的垂直正中
.left=this.width-(this.width-(this.width/2+.width/2))/4*3
ENDWITH
WITH this.howManyLine
.fontSize=this.minOtherFontSize
.top=this.titleLabel1.top+this.titleLabel1.height/2-.height/2
.left=this.width-(this.width-(this.width/2+.width/2))/4
.width=.height*1.5
ENDWITH
WITH this.addNewItemTo
.fontSize=this.minOtherFontSize
.top=this.titleLabel1.top+this.titleLabel1.height+this.minDistance*2
.left=this.minControlLeft+this.minDistance*2
ENDWITH
WITH this.zhangdanTag
.fontSize=this.minOtherFontSize
.top=this.titleLabel1.top+this.titleLabel1.height+this.minDistance*2
.left=this.width/2
ENDWITH
WITH this.zhangdanLabel
.fontSize=this.minOtherFontSize
.top=this.titleLabel1.top+this.titleLabel1.height+this.minDistance*2
.left=this.width/2+this.zhangdanTag.width+this.minDistance*2
ENDWITH
WITH this.line1
.width=this.width-.left*2
.top=this.zhangdanLabel.top+this.zhangdanLabel.height+this.minDistance*2
ENDWITH
WITH this.gydwLabel
.fontSize=this.minOtherFontSize
.top=this.line1.top+this.line1.height+this.minDistance*2
.left=this.addNewItemTo.left
ENDWITH
WITH this.gydwCbx
.fontSize=this.minOtherFontSize
.top=this.gydwLabel.top+this.gydwLabel.height/2-.height/2
.left=this.gydwLabel.left+this.gydwLabel.width+this.minDistance*2
ENDWITH
WITH this.slrqTag
.fontSize=this.minOtherFontSize
.top=this.gydwLabel.top
.left=this.width/2-.width/5*4
ENDWITH
WITH this.slrqLabel
.fontSize=this.minOtherFontSize
.top=this.gydwLabel.top
.left=this.slrqTag.left+this.slrqTag.width+this.minDistance*2
ENDWITH
WITH this.line2
.width=this.width-.left*2
.top=this.slrqLabel.top+this.slrqLabel.height+this.minDistance*2
ENDWITH
WITH this.clflTag
.fontSize=this.minLabelFontSize
.top=this.line2.top+this.line2.height+this.minDistance*2
.left=this.minControlLeft
ENDWITH
WITH this.line3
.width=this.width-.left*2
.top=this.clflTag.top+this.clflTag.height+this.minDistance*2
ENDWITH
WITH this.canzhaoTextBox
.fontSize=this.minOtherFontSize
.top=this.line3.top+this.line3.height+this.minDistance*2
.left=this.minControlLeft
ENDWITH
WITH this.canzhaoComboBox
.fontSize=this.minOtherFontSize
.top=this.line3.top+this.line3.height+this.minDistance*2
.left=this.canzhaoTextBox.left+this.canzhaoTextBox.width+this.minDistance*2
ENDWITH
WITH this.line4
.width=this.width-.left*2
.top=this.canzhaoComboBox.top+this.canzhaoComboBox.height+this.minDistance*2
ENDWITH
WITH this.rtnMainBtn
.fontSize=this.minOtherFontSize
.top=this.line4.top+this.line4.height+this.minDistance*2
.left=this.width-this.minControlLeft-.width
ENDWITH
this.height=this.rtnMainBtn.top+this.rtnMainBtn.height+this.minControlLeft
&&this.width=this.height*2
ELSE
tempFormWidth=this.width
ENDIF
ENDPROC
PROCEDURE Activate
This.Arrange
ENDPROC
PROCEDURE Resize
This.Arrange
ENDPROC
&&根据微调按钮,增加条目开始
&&根据微调按钮,布局结束
PROCEDURE rtnMainBtn.click
RELEASE thisform
ENDPROC
PROCEDURE Destroy
MESSAGEBOX("模块1表单成功销毁了",64,"123")
CLEAR EVENTS
ENDPROC
ENDDEFINE