| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2251 人关注过本帖
标题:这个方法错在呢?
只看楼主 加入收藏
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
结帖率:91.53%
收藏
已结贴  问题点数:100 回复次数:19 
这个方法错在呢?
CLEAR ALL
CLOSE PROCEDURES
SET PROCEDURE TO "MyFormClass", "MyLoginForm"&&,"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
    rowStep=1
    colStep=1
    formHeightZoom=1
    formWidthZoom=1
   
   
    ADD OBJECT titleLabel1 as label WITH caption="收 料 单",backColor=RGB(222,222,222)

    PROCEDURE Arrange
        LOCAL tempFormWidth,tempFormHeight
        tempFormWidth=this.width
        tempFormHeight=this.height
        IF (this.beforeWidth<>tempFormWidth) .or. (this.beforeHeight<>tempFormHeight)
            this.currWidth=tempFormWidth
            this.currHeight=tempFormHeight
            this.formHeightZoom=thisform.currHeight/thisform.minHeight
            this.formWidthZoom=thisform.currWidth/thisform.minWidth
        ENDIF
        WITH this.titleLabel1
            .top=24*this.formHeightZoom
            .left=(this.width-.width)/2
            .width=127*this.formWidthZoom
            .height=29*this.formHeightZoom
            .fontSize=thisform.fontReSize(.height,.width,.class,18)
        ENDWITH

        this.beforeWidth=this.width
        this.beforeHeight=this.height
        thisform.refresh
    ENDPROC
   
    PROCEDURE Activate
        This.Arrange
    ENDPROC
   
    PROCEDURE Resize
        This.Arrange
    ENDPROC
   
    PROCEDURE fontReSize
        PARAMETERS nHeight,nWidth,nBaseClass,nBaseFontSize
        thisform.addobject('testControl',nBaseClass)
            WITH thisform.testControl
                autoSize=.t.
                LOCAL tempFontSize
                FOR tempFontSize=8 TO 72
                    thisform.testControl.fontSize=tempFontSize
                    IF (thisform.testControl.height>nHeight) .or. (thisform.testControl.width>nWidth)
                        thisform.testControl.fontSize=tempFontSize-0.5
                    ENDIF
                ENDFOR
            ENDWITH
        IF thisform.testControl.fontSize<=nBaseFontSize         
            RETURN nBaseFontSize
        ELSE
            RETURN thisform.testControl.fontSize
        ENDIF
        thisform.testControl.release
    ENDPROC

      
    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
ENDDEFINE

红字部分  是我想实现的方法  但是   总是有同名成员对象存在   什么情况呢?

我想这个方法实现的功能  就是把控件的宽、高、类、最低字号传进来
当窗体放大或者缩小的时候,再建一个同样的控件   进行字号对比   最后返回最适合的字号
对比完成  释放这个临时的控件
。。。  请各位老师指导一下   谢谢   迷糊了    
搜索更多相关主题的帖子: PUBLIC 
2015-12-23 13:26
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:451
帖 子:10587
专家分:43118
注 册:2014-5-20
收藏
得分:32 
看看这句:
thisform.addobject('testControl',nBaseClass)
问题:
1、thisform是不是同一个表单
2、addobject()第一个参数是“常数”
3、这句有无多次被执行
2015-12-23 14:02
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
完全的乱了   。。。

