具體説,就是先設計一个標準窗體,把控件佈置好,長寛比例固定,然後在這基礎上設定一個字體基準値,當窗體尺寸變化時,所有控件的尺寸都隨之等比例變化,字體大小亦按大致的比例變化大概(不能確保)能不失真,要反覆調試才能取得這個基準値。
授人以渔,不授人以鱼。
ADD OBJECT titleLabel as label WITH caption="收 料 单" ADD OBJECT howLineLabel as label WITH caption="本单有几项材料?" WITH this.titleLabel .fontBold=.t. .top=24*this.formZoom .left=209*this.formZoom .width=127*this.formZoom .height=29*this.formZoom .fontSize=thisform.fontReSize(.name,.height,.width,18,1) ENDWITH WITH this.howLineLabel .top=this.titleLabel.top+this.titleLabel.height/2-.height/2 .left=this.width-(this.width-(this.width/2+.width/2))/4*3 .width=108*this.formZoom .height=12*this.formZoom .fontSize=thisform.fontReSize(.name,.height,.width,9,1) ENDWITH
PROCEDURE fontReSize PARAMETERS nName,nHeight,nWidth,nFontSize,nClass IF nClass=1 referControl="referLabel" this.&referControl..caption=this.&nName..caption this.&referControl..autoSize=.t. this.&nName..backColor=RGB(222,222,222) ENDIF LOCAL tempFontSize FOR tempFontSize=nFontSize TO 72 STEP 1 this.&referControl..fontSize=tempFontSize IF (this.&referControl..height>this.&nName..height).or.(this.&referControl..width>this.&nName..width) &&MESSAGEBOX(VARTYPE(tempFontSize),64) &&RETURN EXIT ENDIF ENDFOR MESSAGEBOX(VARTYPE(tempFontSize),64) IF this.height<>this.minHeight RETURN tempFontSize ELSE RETURN nFontSize ENDIF ENDPROC