デュアルディスプレイのセカンドモニターにPDF、動画、画像を表示。
@@ -50,12 +50,19 @@ | ||
50 | 50 | End Function |
51 | 51 | |
52 | 52 | Public Sub Create(ByRef form As Form, ByVal formType As Type) |
53 | - If form Is Nothing Then | |
53 | + If form Is Nothing OrElse | |
54 | + Not _secondMonitorWindows.Contains(form) Then | |
54 | 55 | form = Activator.CreateInstance(formType) |
56 | + AddHandler form.FormClosed, AddressOf from_Closed | |
55 | 57 | End If |
56 | 58 | |
57 | 59 | End Sub |
58 | 60 | |
61 | + Private Sub from_Closed(sender As Object, e As EventArgs) | |
62 | + Dim form = DirectCast(sender, Form) | |
63 | + _secondMonitorWindows.Remove(form) | |
64 | + End Sub | |
65 | + | |
59 | 66 | Private Sub HideOther(ByVal targetForm As Form) |
60 | 67 | For Each frm In _secondMonitorWindows |
61 | 68 | If frm Is targetForm Then |
@@ -81,7 +88,8 @@ | ||
81 | 88 | |
82 | 89 | |
83 | 90 | Public Sub CloseViewers() |
84 | - For Each frm In _secondMonitorWindows | |
91 | + Dim forms = New List(Of Form)(_secondMonitorWindows) | |
92 | + For Each frm In forms | |
85 | 93 | frm.Close() |
86 | 94 | Next |
87 | 95 | End Sub |