| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4388 人关注过本帖, 1 人收藏
标题:XP计算器?
只看楼主 加入收藏
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
以下是引用hu9jj在2012-9-18 21:18:16的发言:

不愧是有基础的,上手快的很啊!

那家伙是有点悟性的

授人以渔,不授人以鱼。
2012-09-18 21:33
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:0 
以下是引用hu9jj在2012-9-18 21:18:16的发言:

不愧是有基础的,上手快的很啊!

那家伙是有点悟性的
============================
几位老大这么说让俺受宠若惊啊 其实全靠大牛们指点 我受益匪浅 我功倍事半 我内牛满面

梅尚程荀
马谭杨奚







                                                       
2012-09-18 21:52
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9841
专家分:27213
注 册:2012-2-5
收藏
得分:0 
你们才知道

坚守VFP最后的阵地
2012-09-18 22:00
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:0 
我这个的思路也是一个表单+一个容器 不过一个大的容器里面包含了1个小容器 3个命令按钮组
图片附件: 游客没有浏览图片的权限,请 登录注册

1是容器 显示是否存储TextBox的结果 存则显示一个M符号
2 3 4 都是命令按钮组
5是个大容器
先付上自己写的代码吧 有几个问题求解
程序代码:
*****************************************************************
*--主函数
set clock on
set talk off
main_form = CreateObject("c_form")
main_form.show
read events
return
*--程序结束
*****************************************************************

*****************************************************************
*--类       c_form
*-- 父类:  form
*-- 基类:    form
define class c_form as Form
    BorderStyle = 1
    width = 256
    height = 215
    AutoCenter = .T.
    Maxbutton = .F.
    Caption = " 计算器"
    Icon = 'D:\VFP\ico\rr.ico'

    add object menu_edit as label with Height = 20, Width = 50,  Caption = "编辑(\<E)"
    add object menu_view as label with Height = 20, Width = 50,  Caption = "查看(\<V)"
    add object menu_help as label with Height = 20, Width = 50,  Caption = "帮助(\<H)"

    add object f_body as body                         


procedure Arrange
    with thisform.menu_view
         .Top = ThisForm.menu_edit.Top
         .Left = ThisForm.menu_edit.Left + ThisForm.menu_edit.Width
    endwith
   

    with thisform.menu_help
         .Top = ThisForm.menu_edit.Top
         .Left = ThisForm.menu_view.Left + ThisForm.menu_view.Width
    endwith
   

     with thisform.f_body
         .Top = ThisForm.menu_edit.Top + ThisForm.menu_edit.Height
         .Left = ThisForm.menu_edit.Left
         .Height = ThisForm.Height - ThisForm.menu_edit.Height
    endwith
endproc

       procedure Activate
          thisform.Arrange
       endproc

       procedure f_body.num_ thisform.f_body.b_text.value = '7'
          MessageBox("haha!")
       endproc
      

       procedure f_body.mem_ thisform.f_body.m_flag.mem_disp_text.Caption = "M"
       endproc


procedure destroy
*!*         a = MessageBox("真的要退出吗?", 1 + 32, "退出")
*!*         if a == 1
         clear events
endproc

enddefine
*
*--end_define: c_form
*****************************************************************    


*****************************************************************
*--类      body
*-- 父类:  container
*-- 基类:  container
define class body as Container
       Caption = ""
       BorderColor = Rgb(222, 222, 222) 

       Width = 256
      

       add object b_text as TextBox with Top = 4, Left = 8, value = 0, Alignment = 1,;
                            Height = 20, Width = This.Width - 2 * This.b_text.Left,;
                            BorderStyle = 0
       add object m_flag as mem_disp with Top = 35, Left = 14                      

       add object num_opr as num_btn with Top = 68, left = 55, Height = 300, Width = 200  

       add object cls_opr as cls_btn with Top = 35, left = 55 

       add object mem_opr as mem_btn with Top = 68, left = 8                

                           

                           

*!*           procedure num_*!*             this.b_text.value = '7'
*!*              MessageBox("haha!")
*!*           endproc
*!*          

*!*           procedure mem_*!*             * this.b.value = '7'
*!*              *m_flag.mem_disp_text.Caption = "M"
*!*              MessageBox("haha!")
*!*           endproc
      

