程序中打开的窗口列表 [英] List of open windows in program

查看:61
本文介绍了程序中打开的窗口列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,

我似乎缺乏描述我所追求的内容所以我会告诉你我希望可以使用的代码。



Hey guys,
I seem to lack words to describe what I'm after so I'll show you the code that I wish Were usable.

dim idToView as integer = 3'RANDOM'
dim AlreadyExists as boolean = False



For each X as CertainKindOfWindow in AllOfTheOpenWindowsInThisProgram '<-----Thats What I'm after




    if X.DataRowID = = idToView Then
       
      AlreadyExists = True
      X.BringToFront
      
    end if

Next

if not AlreadyExists then
   OpenNewInstanceOfCertainKindOfWindow(idToView)
end if









我需要一些检查方法某个类的所有打开的窗口,看天气与否,我应该打开一个新的实例。我将根据每个窗口中的属性idToView做出决定。

如果其中一个窗口具有匹配的ID,那么我将只显示该窗口而不是混乱我的用户环境并占用ram。 br />




非常感谢所有打开窗户骑自行车的任何帮助。谢谢。





I need some Method of examining all of the open windows of a certain class to see weather or not I should open a new instance. I will make the decision Based on the property idToView in each window.
If one of the windows has a matching id then i'll just show that window instead of cluttering my users environment and hogging ram.


Any help on cycling through all open windows is much appreciated. Thanks.

推荐答案

Application.OpenForms [ ^ ]获取应用程序中所有打开表单的列表。然后你可以使用你发布的上述代码。
Application.OpenForms[^] Gets a list of all the open forms in the application. You can then use the above code you posted.


在Ron Beyer的帮助下解决他的使用Application.OpenForms的建议。



因为我正在测试一个只存在于某种形式的变量;我必须先遍历每个表单,以确保它是我需要使用的类型,因此包含我需要检查的属性。

所以列出该类型的表单并使用IS运算符在Application.OpenForms中找到匹配的表单。





Solved with the help of Ron Beyer and his suggestion of using Application.OpenForms.

Because i am testing a variable that only exists in a certain type of form; i must first cycle through each form to make sure that it's the type i need to work with and thus contains the property that i need to examine.
so make a list of that type of form and use the IS operator to find forms in Application.OpenForms that match.


Sub RespondToClientViewRequest(sender As EPI_Class_Library.EPI_Client, e As EPI_Class_Library.EPI_Class_Events.ClientViewRequestedEventArgs)
     Dim Exists As Boolean = False
     Dim ClientViewForms As New List(Of EPI_Viewers.Veiw_Client_Window)

     For Each x As Form In Application.OpenForms
         If x.GetType Is GetType(EPI_Viewers.Veiw_Client_Window) Then
             ClientViewForms.Add(x)
         End If
     Next

     For Each y As EPI_Viewers.Veiw_Client_Window In ClientViewForms
         If y.ClientDisplay.Client.ID = sender.ID Then
             Exists = True
             y.BringToFront()
         End If
     Next

     If Not Exists Then
         Dim newClient As New EPI_Viewers.Veiw_Client_Window
         newClient.Show()

     End If


 End Sub


这篇关于程序中打开的窗口列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