ご存知の方がいましたら、教えてください。
MDIフォームを持つアプリケーションを作成しているのですが、
一度に複数個のMDI子フォームを起動しようと思っています。
たとえば、以下のように。
Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewToolStripButton.Click, NewWindowToolStripMenuItem.Click
For i As Integer = 0 To 10
Dim ChildForm As New System.Windows.Forms.Form
ChildForm.MdiParent = Me
ChildForm.Text = "ウィンドウ " & i + 1
ChildForm.Show()
Next
End Sub
これを実行すると、子フォームがパラパラ出てくるのが嫌なのですが、
何か回避する方法はないものでしょうか?
一度、Hideにしてから、Showしても、似たような結果でした。
Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewToolStripButton.Click, NewWindowToolStripMenuItem.Click
For i As Integer = 0 To 10
Dim ChildForm As New System.Windows.Forms.Form
ChildForm.MdiParent = Me
ChildForm.Text = "ウィンドウ " & i + 1
ChildForm.hide()
Next
For i As Integer = 0 To 10
ChildForm.Show()
next
end sub
親フォームのvisbleをFalseにしても良いのですが、親フォームが突然消えるのも、
個人的には、好きじゃありません。
フォームの更新をとめることが出来たら、うれしいのですが、
可能なのでしょうか?
APIでできそうなできないようなよくわからないのですが、
一度にバッと表示させたいのであれば、
各フォームにバックグラウンドワーカーみたいなので
指定時間を数秒後にセットしてshowっていうのはどうですか?(^^;
ひどいかな。。
それでもずれちゃうかな?
GDI系でなんとかできるのかな?
ダミーの親コンテナをvisible=Flaseにしてみるとか。
Zオーダーを変えてみるとかでダメでしょうか。
Dim childForms(8) As Form
'とりあえず、マイナス座標に配置しておいて
For i As Integer = 0 To 7
childForms(i) = New Form()
With childForms(i)
.MdiParent = Me
.Text = String.Format("ウィンドウ {0}", i + 1)
.Size = New Size(300, 80)
.Location = New Point(-1000, -1000)
.StartPosition = FormStartPosition.Manual
.Show()
End With
Next
'あとから、座標位置を調整
For i As Integer = 0 To 7
With childForms(i)
If i < 4 Then
.Location = New Point(0, i * 80)
Else
.Location = New Point(300, (i - 4) * 80)
End If
End With
Next
'LayoutMdi(MdiLayout.TileVertical)
childForms(0).Activate()
うぉーなるほど。。(^^;
ツイート | ![]() |