我这个的思路也是一个表单+一个容器 不过一个大的容器里面包含了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 编辑 ]