| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2042 人关注过本帖
标题:双管齐下,表单和控件按一定比例放大
取消只看楼主 加入收藏
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
结帖率:91.53%
收藏
已结贴  问题点数:100 回复次数:6 
双管齐下,表单和控件按一定比例放大
还是要做这样的表单,但考虑最终客户的眼神可能不好,有可能需要放在表单,并且按一定比例规则放大表单上的控件和字体
图片附件: 游客没有浏览图片的权限,请 登录注册


考虑到  前面T版已经做了等比例调整控件位置的示例  但相应的字号没有跟着放大

为此  我特意研究了一下WORD中的字号,11可以,12可以,11.5也可以,但11.6就非法

我又回到VFP中  字号在设计器中   只能输入整法   小数点部分自动舍掉   

看来整个表单的放大比例规则   是要被字号制约的

于是  我定义了一系列基础字号   在这些基础字号上进行比例的计算   和控件的定位

不知道这样的思路   对不对?

    minLabelFontSize=8    &&定义最小标签的字号
    minOtherFontSize=9    &&定义最小文本框、列表框、按钮字号
    minTitleFontSize=18    &&定义标题标签小号字号
    minDistance=2    &&定义控件间最小间距
    minControlTop=24    &&定义最顶端控件的最小顶边
    minControlLeft=12    &&定义最左端控件的最小侧边距

[此贴子已经被作者于2015-12-21 18:39编辑过]

搜索更多相关主题的帖子: 小数点 眼神 
2015-12-21 18:37
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
回复 6楼 TonyDeng
先不考虑难看的问题   先要做到   做出来不好看   可以不要   但有想法   就要试着做一下

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-12-21 22:10
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
手工“计算”了一张表单,发现三个问题,和一个思路
问题一:为什么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

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-12-22 03:03
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
先来解决第一个问题   为什么添加的Line控件是歪的

图片附件: 游客没有浏览图片的权限,请 登录注册

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-12-22 09:51
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
回复 12楼 liuxingang28
明白了

ADD OBJECT line4 as line WITH borderWidth=1,left=this.minControlLeft-this.minDistance,height=0

强制HEIGHT=0,才能得到水平的直线   呵呵    谢谢

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-12-22 11:22
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
下面分步解决思路  先得到每次调整的宽、高比例
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
    beforeWidth=this.width
    currWidth=this.width
    beforeHeight=this.Height
    currHeight=this.Height
    minWidth=this.Width
    minHeight=this.Height
   
    ADD OBJECT infoLabel as label WITH backColor=RGB(222,222,222),wordWrap=.t.,caption="123"
   
    PROCEDURE init
        thisformSize="窗体加载时高为"+ALLTRIM(STR(thisform.height))+",宽为"+ALLTRIM(STR(thisform.width))
        MESSAGEBOX(thisformSize,64,"123")
    ENDPROC
   
    PROCEDURE Arrange
        WITH this.infoLabel
            .top=this.height/10
            .left=this.width/10
            .width=this.width/10*8
            .height=this.height/10*8
        ENDWITH
        LOCAL tempFormWidth,tempFormHeight
        tempFormWidth=this.width
        tempFormHeight=this.height
        IF (this.beforeWidth<>tempFormWidth) .or. (this.beforeHeight<>tempFormHeight)
            this.currWidth=tempFormWidth
            this.currHeight=tempFormHeight
            LOCAL labelMess
            labelMess="窗体加载时高为:"+ALLTRIM(STR(thisform.minheight))+",宽为:"++ALLTRIM(STR(thisform.minWidth))
            labelMess=labelMess+CHR(13)
            labelMess=labelMess+"窗体调整前高为:"+ALLTRIM(STR(thisform.beforeHeight))+",宽为:"++ALLTRIM(STR(thisform.beforeWidth))
            labelMess=labelMess+CHR(13)
            labelMess=labelMess+"窗体调整后高为:"+ALLTRIM(STR(thisform.currHeight))+",宽为:"++ALLTRIM(STR(thisform.currWidth))
            labelMess=labelMess+CHR(13)
            labelMess=labelMess+"窗体高的缩放比例为:"+ALLTRIM(STR(thisform.currHeight/thisform.beforeHeight,10,4))
            labelMess=labelMess+CHR(13)
            labelMess=labelMess+"窗体宽的缩放比例为:"+ALLTRIM(STR(thisform.currWidth/thisform.beforeWidth,10,4))
            thisform.infoLabel.caption=labelMess
        ENDIF
        this.beforeWidth=this.width
        this.beforeHeight=this.height
    ENDPROC
   
    PROCEDURE Activate
        This.Arrange
    ENDPROC
   
    PROCEDURE Resize
        This.Arrange
    ENDPROC
        
    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