enddefine

*
*--end_define: body
*****************************************************************


*****************************************************************
*--类      num_btn
*-- 父类:  CommandGutton
*-- 基类:  CommandGutton
define class num_btn as CommandGroup
    ButtonCount = 20
    BackStyle = 0
    BorderStyle = 0
   

    procedure init
         local sp as Integer
         sp = 4
         with  .Themes = .F.
             .Top = 0
             .left = 0
             .Height = 27
             .Width = 35
             .Caption = '7'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '8'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

          with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '9'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '/'
             .ForeColor = Rgb(255, 0, 0)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = 'sqrt'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top +  + sp
             .left = Left
             .Height =  .Width =  .Caption = '4'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '5'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '6'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '*'
             .ForeColor = Rgb(255, 0, 0)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '%'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top +  + sp
             .left = Left
             .Height =  .Width =  .Caption = '1'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '2'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '3'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '-'
             .ForeColor = Rgb(255, 0, 0)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '1/x'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

         with  .Themes = .F.
             .Top = Top +  + sp
             .left = Left
             .Height =  .Width =  .Caption = '0'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

           with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '+/-'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

           with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '.'
             .ForeColor = Rgb(0, 0, 255)
         endwith

        

          with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '/'
             .ForeColor = Rgb(255, 0, 0)
         endwith

        

           with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = '='
             .ForeColor = Rgb(255, 0, 0)
         endwith       

    endproc

 

enddefine

*
*--end_define: num_btn
*****************************************************************



*****************************************************************
*--类      cls_btn
*-- 父类:  CommandGroup
*-- 基类:  CommandGroup
define class cls_btn as CommandGroup
     ButtonCount = 3
     BackStyle = 0
     BorderStyle = 0
     Width = 240
     Height = 25
    

     procedure init
         local sp as Integer
         sp = 5
         with  .Themes = .F.
             .Top = 0
             .left = 0
             .Height = 25
             .Width = 60
             .Caption = 'BackSpace'
             .ForeColor = Rgb(255, 0, 0)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = 'CE'
             .ForeColor = Rgb(255, 0, 0)
         endwith

        

         with  .Themes = .F.
             .Top = Top
             .left = Left +  + sp
             .Height =  .Width =  .Caption = 'C'
             .ForeColor = Rgb(255, 0, 0)
         endwith

     endproc
    

enddefine       

*
*--end_define: cls_btn
*****************************************************************


*****************************************************************
*--类      mem_btn
*-- 父类:  CommandGroup
*-- 基类:  CommandGroup
define class mem_btn as CommandGroup
     ButtonCount = 4
     BackStyle = 0
     BorderStyle = 0
     Width = 35
     Height = 240
    

    procedure init
        local sp as Integer
         sp = 4
         with  .Themes = .F.
             .Top = 0
             .left = 0
             .Height = 27
             .Width = 35
             .Caption = 'MC'
             .ForeColor = Rgb(255, 0, 0)
         endwith 

        

          with  .Themes = .F.
             .Top = Top +  + sp
             .left = Left
             .Height =  .Width =  .Caption = 'MR'
             .ForeColor = Rgb(255, 0, 0)
         endwith
        

         with  .Themes = .F.
             .Top = Top +  + sp
             .left = Left
             .Height =  .Width =  .Caption = 'MS'
             .ForeColor = Rgb(255, 0, 0)
         endwith
        

         with  .Themes = .F.
             .Top = Top +  + sp
             .left = Left
             .Height =  .Width =  .Caption = 'M+'
             .ForeColor = Rgb(255, 0, 0)
         endwith
    endproc
            

enddefine

*
*--end_define: mem_btn
*****************************************************************


*****************************************************************
*--类      mem_btn
*-- 父类:  CommandGroup
*-- 基类:  CommandGroup
define class mem_disp as Container
    Width = 25
    Height = 25
    BackStyle = 0
    BorderWidth = 1
    SpecialEffect = 1
   

    add object mem_disp_text as TextBox with Top = 1, Left = 1, Height = 23, Width = 23,;
                                  BackStyle = 0, BorderWidth = 0, Caption = 'M',;
                                  FontSize = 10, Rotation = 1, BorderStyle = 0
                                                                           

