フォント設定のダイアログを呼び出します。フォントを設定するとModifiedプロパティがTrueになるので、いったん変数に写してから戻すようにしています。
Private m_font As Font ' フォント
' 表示メニュー : フォント
Private Sub mnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnFont.Click
Dim d As New FontDialog()
Dim bModified As Boolean = False
Try
If Not IsNothing(TC1.SelectedTab) Then
With DirectCast(TC1.SelectedTab, TextPage).EditBox
d.Font = .Font
bModified = .Modified
End With
Else
d.Font = m_font
End If
If d.ShowDialog = DialogResult.OK Then
m_font = d.Font
If Not IsNothing(TC1.SelectedTab) Then
Cursor.Current = Cursors.WaitCursor
With DirectCast(TC1.SelectedTab, TextPage)
.EditBox.Font = m_font
.EditBox.Modified = bModified
End With
Cursor.Current = Cursors.Default
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "フォントエラー", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
d.Dispose()
End Try
End Sub
ツールバーとステータスバーの表示・非表示を切り替えます。つくってはみたものの、一度も使ったことがない機能です。
' 表示メニュー : ツールバー
Private Sub mnToolbar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnToolbar.Click
mnToolbar.Checked = Not mnToolbar.Checked
TB1.Visible = mnToolbar.Checked
End Sub
' 表示メニュー : ステータスバー
Private Sub mnStatusbar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnStatusbar.Click
mnStatusbar.Checked = Not mnStatusbar.Checked
SB1.Visible = mnStatusbar.Checked
End Sub

タブ幅の変更では、ダイアログを呼び出しますが、このダイアログは、編集のジャンプメニューでつくった「数値指定ダイアログ」を使いまわしています。 SetTabStops, SetWordWrap また、実際にタブ幅とワードラップを設定するこれらの関数は、すでにリッチテキスト派生クラスのところ(第3章)で作成済みです。
' 表示メニュー : タブ幅
Private Sub mnTabstops_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnTabstops.Click
Dim nMin As Integer = 0
Dim nMax As Integer = 32
Dim d As New NumericDialog("タブ幅の設定", "タブ (" & nMin & " (規定値) 〜" & nMax & ")")
Try
d.SetValues(nMax, nMin, m_tabwidth)
If d.ShowDialog(Me) = DialogResult.OK Then
If Not IsNothing(TC1.SelectedTab) Then
DirectCast(TC1.SelectedTab, TextPage).EditBox.SetTabStops(d.Value)
End If
m_tabwidth = d.Value
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "タブ幅指定エラー", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
d.Dispose()
End Try
End Sub
' 表示メニュー : ワードラップ
Private Sub mnWordwrap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnWordwrap.Click
mnWordwrap.Checked = Not mnWordwrap.Checked
If (TC1.TabPages.Count > 0) AndAlso (Not IsNothing(TC1.SelectedTab)) Then
Cursor.Current = Cursors.WaitCursor
DirectCast(TC1.SelectedTab, TextPage).EditBox.SetWordWrap(mnWordwrap.Checked)
Cursor.Current = Cursors.Default
End If
End Sub

簡単なダイアログをつくって表示します。すべて、アッセンブリファイルやアイコンリソースから必要なデータを引っ張り出して直接描画しています。
' ヘルプメニュー : バージョン情報
Private Sub mnAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnAbout.Click
Dim d As New AboutDialog(Me)
d.Show()
End Sub
' バージョン情報ダイアログ
Public Class AboutDialog
Inherits System.Windows.Forms.Form
' 変数と定数
WithEvents bnOK As Button
Const strIcon As String = "Tsuzuri.Tsuzuri32.ico"
' コンストラクタ
Public Sub New(ByRef parent As Form)
MyBase.New()
Me.Text = " バージョン情報 "
Me.FormBorderStyle = FormBorderStyle.FixedToolWindow
Me.Owner = parent
Me.Font = New Font("MS UIゴシック", 9, FontStyle.Regular)
Me.AcceptButton = bnOK
Me.StartPosition = FormStartPosition.Manual
bnOK = New Button()
With bnOK
.Text = "OK"
.FlatStyle = FlatStyle.System
.Cursor = Cursors.Hand
.DialogResult = DialogResult.OK
.Visible = True
End With
Me.Controls.Add(bnOK)
End Sub
' ロード
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Me.Size = New Size(288, 120)
Me.Location = _
New Point(CInt((Owner.Width - Me.Width) / 2 + Owner.DesktopLocation.X), _
CInt((Owner.Height - Me.Height) / 2 + Owner.DesktopLocation.Y))
bnOK.Size = New Size(72, 22)
bnOK.Location = _
New Point(CInt((ClientSize.Width - bnOK.Width) / 2),
ClientSize.Height - bnOK.Height - 8)
End Sub
' 描画
Private Sub AboutDialog_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' アッセンブリ
Dim m_assembly As Reflection.Assembly = _
Reflection.Assembly.GetExecutingAssembly
' アイコンをリソースから取得
Dim m_icon As New Icon(m_assembly.GetManifestResourceStream(strIcon))
' バージョン番号をアッセンブリから取得
Dim m_info As Diagnostics.FileVersionInfo
m_info = Diagnostics.FileVersionInfo.GetVersionInfo(m_assembly.Location)
' 描画実行
Dim m_font As Font
e.Graphics.FillRectangle(Brushes.White, 8, 8, m_icon.Width, m_icon.Height)
e.Graphics.DrawIcon(m_icon, 8, 8)
m_font = New Font("MS ゴシック", 11, FontStyle.Bold)
e.Graphics.DrawString("「" & m_info.ProductName & "」", m_font, Brushes.Black, 48, 8)
m_font = New Font("MS ゴシック", 9, FontStyle.Regular)
e.Graphics.DrawString("バージョン : " & m_info.FileVersion, m_font, Brushes.Black, 52, 32)
e.Graphics.DrawString("コメント : " & m_info.Comments, m_font, Brushes.Black, 52, 46)
m_font.Dispose()
m_info = Nothing
m_assembly = Nothing
m_icon.Dispose()
e.Graphics.Dispose()
End Sub
' OKボタン
Private Sub bnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles bnOK.Click
Me.Close()
End Sub
End Class