继续看“查询”按钮和子窗体怎么做:
程序代码:
CLEAR ALL
Form1 = CREATEOBJECT("C_Form")
Form1.Show
READ EVENTS
CLEAR ALL
RETURN
*---------------------
* 主窗体类定义
*---------------------
DEFINE CLASS C_Form AS Form
Caption = "星期小五的程序"
Height = 400
Width = 600
AutoCenter = .T.
ADD OBJECT Label1 AS Label WITH Caption = "考号:", Height = 25, Width = 60, Top = 20, Left = 10, Alignment = 1
ADD OBJECT Text1 AS TextBox WITH Value = "", Height = 25, Width = 100, Top = 20, Left = 70
ADD OBJECT Command1 AS CommandButton WITH Caption = "查询", Height = 25, Width = 60, Top = 50, Left = 500
ADD OBJECT Command2 AS CommandButton WITH Caption = "退出", Height = 25, Width = 60, Top = 80, Left = 500
PROCEDURE Destroy
CLEAR EVENTS
ENDPROC
PROCEDURE Command1.Click
LOCAL frmInquire AS Object
frmInquire = CREATEOBJECT("C_Inquire")
WITH frmInquire
.Top = ThisForm.Top + 100
.Left = ThisForm.Left + 100
.Show(1) && 模式窗体,此时主窗体不会响应交互事件
ENDWITH
ENDPROC
PROCEDURE Command2.Click
RELEASE ThisForm
ENDPROC
ENDDEFINE
*--------------------
* 查询窗体类定义
*--------------------
DEFINE CLASS C_Inquire AS Form
Caption = "查询"
Height = 200
Width = 200
PROCEDURE Destroy
RELEASE ThisForm
ENDPROC
ENDDEFINE
注意.Show(1)的用法,这就是某人问如何不让其它窗体接受焦点的方法,但只能在本程序中,无法阻止用户切换到Windows的其它窗口上去,比如此时阻止用户到资源管理器查看文件就是无理的。
[
本帖最后由 TonyDeng 于 2011-8-28 18:21 编辑 ]