大家好,我有一个浮动表单在顶层表单中显示的问题,请大家帮帮忙解决。
关于顶层表单,一般都是分别建立表单文件*.scx。把其中一个表单设置为顶层表单,然后在顶层表单中用do form命令调用其他表单。
可是我想在不显示_Screen的情况下,在表单集中用一个表单做顶层表单,其余表单作为浮动表单。这样可以保持数据表的联动。
于是我创建了一个程序,希望达成如下效果:
*表单form1设置为顶层表单。
*表单form2设置为在顶层表单form1中的从属表单。
*表单form3设置为在顶层表单form1中的浮动表单。
程序代码如下:
PUBLIC poformset
*_Screen.Visible = .F.
poformset = NEWOBJECT("myformset")
poformset.Show
RETURN
DEFINE CLASS myformset AS formset
AutoRelease = .T.
Name = "myformset"
visible = .T.
ADD OBJECT form1 AS myform WITH;
showwindow = 2,;
Height = 486,;
Width = 586,;
Caption = "顶层表单",;
Name = "Form1"
ADD OBJECT form2 AS myform WITH;
showwindow = 1,;
Height = 386,;
Width = 486,;
Caption = "在顶层表单中",;
BackColor = RGB(255,0,0),;
Name = "Form2"
ADD OBJECT form3 AS myform WITH;
showwindow = 1,;
desktop = .T.,;
Height = 386,;
Width = 486,;
Caption = "浮动表单",;
BackColor = RGB(0,0,255),;
Name = "form3"
ENDDEFINE
DEFINE CLASS myform AS Form
AutoCenter = .T.
Caption = ""
BackColor = RGB(0,255,88)
Name = "myform"
ADD OBJECT mytext1 As mytext WITH ;
Top = 0,;
value = "设计时的表单属性Name="+Thisform.Name
ADD OBJECT mytext2 As mytext WITH ;
Top = 20,;
Forecolor = RGB(0,0,255)
ADD OBJECT mytext3 As mytext WITH ;
Top = 40,;
Value = "设计时的表单属性ShowWindow="+ALLTRIM(STR(Thisform.ShowWindow))
ADD OBJECT mytext4 As mytext WITH ;
Top = 60,;
Forecolor = RGB(0,0,255)
PROCEDURE Queryunload
Thisform.release
CLEAR EVENTS
* _Screen.Visible = .T.
ENDPROC
PROCEDURE mytext2.init
This.Value = "运行后表单属性Name="+Thisform.Name
ENDPROC
PROCEDURE mytext4.init
This.Value = "运行后表单属性ShowWindow="+ALLTRIM(STR(Thisform.ShowWindow))
ENDPROC
ENDDEFINE
DEFINE CLASS mytext AS TextBox
Width = 200
ENDDEFINE
程序运行后,表单form2和form3却在visual foxpro主窗口中显示,这是为什么?该怎么解决?我的QQ:304201167,请大家帮助我。在这里先谢谢大家了。
相关资料:
一、在自定义myformset类时写入下列代码:
FUNCTION form2.init
show window (this.Name) in (this.Parent.form1.Name)
ENDFUNC
PROCEDURE form3.init
show window (this.Name) in (this.Parent.form1.Name)
ENDPROC
可以使表单form2和form3停靠在form1中,但是表单form3仍然不能达到浮动表单的效果。
二、隐藏VFP的主窗口必需使可操作的表单设为顶层表单,子表单设为在顶层表单中,VFP的主窗口是一种“特殊”的‘顶层表单’所有表单默认都是“在屏幕中”
即在“VFP主窗口中。作为“顶层”的表单或“主”的窗口如果隐藏了,它的子表单也就不能显示!全程隐藏VFP的主窗口的话,必需在可操作的任一时刻有一个顶
层表单存,一个顶层表单关闭的话,必需有另一个顶层表单来“显示”才能让用户操作,不然就在进程里看见,桌面却不能操作!