'
在顶层表单实现动态显示窗口列表
'
我从一开始编程,就彻底抛弃了_screen,而改用顶层表单。我个人感觉顶层表单做出的系统显示专业些,也许是因为我对_screen了解不够深入吧。选用顶层表单作为系统主表单,就意味着很多东西必须自己去实现。例如如何实现动态显示窗口列表,以为是我的个人经验,希望能抛砖引玉!
'
*************************
'
基于base.vcx中的_form类
'
*************************
'
''''''*!* LoadValues事件代码:
'
''''''*-- 表单状态设置
With
This
.cFormName
=
.Caption
.JustName
=
FindWin(This)
.Name
=
"
_
"
+
Alltrim(Str(.hWnd))
.Icon
=
"
ImagesLogo.ico
"
.MDIForm
=
.F.
.ShowTips
=
.T.
.BorderStyle
=
2
.oldWidth
=
.Width
.oldHeight
=
.Height
.chkFormType()
&&
检查表单类型
ToBar (.cFormName)
Endwith
'
'''''*-- 保存表单位置
Local
cThisName
cThisName
=
This.JustName
If
Type(
"
_Screen.&cThisName
"
)
=
"
U
"
Then
_Screen.AddObject(cThisName,
"
Custom
"
)
With
_Screen.
&
cThisName.
.AddProperty(
"
LEFT
"
,
0
)
.AddProperty(
"
TOP
"
,
0
)
Endwith
End
If
With
_Screen.
&
cThisName.
This.Left
=
This.Left
+
.Left
This.Top
=
This.Top
+
.Top
'
'''''*-- 计算表单在屏幕中的位置
If
Sysmetric(
2
)
-
(This.Top
+
This.Height)
>=
140
Then
.Left
=
.Left
+
20
.Top
=
.Top
+
20
Else
.Left
=
0
.Top
=
0
End
If
Endwith
'
'''''*-- 刷新窗口列表
If
!This.nWindowType
=
1
Then
If
Vartype
(_Screen.WindowListText)
=
"
U
"
Then
_Screen.AddProperty(
"
WindowListText
"
,
""
)
End
If
cFormInf
=
Alltrim(This.Name)
+
"
#
"
+
Alltrim(This.Caption)
+
"
,
"
_Screen.WindowListText
=
_Screen.WindowListText
+
cFormInf
This.AddWindowList()
End
If
'
'''''*-- 刷新工具条
If
!Type(
"
oMytoolsbar
"
)
=
"
U
"
Then
Local
tForm,cForm,o
tForm
=
Lower(Alltrim(This.JustName))
For
Each
o In oMytoolsbar.Controls
cForm
=
Alltrim(o.Name)
cForm
=
Lower(Substrc(cForm,
4
,
Len
(cForm)))
If
cForm
=
tForm
Then
o.Enabled
=
.F.
Exit
End
If
Next
End
If
'
'''''*!* AddWindowList事件代码
'
'''''*-- 增加窗口列表
With
_Screen
nListForm
=
Alines(aWindowList, .WindowListText,
"
,
"
)
Define Bar
4
Of _4 Prompt
"
-
"
For
i
=
1
To
nListForm
cFormInf
=
Strtran(aWindowList[i],
"
,
"
,
""
)
cFormName
=
Left
(cFormInf, At(
"
#
"
, cFormInf)
-
1
)
cFormInf
=
Substr(cFormInf, At(
"
#
"
, cFormInf)
+
1
)
cFormInf
=
"
<
"
+
Alltrim(Str(i))
+
"
.
"
+
cFormInf
_FontName
=
Alltrim(.MenuFontName)
_FontSize
=
.MenuFontSize
Define Bar i
+
4
Of _4 Prompt
"
&cFormInf
"
Font
"
&_FontName
"
,_FontSize
*
On
Selection Bar i
+
4
Of _4 Activate Window
&
cFormName Top
On
Selection Bar i
+
4
Of _4 ActivateWindow(
"
&cFormName
"
)
Endfor
Endwith
'
'''''*!* DeleteWindowList事件代码
'
'''''*-- 删除窗口列表
Release Bar
4
Of _4
&&
删除
"
-
"
With
_Screen
nListForm
=
Alines(aWindowList, .WindowListText,
"
,
"
)
For
i
=
1
To
nListForm
Release Bar i
+
4
Of _4
Endfor
cFormInf
=
Alltrim(This.Name)
+
"
#
"
+
Alltrim(This.Caption)
+
"
,
"
.WindowListText
=
Strtran(.WindowListText, cFormInf,
""
)
Endwith
'
'''''*!* chkFormType
'
'''''*-- 判别当前表单类型
Local
lFormType
lFormType
=
.T.
Try
lFormType
=
PEMSTATUS(This.Parent,
"
WindowList
"
,
5
)
Catch
lFormType
=
.F.
Finally
This.FormType
=
lFormType
Endtry
本文介绍了一种使用顶层表单实现动态显示窗口列表的方法,包括表单状态设置、保存表单位置、计算表单位置、刷新窗口列表等功能。

8340

被折叠的 条评论
为什么被折叠?



