'Display the window list dynamically in the top-level form.
'From the very beginning, I completely abandoned _ screen and switched to the top-level form. I personally feel that the top-level forms display a professional system, maybe because I don't know much about _ screen. Using the top-level form as the main form of the system means that many things must be implemented by themselves. For example, how to display the window list dynamically is my personal experience!
'*************************
'Based on the _ form class in base. vcx
'*************************
'''''''*! * LoadValues Event code:
''' * -- Form status settings
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 () & Check Form Type
Tobar (. cformname)
Endwith
''' * -- Save the form position
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
''' * -- Calculates the position of the form on the screen.
If sysmetric (2)-(this. Top + this. Height) >=140 then
. Left =. Left + 20
. Top =. Top + 20
Else
. Left = 0
. Top = 0
End if
Endwith
''' * -- Refresh the window list
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
''' * -- Refresh the toolbar
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 Event code
''' * -- Adds a window list.
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 Event code
''' * -- Deletes the window list.
Release Bar 4 Of _ 4 & Delete "-"
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
''' * -- Identifies the current form type
Local lFormType
LFormType =. T.
Try
LFormType = PEMSTATUS (This. Parent, "WindowList", 5)
Catch
LFormType =. F.
Finally
This. FormType = lFormType
Endtry