在顶层表单实现动态显示窗口列表

    技术2022-05-11  88

    ' 在顶层表单实现动态显示窗口列表 '     我从一开始编程,就彻底抛弃了_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  cThisNamecThisName  =  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 " ) EndforEndwith  ' '''''*!* 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  lFormTypelFormType  =  .T.Try lFormType  =  PEMSTATUS(This.Parent,  " WindowList " 5 )Catch lFormType  =  .F.Finally This.FormType  =  lFormTypeEndtry  

    最新回复(0)