DockingManager (Magic Library 1.7.4) の利用方法では、DockingManager を Form に適用していたので、Form にメニューを実装するとドッキングするコントロールが メニューとフォームの間に入り込んでしまいます。 これを避けるには、フォーム以外のコンテナに DockingManager を適用して その中にコントロールを配置すれば解決します
関連記事
ユーザコントロールとして、UserPanel を作成します。 1) プロジェクトで UserControl を追加。 2) UserControl1.Designer.vb の Inherits の部分を変更。 <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class UserPanel Inherits System.Windows.Forms.ContainerControl 'UserControl はコンポーネント一覧をクリーンアップするために dispose をオーバーライドします。 <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub 'Windows フォーム デザイナで必要です。 Private components As System.ComponentModel.IContainer 'メモ: 以下のプロシージャは Windows フォーム デザイナで必要です。 'Windows フォーム デザイナを使用して変更できます。 'コード エディタを使って変更しないでください。 <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() components = New System.ComponentModel.Container() End Sub End Class 一度ビルドして実行すると、ユーザーコントロールがツールボックスから 選択できるようになるので、その中に他のコントロールを配置します Imports Crownwood.Magic.Common Imports Crownwood.Magic.Docking Public Class Form1 Private _dockingManager As DockingManager = Nothing Private _myMemo As Content = Nothing Private _myMemo2 As Content = Nothing Private hide_control As Boolean = False ' ************************************************************************** ' 初期処理 ' ************************************************************************** Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Me.UserPanel1.Dock = DockStyle.Fill ' ドッキングマネージャを作成 _dockingManager = New DockingManager(Me.UserPanel1, VisualStyle.IDE) ' フォームに貼り付けられたコントロールを追加 _myMemo = _dockingManager.Contents.Add(Me.Panel1, "今日の予定表") _myMemo2 = _dockingManager.Contents.Add(Me.Panel2, "今日の予定表2") Dim wc As WindowContent = CType(_dockingManager.AddContentWithState( _ _myMemo2, State.DockTop), WindowContent) ・ ・ ・ ・ ・
関連記事
配列を使用して複数のコントロールを想定しています。 この例では、一つのウインドウにコントロールをまとめるようにしています。 Articles の「Create in same window」として説明されている内容です。 ( 開いた時の大きさが全て同じになります ) ※ タイマーが必要になります Imports Crownwood.Magic.Common Imports Crownwood.Magic.Docking Public Class Form1 Private _dockingManager As DockingManager = Nothing Private _myContent As Content() Private hide_control As Boolean = False Private wc As WindowContent ' ************************************************************************** ' 初期処理 ' ************************************************************************** Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load ' 配列を作成 _myContent = New Content(1) {} Me.UserPanel1.Dock = DockStyle.Fill ' ドッキングマネージャを作成 _dockingManager = New DockingManager(Me.UserPanel1, VisualStyle.IDE) ' フォームに貼り付けられたコントロールを追加 _myContent(0) = _dockingManager.Contents.Add(Me.Panel1, "今日の予定表") _myContent(0).ImageList = Me.ImageList1 _myContent(0).ImageIndex = 0 _myContent(1) = _dockingManager.Contents.Add(Me.Panel2, "今日の予定表2") Dim i As Integer For i = 0 To 1 ' メモ帳の設定 _myContent(i).FullTitle = "メモ : " + DateTime.Today.ToString("d") ' 閉じるボタンを使用しない場合は、Flase を設定 ' ( 閉じるボタンの機能は完全に非表示 ) _myContent(i).CloseButton = False ' クリップボタンを表示する _myContent(i).HideButton = True ' ドッキング時の初期の横幅( 横にドッキングなので縦は無効 ) _myContent(i).AutoHideSize = New Size(270, 270) ' ドッキング中のタブなしの横幅( 横にドッキングなので縦は無効 ) _myContent(i).DisplaySize = New Size(270, 270) ' 浮いている状態のサイズ( 浮いている状態のサイズが手動でドッキング時のサイズになる ) _myContent(i).FloatingSize = New Size(270, 270) ' 表示 _dockingManager.ShowContent(_myContent(i)) ' たたむ If i = 0 Then wc = _dockingManager.AddContentWithState( _ _myContent(i), State.DockLeft) Else _dockingManager.AddContentToWindowContent(_myContent(1), wc) End If Next Dim wdc As WindowDetailCaption For Each wdc In wc.WindowDetails wdc.OnInvertAutoHide() Next ' ドッキングされたコントロールが非表示になった時のイベント AddHandler _dockingManager.ContentHidden, AddressOf content_Hidden End Sub ' ************************************************************************** ' 非表示 ' ************************************************************************** Private Sub content_Hidden(ByVal c As Content, ByVal e As System.EventArgs) If Not hide_control Then ' この処理は、浮いている状態からの x ボタンを想定しています ' ( この処理は多少ちらつきます ) c.Docked = True _dockingManager.ShowContent(c) Me.Timer1.Start() End If End Sub ' ************************************************************************** ' メニューからの処理 ' ************************************************************************** Private Sub close_control(ByVal cidx As Integer) hide_control = True ' タブ付きかそうでないか If _myContent(cidx).ParentWindowContent.ParentZone Is Nothing Then ' タブあり _dockingManager.HideAllContents() _dockingManager.ShowAllContents() Else ' タブなし If _myContent(cidx).Docked Then ' ドッキング中 _dockingManager.ToggleContentAutoHide(_myContent(cidx)) Else ' 浮いている状態( この処理は多少ちらつきます ) Dim i As Integer For i = 0 To 1 _myContent(i).Docked = True Next _dockingManager.HideAllContents() _dockingManager.ShowAllContents() _dockingManager.ToggleContentAutoHide(_myContent(0)) End If End If hide_control = False End Sub ' ************************************************************************** ' ドッキングしたパネルのメニュー ' ************************************************************************** Private Sub 閉じる_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles 閉じる.Click close_control(0) End Sub Private Sub 閉じる2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles 閉じる2.Click close_control(1) End Sub ' ************************************************************************** ' タイマー処理の状態切り替え ' ************************************************************************** Private Sub Timer1_Tick(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Timer1.Tick Me.Timer1.Stop() close_control(0) End Sub End Class |