-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfontselect.vb
66 lines (50 loc) · 1.91 KB
/
fontselect.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'====================================================================================
''' コンボリストの描画
'------------------------------------------------------------------------------------
Private Sub comboFontList_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles comboFontList.DrawItem
Dim ff As FontFamily
Dim f As Font
Dim fs As FontStyle
Dim b As Brush
ff = New FontFamily(Me.comboFontList.Items.Item(e.Index).ToString)
If ff.IsStyleAvailable(FontStyle.Regular) Then
fs = FontStyle.Regular
ElseIf ff.IsStyleAvailable(FontStyle.Italic) Then
fs = FontStyle.Italic
Else
fs = FontStyle.Bold
End If
f = New Font(ff, 12, fs)
e.DrawBackground() '背景の塗りつぶしはVBにお任せしてしまう。
If e.State = DrawItemState.Selected Then
b = SystemBrushes.HighlightText
Else
b = SystemBrushes.WindowText
End If
e.Graphics.DrawString(Me.comboFontList.Items.Item(e.Index).ToString, f, b, e.Bounds.X, e.Bounds.Y)
'-- フォントの破棄
f.Dispose()
ff.Dispose()
End Sub
'====================================================================================
'====================================================================================
''' コンボリストの描画
'------------------------------------------------------------------------------------
Private Sub comboFontList_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles comboFontList.MeasureItem
Dim ff As FontFamily
Dim f As Font
Dim fs As FontStyle
ff = New FontFamily(Me.comboFontList.Items.Item(e.Index).ToString)
If ff.IsStyleAvailable(FontStyle.Regular) Then
fs = FontStyle.Regular
ElseIf ff.IsStyleAvailable(FontStyle.Italic) Then
fs = FontStyle.Italic
Else
fs = FontStyle.Bold
End If
f = New Font(ff, 12, fs)
e.ItemHeight = f.Height + 2
f.Dispose()
ff.Dispose()
End Sub
'====================================================================================