ENDDEFINE

[此贴子已经被作者于2015-12-22 12:47编辑过]


报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-12-22 11:27
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
程序代码:
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
    beforeWidth=this.width
    currWidth=this.width
    beforeHeight=this.Height
    currHeight=this.Height
    minWidth=this.Width
    minHeight=this.Height
   
    ADD OBJECT infoLabel1 as label WITH backColor=RGB(222,222,222),wordWrap=.f.,caption="123",autoSize=.t.
    ADD OBJECT infoLabel2 as label WITH backColor=RGB(222,222,222),wordWrap=.f.,caption="456"
    ADD OBJECT infoLabel3 as label WITH backColor=RGB(222,222,222),wordWrap=.f.,caption="789"
   
    PROCEDURE Arrange
        WITH this.infoLabel1
            .top=this.height/10
            .left=this.width/10
            &&.width=this.width/10*8
            .height=this.height/10-1
        ENDWITH
        WITH this.infoLabel2
            .top=this.height/10*2
            .left=this.width/10
            .width=this.width/10*8
            .height=this.height/10-1
        ENDWITH
        WITH this.infoLabel3
            .top=this.height/10*3
            .left=this.width/10
            .width=this.width/10*8
            .height=this.height-this.height/10*4
        ENDWITH
        LOCAL tempFormWidth,tempFormHeight
        tempFormWidth=this.width
        tempFormHeight=this.height
        IF (this.beforeWidth<>tempFormWidth) .or. (this.beforeHeight<>tempFormHeight)
            this.currWidth=tempFormWidth
            this.currHeight=tempFormHeight
            LOCAL labelMess1,labelMess2,labelMess3
            labelMess1="窗体加载时高为:"+ALLTRIM(STR(thisform.minheight))+",宽为:"++ALLTRIM(STR(thisform.minWidth))
            thisform.infoLabel1.caption=labelMess1
            labelMess2="窗体调整前高为:"+ALLTRIM(STR(thisform.beforeHeight))+",宽为:"++ALLTRIM(STR(thisform.beforeWidth))
            thisform.infoLabel2.caption=labelMess2
           
            FOR tempFontSize=8 TO 72 STEP 0.5
                this.InfoLabel1.fontSize=tempFontSize
                IF (this.infoLabel1.height>this.infoLabel2.height).or.(this.infoLabel1.width>this.infoLabel2.width)
                    this.infoLabel1.fontSize=tempFontSize-0.5
                    RETURN
                ENDIF
            ENDFOR
            
            labelMess3="窗体调整后高为:"+ALLTRIM(STR(thisform.currHeight))+",宽为:"++ALLTRIM(STR(thisform.currWidth))
            labelMess3=labelMess3+CHR(13)
            labelMess3=labelMess3+"窗体高的缩放比例为:"+ALLTRIM(STR(thisform.currHeight/thisform.beforeHeight,10,4))
            labelMess3=labelMess3+CHR(13)
            labelMess3=labelMess3+"窗体宽的缩放比例为:"+ALLTRIM(STR(thisform.currWidth/thisform.beforeWidth,10,4))
            thisform.infoLabel3.caption=labelMess3
           
           
        ENDIF
        this.beforeWidth=this.width
        this.beforeHeight=this.height
    ENDPROC
   
    PROCEDURE Activate
        This.Arrange
    ENDPROC
   
    PROCEDURE Resize
        This.Arrange
    ENDPROC
       
    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
ENDDEFINE 

已经实现控件随窗体调整大小,控件上的字号,随控件大小以0.5步长递增到最大尺寸,需要找一个同样的控件做参照物  。。。。。。

有没有更好的算法,或者,,,做一个能传参的过程或者方法  把表单上现有的控件逐个扔进去,按比例规则变形后,再拿出来  

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-12-22 13:35
快速回复:双管齐下,表单和控件按一定比例放大
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023305 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved