| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1564 人关注过本帖
标题:怎么引用另一个创建的控件的属性?
取消只看楼主 加入收藏
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
结帖率:91.53%
收藏
已结贴  问题点数:100 回复次数:7 
怎么引用另一个创建的控件的属性?
程序代码:
&&百钱买百鸡.prg

&&_screen.Visible= .F.
formHeight=280
formWidth=375

objForm=CREATEOBJECT("fm1")
objForm.show
READ EVENTS

DEFINE CLASS fm1 as Form
    windowType=1
    showWindow=2
    Desktop=.t.
    autoCenter=.t.
    caption="百钱买百鸡(举解法)"
    height=formHeight
    width=formWidth
    minHeight=280
    minWidth=375
    
    ADD OBJECT cmdExit as myCmd1 WITH top=formHeight-5-25,left=formWidth-5-85
    
    ADD OBJECT pageFrame1 as myPf WITH top=5,left=5
    
    PROCEDURE UnLoad
        CLEAR EVENTS
    ENDPROC
    
*!*        PROCEDURE resize
*!*            &&
*!*        ENDPROC 
ENDDEFINE

DEFINE CLASS myPf as PageFrame
    visible=.t.
    &&pageCount=2
    height=formHeight-10-25
    width=formWidth-5
    anchor=15
    
    ADD OBJECT page1 as myPage1
    ADD OBJECT page2 as myPage2
    
ENDDEFINE

DEFINE CLASS myPage1 as Page
    visible=.t.
    caption="问题描述"
    
    ADD OBJECT p1Lbl1 as qdLbl WITH top=15,left=10,caption="百钱买百鸡,"+CHR(13)+"公鸡、母鸡、小鸡都要买,各能几只?"
    ADD OBJECT p1Lbl2 as qdLbl WITH top=45,left=10,caption="铜钱一百"
    ADD OBJECT p1Lbl3 as qdLbl WITH top=75,left=10,caption="公鸡一只五钱"
    ADD OBJECT p1Lbl4 as qdLbl WITH top=105,left=10,caption="母鸡一只三钱"
    ADD OBJECT p1Lbl5 as qdLbl WITH top=135,left=10,caption="小鸡三只一钱"
    
ENDDEFINE 

DEFINE CLASS qdLbl as Label
    fontsize=10
    autoSize=.t.
ENDDEFINE

DEFINE CLASS myPage2 as Page
    visible=.t.
    caption="解答"
    
    ADD OBJECT p2Edit as qaEdit WITH top=5,left=5,anchor=15
ENDDEFINE 

DEFINE CLASS qaEdit as EditBox
    visible=.t.
    readOnly=.t.
    
    myHeight=thisform.myPf.height/4  &&??这里怎么算?
    Width=thisform.pageFrame1.width-10
    text="解答说明"
    
ENDDEFINE 

DEFINE CLASS myCmd1 as CommandButton
    visible=.t.
    caption="退出"
    height=25
    width=85
    anchor=12
    
    PROCEDURE click
        thisform.release
    ENDPROC
ENDDEFINE 


想在page2中创建一个可以显示多行文本的编辑框,宽度是页框-10,高度是页框的四分之一,会随窗口放大而变大

编辑框下面放一个表格,位置top,页框高-10再减编辑框高度,  高度是页框的四分之一,会随窗口放大而变大

2015-11-19 14:51
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
程序代码:
&&百钱买百鸡.prg

&&_screen.Visible= .F.
formHeight=350
formWidth=375

objForm=CREATEOBJECT("fm1")
objForm.show
READ EVENTS
&&CLOSE ALL
IF _VFP.StartMode=4
    QUIT
ENDIF 

DEFINE CLASS fm1 as Form
    windowType=1
    showWindow=2
    Desktop=.t.
    autoCenter=.t.
    caption="百钱买百鸡(穷解法)"
    height=formHeight
    width=formWidth
    minHeight=formHeight
    minWidth=formWidth
    
    ADD OBJECT cmdExit as myCmd1 WITH top=formHeight-5-25,left=formWidth-5-85
    
    ADD OBJECT pageFrame1 as myPf WITH top=5,left=5
    
    PROCEDURE UnLoad
        CLEAR EVENTS
    ENDPROC
    
*!*        PROCEDURE resize
*!*            &&
*!*        ENDPROC 
ENDDEFINE

DEFINE CLASS myPf as PageFrame
    visible=.t.
    &&pageCount=2
    height=formHeight-11-25
    width=formWidth-5
    anchor=15
    
    PROCEDURE init
        this.AddObject("page1","myPage1")
        this.AddObject("page2","myPage2")
        this.Resize
    ENDPROC 
    &&ADD OBJECT page1 as myPage1  &&这样是不科学的
    &&ADD OBJECT page2 as myPage2
    
    PROCEDURE resize
        this.page2.myResize
    ENDPROC 
    
ENDDEFINE

DEFINE CLASS myPage1 as Page
    visible=.t.
    caption="问题描述"
    
    
    PROCEDURE init
        this.addObject("p1Lbl1","qdLbl",15,10,"百钱买百鸡,公鸡、母鸡、小鸡都要买,各能几只?")
        this.addObject("p1Lbl2","qdLbl",45,10,"钢钱一百")
        this.addObject("p1Lbl3","qdLbl",75,10,"公鸡一只五钱")
        this.addObject("p1Lbl4","qdLbl",105,10,"母鸡一只三钱")
        this.addObject("p1Lbl5","qdLbl",135,10,"小鸡三只一钱")
    ENDPROC 
    
ENDDEFINE 

DEFINE CLASS qdLbl as Label
    visible=.t.
    fontsize=10
    autoSize=.t.
    
    PROCEDURE init(nTop,nLeft,cCaption)
        this.Top=nTop
        this.Left=nLeft
        this.Caption=cCaption
    ENDPROC
ENDDEFINE

DEFINE CLASS myPage2 as Page
    visible=.t.
    caption="解答"
    
    PROCEDURE init
        this.AddObject("p2Lbl","qaLbl",5,5,15)
        this.AddObject("p2Grid1","qaGrid1",this.Parent.height/4+15)
    ENDPROC
    &&ADD OBJECT p2Edit as qaEdit WITH top=5,left=5,anchor=15   &&这样是不科学的
    
    PROCEDURE myResize
        this.p2Lbl.height=this.Parent.height/4
        this.p2Lbl.width=this.Parent.width-5
        this.p2Grid1.height=this.Parent.height/4
        this.p2Grid1.width=this.Parent.width-5
        
    ENDPROC 
    
ENDDEFINE 

DEFINE CLASS qaLbl as Label 
    visible=.t.
    readOnly=.t.
    &&Height=thisform.myPf.height/4  &&??这里怎么算?
    &&Width=fm1.width-20
    caption="说明一二三四。"
    
    PROCEDURE init(nTop,nLeft,aAnchor)
        this.Top=nTop
        this.Left=nLeft
        this.Anchor=aAnchor
         
        MESSAGEBOX(this.Height)     
    ENDPROC 
    
ENDDEFINE 

DEFINE CLASS qaGrid1 as Grid
    visible=.t.
*!*        top=this.Parent.Height/4+15  &&写在这里不行,是因为什么呢?
    &&top=50     直接使用数值就可以,用表达式就乱了
    left=5
    columnCount=3
    anchor=15
    
    PROCEDURE init(nTop)
        this.Top=nTop
        MESSAGEBOX(this.Top)
    ENDPROC 
ENDDEFINE 

DEFINE CLASS myCmd1 as CommandButton
    visible=.t.
    caption="退出"
    height=25
    width=85
    anchor=12
    
    PROCEDURE click
        thisform.release
    ENDPROC
ENDDEFINE 


还是得不到希望的效果    this.parent.height/4的值?      到底是多少呢?

为什么表格会盖住标签?

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-11-20 14:23
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
回复 9楼 吹水佬
这个创建窗体各部件的顺序  很蛋疼啊  

无法利用父容器的大小  来定义子控件的大小了位置了 

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-11-20 15:14
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
回复 9楼 吹水佬
可不可以写一个方法  它的执行顺序是在所有控件都创建完成之后   再执行

先让所有东西都不显示  等全部窗体控件创建完成后   再重设置一下每个控件的大小的位置   然后再刷新一下表单    最后显示出表单?

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-11-20 15:18
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
我知道了  原来是写在这里 


    PROCEDURE myResize
        this.p2Lbl.height=this.Parent.height/4
        this.p2Lbl.width=this.Parent.width-5
        this.p2Grid1.height=this.Parent.height/4
        this.p2Grid1.top=this.Parent.height/4+15
        this.p2Grid1.width=this.Parent.width-5
        
    ENDPROC

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-11-20 15:21
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
回复 13楼 sdta
这样练习  才能看懂你们以后发的代码   不然   有时候都不知道你们在说什么

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-11-20 15:23
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
回复 12楼 吹水佬
对于类  没有什么概念   买的书   下载的书   讲这个   都太少了


报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-11-20 15:32
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
回复 23楼 TonyDeng
刚才又看了一遍那个例程,大部分可以看懂了,少量疑惑,暂时放一边

多来几个例程,我对比着看看

报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2015-11-21 11:21
快速回复:怎么引用另一个创建的控件的属性?
数据加载中...
 
   



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

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