那个高手有时间帮我完善一下一个类似 messagebox 的函数的??
*调用dfmsg(msg,cr,msgt,msgc,col1,col2,col3,col4)
* msg 需要显示的内容
* cr 命令按钮控制
* msgt 标题栏显示的内容
* msgc check显示的内容,如果为空则不显示
* col1 界面背景色
* col2 文字颜色
* col3 命令背景色
* col4 命令文字色
*其中f_color_01,f_color_02是我程序的全局变量,用于控制表单的颜色!
PROCEDURE dfmsg
LPARAMETERS msg,cr,msgt,msgc,col1,col2,col3,col4
LOCAL ARRAY tmp_1(1)
LOCAL tmp_2,tmp_3,tmp_4
PUBLIC tmp_5
* 检查函数的输入数据,并定义默认值
DO CASE
CASE "N"=TYPE("msg")
msg=ALLTRIM(STR(msg))
CASE "L"=TYPE("msg")
msg=""
ENDCASE
IF "N" # TYPE("cr")
cr=0
ENDIF
DO CASE
CASE "N"=TYPE("msgt")
msgt=ALLTRIM(STR(msgt))
CASE "L"=TYPE("msgt")
msgt=""
ENDCASE
DO CASE
CASE "N"=TYPE("msgc")
msgc=ALLTRIM(STR(msgc))
CASE "L"=TYPE("msgc")
msgc=""
ENDCASE
IF "N" # TYPE("col1")
IF "N" = TYPE("f_color_01")
col1=f_color_01
ELSE
col1=14215660
ENDIF
ENDIF
IF "N" # TYPE("col2")
IF "N" = TYPE("f_color_02")
col2=f_color_02
ELSE
col2=0
ENDIF
ENDIF
IF "N" # TYPE("col3")
IF "N" = TYPE("f_color_01")
col3=f_color_01
ELSE
col3=14215660
ENDIF
ENDIF
IF "N" # TYPE("col4")
IF "N" = TYPE("f_color_02")
col4=f_color_02
ELSE
col4=0
ENDIF
ENDIF
* tmp_2 显示行数 tmp_3 每行最长字符数
IF 0=LEN(msg)
tmp_2=0
tmp_3=0
ELSE
tmp_2=alines(tmp_1,msg)
tmp_3=0
FOR EACH tmp_4 IN tmp_1
tmp_3 = MAX(tmp_3,LEN(tmp_4))
ENDFOR
ENDIF
IF 0=LEN(msgc)
tmp_4=0
ELSE
tmp_4=1
tmp_3 = MAX(tmp_3,LEN(msgc))
ENDIF
IF tmp_3 >10
tmp_3=tmp_3-10
ELSE
tmp_3=0
ENDIF
tmp_5=0
ACTIVATE SCREEN
dfmgs = CREATEOBJECT('Form')
WITH dfmgs
.Closable = .F.
.Height = 80+(tmp_2+tmp_4)*FONTMETRIC(1)
.Width = 100 +tmp_3*FONTMETRIC(6)
.backcolor=col1
.AutoCenter = .T.
.BorderStyle = 2
.Caption = msgt
.FontCondense = .T.
.MaxButton = .F.
.MinButton = .F.
.WindowType = 1
.AlwaysOnTop = .T.
ENDWITH
dfmgs.AddObject('lbl','label')
WITH dfmgs.lbl
*.AutoSize = .T.
.WordWrap = .T.
.BackStyle = 0
.forecolor=col2
.Caption = msg
.Left = 30
.Top = 25
.Height = (tmp_2+tmp_4)*FONTMETRIC(1)
.Width = LEN(msg)*FONTMETRIC(6)
ENDWITH
dfmgs.AddObject('chk','chkbox')
WITH dfmgs.chk
.AutoSize = .T.
.BackStyle = 0
.forecolor=col2
.Caption = msgc
.Top = 35+tmp_2*FONTMETRIC(1)
.Left = 30
.Height = 16
.Width = 20+LEN(msgc)*FONTMETRIC(6)
ENDWITH
dfmgs.AddObject('cmd1','cmdbtn1')
WITH dfmgs.cmd1
.backcolor=col3
.forecolor=col4
.Top = 40+(tmp_2+tmp_4)*FONTMETRIC(1)
.Left = (40+tmp_3*FONTMETRIC(6))/3
.Height = 20
.Width = 30
.Caption = "是"
ENDWITH
dfmgs.AddObject('cmd2','cmdbtn2')
WITH dfmgs.cmd2
.backcolor=col3
.forecolor=col4
.Top = 40+(tmp_2+tmp_4)*FONTMETRIC(1)
.Left = (40+tmp_3*FONTMETRIC(6))/3*2+30
.Height = 20
.Width = 30
.Caption = "否"
ENDWITH
IF LEN(msg)>0
dfmgs.lbl.visible=.t.
ENDIF
IF LEN(msgc)>0
dfmgs.chk.visible=.t.
dfmgs.cmd1.enabled=.f.
ENDIF
DO CASE
CASE 0=cr
dfmgs.cmd1.left=(70+tmp_3*FONTMETRIC(6))/2
dfmgs.cmd1.visible=.t.
CASE 1=cr
dfmgs.cmd1.visible=.t.
dfmgs.cmd2.visible=.t.
CASE 2=cr
dfmgs.cmd1.caption="确定"
dfmgs.cmd2.caption="取消"
dfmgs.cmd1.visible=.t.
dfmgs.cmd2.visible=.t.
ENDCASE
dfmgs.SHOW
READ EVENTS
tmp_2=tmp_5
RELEASE tmp_5
RETURN tmp_2
DEFINE CLASS chkbox AS checkbox
PROCEDURE Click
this.Parent.cmd1.enabled=this.Value
ENDDEFINE
DEFINE CLASS cmdbtn1 AS COMMANDBUTTON
PROCEDURE Click
tmp_5=1
thisform.Release()
CLEAR EVENTS
ENDDEFINE
DEFINE CLASS cmdbtn2 AS COMMANDBUTTON
PROCEDURE Click
tmp_5=2
thisform.Release()
CLEAR EVENTS
ENDDEFINE
ENDPROC