以下是引用TonyDeng在2012-9-18 14:17:23的发言:
Label没有这种效果,Container或CommandButton就可以。
菜单有专门建菜单的命令组。
Label没有这种效果,Container或CommandButton就可以。
菜单有专门建菜单的命令组。
THANKS 那去了解了解
那第一个 和第三个咋办?
***************************************************************** *--主函数 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 *****************************************************************问题
*!* 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也不行