enddefine
*
*--end_define: mem_btn
***************************************************************** 
问题
1. 我在body大容器 也就是容器5里写事件代码click的时候引用不了body里其他的object? 但是可以相应一个messagebox()   函数 ~~ 但是把这个事件写到C_Form下(总表单)就能正常
  按理说body是自定义的一个类 在里面写他的方法函数怎么不成 而且他里面的控件都是一个级别的 经过他调用怎么会有问题? 这样的写法有错?
程序代码:
*!*           procedure num_*!*             this.b_text.value = '7'

*!*              MessageBox("haha!")

*!*           endproc

*!*          

*!*           procedure mem_*!*             * this.b.value = '7'

*!*              *m_flag.mem_disp_text.Caption = "M"

*!*              MessageBox("haha!")

*!*           endproc 
  错误提示找不到b_text对象 我把this去掉也不成 换成thisform也不行
  很不愿意在C_Form里写body的事件代码 啊
  难道是还要在body里加个init事件但是又怎么弄呢 貌似都先add object了啊
2 在那个小容器 也就是套在容器5里的容器1里添加了一个TextBox控件
    add object mem_disp_text as TextBox with Top = 1, Left = 1, Height = 23, Width = 23,;
                                  BackStyle = 0, BorderWidth = 0, Caption = 'M',;
                                  FontSize = 10, Rotation = 1, BorderStyle = 0
很显然我已经给他的Caption = ‘M’了 为什么运行程序无法显示 MS的click事件也不起作用?
可以看下界面图
图片附件: 游客没有浏览图片的权限,请 登录注册

凹陷那个方框里 怎么弄都没有东西?
      



[ 本帖最后由 有容就大 于 2012-9-18 22:43 编辑 ]

梅尚程荀
马谭杨奚







                                                       
2012-09-18 22:37
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9841
专家分:27213
注 册:2012-2-5
收藏
得分:0 
回复 24楼 有容就大
图片附件: 游客没有浏览图片的权限,请 登录注册

坚守VFP最后的阵地
2012-09-18 22:41
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
回复 24楼 有容就大
出现大量重复代码了!

授人以渔,不授人以鱼。
2012-09-18 22:43
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:0 
以下是引用TonyDeng在2012-9-18 22:43:57的发言:

出现大量重复代码了!

那怎么办 我也考虑过这个情况 但是 一个命令按钮组里的单独按钮的caption ,left, top ,forecolor 都是不一样的啊  

梅尚程荀
马谭杨奚







                                                       
2012-09-18 22:47
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:0 
回复 25楼 sdta
无限挑逗啊
求真相

梅尚程荀
马谭杨奚







                                                       
2012-09-18 22:48
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:0 
回复 25楼 sdta
擦 貌似不是caption = ‘M’而是 value
但是又有个问题 怎么让TextBox里的字符出现的方框中央?
Rotation = 1貌似不太美观

梅尚程荀
马谭杨奚







                                                       
2012-09-18 22:50
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9841
专家分:27213
注 册:2012-2-5
收藏
得分:0 
2 在那个小容器 也就是套在容器5里的容器1里添加了一个TextBox控件
    add object mem_disp_text as TextBox with Top = 1, Left = 1, Height = 23, Width = 23,;
                                  BackStyle = 0, BorderWidth = 0, Caption = 'M',;
                                  FontSize = 10, Rotation = 1, BorderStyle = 0
很显然我已经给他的Caption = ‘M’了 为什么运行程序无法显示 MS的click事件也不起作用?
按钮[M]CLICK EVENT
THISFORM.CONTAINER1.LABEL1.CAPTION=ALLTRIM(THISFORM.ACTIVECONTROL.CAPTION)
THISFORM.CONTAINER1.LABEL1.LEFT=(THISFORM.CONTAINER1.Width-THISFORM.CONTAINER1.LABEL1.Width)/2

把文本框换成标签

Rotation ?不认识

[ 本帖最后由 sdta 于 2012-9-18 22:55 编辑 ]

坚守VFP最后的阵地
2012-09-18 22:53
快速回复:XP计算器?
数据加载中...
 
   



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

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