CLEAR ALL
CLOSE PROCEDURES
SET PROCEDURE TO "MyFormClass", "MyLoginForm"&&,"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
    rowStep=1
    colStep=1
    formHeightZoom=1
    formWidthZoom=1
   
    &&用作参照物的控件
    ADD OBJECT referLabel as label &&WITH visible=.f.
   
    ADD OBJECT titleLabel1 as label WITH caption="收 料 单",backColor=RGB(222,222,222)

    PROCEDURE Arrange
        WITH this.titleLabel1
            .top=24*this.formHeightZoom
            .left=(this.width-.width)/2
            .width=127*this.formWidthZoom
            .height=29*this.formHeightZoom
            .fontSize=18
        ENDWITH
        LOCAL tempFormWidth,tempFormHeight
        tempFormWidth=this.width
        tempFormHeight=this.height
        IF (this.beforeWidth<>tempFormWidth) .or. (this.beforeHeight<>tempFormHeight)
            this.currWidth=tempFormWidth
            this.currHeight=tempFormHeight
            this.formHeightZoom=thisform.currHeight/thisform.minHeight
            this.formWidthZoom=thisform.currWidth/thisform.minWidth
            
            thisform.titleLabel1.FontSize=thisform.fontReSize(thisform.titleLabel1.height,thisform.titleLabel1.width,thisform.titleLabel1.FontSize,1)
            
        ENDIF

        this.beforeWidth=this.width
        this.beforeHeight=this.height
        thisform.refresh
    ENDPROC
   
    PROCEDURE Activate
        This.Arrange
    ENDPROC
   
    PROCEDURE Resize
        This.Arrange
    ENDPROC
   
    PROCEDURE fontReSize
        PARAMETERS nHeight,nWidth,nBaseFontSize,nBaseClass
        IF nBaseClass=1      
         
        thisform.referLabel.autoSize=.t.
        LOCAL tempFontSize
        FOR tempFontSize=8 TO 72
            thisform.referLabel.fontSize=tempFontSize
            IF (thisform.referLabel.height>nHeight) .or. (thisform.referLabel.width>nWidth)
                thisform.referLabel.fontSize=tempFontSize-1
            ENDIF
        ENDFOR
        MESSAGEBOX(thisform.referLabel.fontSize,64)
        IF thisform.referLabel.fontSize<=nBaseFontSize         
            RETURN nBaseFontSize
        ELSE
            RETURN thisform.referLabel.fontSize
        ENDIF
        ENDIF
    ENDPROC
      
    PROCEDURE Destroy
        CLEAR EVENTS
    ENDPROC
   
ENDDEFINE

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-12-23 15:30
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:451
帖 子:10587
专家分:43118
注 册:2014-5-20
收藏
得分:0 
大乱得大治
战场拉得太大
改变一下战略,集中优势兵力逐个击破。


2015-12-23 16:16
liuxingang28
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:山东济南
等 级:贵宾
威 望:47
帖 子:654
专家分:2167
注 册:2014-2-7
收藏
得分:30 
好乱!想让大伙替你调试程序?

泉城飞狐
2015-12-23 16:27
liuxingang28
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:山东济南
等 级:贵宾
威 望:47
帖 子:654
专家分:2167
注 册:2014-2-7
收藏
得分:0 
个人看法:对于大多数用户来说,很少自己编写代码调整各控件的大小。通常情况下,调整一下各控件的 Anchor 属性即可。不知道楼主的水平如何,但从发布的几个帖子来看,应该是个刚入门的新手。你必须明白:用 Prg 程序来创建类和应用程序是有相当难度的,并不适用于入门用户,这也背离了“Visual”的特性。

泉城飞狐
2015-12-23 16:40
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:0 
完全的乱了
2015-12-23 18:56
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
不知道你的參考Label幹嘛的,調整出來是那個控件尺寸變了。

授人以渔,不授人以鱼。
2015-12-23 19:53
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:30 
把你的處理邏輯用文字描述清楚。其實文字描述清楚了,代碼就自然出來。文字表達都不清的,也無法寫出代碼。

[此贴子已经被作者于2015-12-23 19:59编辑过]


授人以渔,不授人以鱼。
2015-12-23 19:57
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
看明白https://bbs.bccn.net/thread-460483-1-1.html所給的示例,就知道不需要參考控件的,你只需要一個基準値,那個値是做界面時根據設計方案預定的,控制字體變化幅度在最大和最小尺寸都能協調才行。

授人以渔,不授人以鱼。
2015-12-23 20:30
快速回复:这个方法错在呢?
数据加载中...
 
   



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

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