home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form FontForm
- BorderStyle = 3 'Fixed Dialog
- Caption = "Font example"
- ClientHeight = 6105
- ClientLeft = 45
- ClientTop = 345
- ClientWidth = 9615
- FillStyle = 0 'Solid
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 6105
- ScaleWidth = 9615
- ShowInTaskbar = 0 'False
- Begin VB.CommandButton ShowFontBut
- Caption = "&Show Dialog!"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 13.5
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 840
- Left = 6960
- TabIndex = 35
- Top = 240
- Width = 2535
- End
- Begin VB.ListBox List1
- Height = 4155
- ItemData = "Font.frx":0000
- Left = 4560
- List = "Font.frx":0046
- MultiSelect = 1 'Simple
- TabIndex = 45
- Top = 360
- Width = 2295
- End
- Begin VB.Frame Frame4
- Caption = "OK and Cancel Button Options"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1485
- Left = 120
- TabIndex = 44
- Top = 120
- Width = 4215
- Begin VB.CheckBox CustomCancelCaptionCheck
- Caption = "Change &Cancel Button Caption"
- Height = 285
- Left = 120
- TabIndex = 4
- Top = 990
- Width = 2865
- End
- Begin VB.TextBox CustomCancelCaptionText
- Height = 345
- Left = 3060
- TabIndex = 5
- Text = "E&xit"
- Top = 990
- Width = 945
- End
- Begin VB.TextBox CustomButtonCaptionText
- Height = 345
- Left = 3060
- TabIndex = 3
- Text = "&Select"
- Top = 570
- Width = 945
- End
- Begin VB.CheckBox CustomButtonCaptionCheck
- Caption = "Change &OK Button Caption"
- Height = 285
- Left = 120
- TabIndex = 2
- Top = 600
- Width = 2865
- End
- Begin VB.CheckBox HideCancelCheck
- Caption = "Hide Cancel B&utton"
- Height = 285
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 1845
- End
- Begin VB.CheckBox CancelErrorCheck
- Caption = "&Raise Error On Cancel"
- Height = 285
- Left = 2130
- TabIndex = 1
- Top = 240
- Width = 1905
- End
- End
- Begin VB.Frame Frame7
- Caption = "Results"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 13.5
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 4545
- Left = 6960
- TabIndex = 38
- Top = 1200
- Width = 2535
- Begin VB.TextBox SampleFontText
- Height = 1305
- Left = 120
- TabIndex = 46
- Text = "AaBbZzYy1234567890"
- Top = 3120
- Width = 2295
- End
- Begin VB.TextBox FontColorText
- Height = 315
- Left = 1110
- Locked = -1 'True
- TabIndex = 17
- Text = "&H0"
- Top = 450
- Width = 885
- End
- Begin VB.TextBox FontStyleNameText
- Enabled = 0 'False
- Height = 315
- Left = 1110
- Locked = -1 'True
- TabIndex = 20
- Top = 1560
- Width = 1305
- End
- Begin VB.TextBox FontSizeText
- Enabled = 0 'False
- Height = 315
- Left = 1110
- Locked = -1 'True
- TabIndex = 19
- Top = 1200
- Width = 1305
- End
- Begin VB.TextBox FontNameText
- Enabled = 0 'False
- Height = 315
- Left = 1110
- Locked = -1 'True
- TabIndex = 18
- Top = 840
- Width = 1305
- End
- Begin VB.CheckBox BoldCheck
- Caption = "&Bold"
- Height = 255
- Left = 120
- TabIndex = 21
- Top = 2070
- Width = 705
- End
- Begin VB.CheckBox StrikeThruCheck
- Caption = "Strike&Thru"
- Height = 255
- Left = 1110
- TabIndex = 24
- Top = 2430
- Width = 1095
- End
- Begin VB.CheckBox UnderLineCheck
- Caption = "Under&line"
- Height = 255
- Left = 1110
- TabIndex = 23
- Top = 2070
- Width = 1095
- End
- Begin VB.CheckBox ItalicCheck
- Caption = "&Italic"
- Height = 255
- Left = 120
- TabIndex = 22
- Top = 2430
- Width = 705
- End
- Begin VB.PictureBox FontColorPic
- BackColor = &H00000000&
- FillColor = &H00FFFFFF&
- Height = 315
- Left = 2040
- ScaleHeight = 255
- ScaleWidth = 315
- TabIndex = 40
- Top = 450
- Width = 375
- End
- Begin VB.Label Label9
- AutoSize = -1 'True
- Caption = "Sample:"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 195
- Left = 120
- TabIndex = 48
- Top = 2880
- Width = 690
- End
- Begin VB.Label Label20
- AutoSize = -1 'True
- Caption = "Style Name"
- Height = 195
- Left = 120
- TabIndex = 43
- Top = 1620
- Width = 810
- End
- Begin VB.Label Label10
- AutoSize = -1 'True
- Caption = "Size"
- Height = 195
- Left = 120
- TabIndex = 42
- Top = 1260
- Width = 300
- End
- Begin VB.Label Label5
- AutoSize = -1 'True
- Caption = "Name"
- Height = 195
- Left = 120
- TabIndex = 41
- Top = 870
- Width = 420
- End
- Begin VB.Label Label3
- AutoSize = -1 'True
- Caption = "Color Value"
- Height = 195
- Left = 120
- TabIndex = 39
- Top = 510
- Width = 810
- End
- End
- Begin VB.Frame Frame6
- Caption = "Help Options"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1455
- Index = 1
- Left = 120
- TabIndex = 25
- Top = 4560
- Width = 6735
- Begin VB.OptionButton HelpContextOpt
- Caption = "Help Co&ntext"
- Height = 255
- Left = 180
- TabIndex = 29
- Top = 660
- Value = -1 'True
- Width = 1245
- End
- Begin VB.TextBox HelpFileText
- Height = 315
- Left = 1410
- TabIndex = 27
- Top = 210
- Width = 4125
- End
- Begin VB.OptionButton HelpKeyOpt
- Caption = "Help &Key"
- Height = 255
- Left = 180
- TabIndex = 32
- Top = 1080
- Width = 1245
- End
- Begin VB.TextBox HelpContextNumberText
- Height = 315
- Left = 2880
- TabIndex = 31
- Top = 630
- Width = 1005
- End
- Begin VB.TextBox HelpKeyText
- Height = 315
- Left = 2880
- TabIndex = 34
- Top = 1050
- Width = 1005
- End
- Begin VB.CommandButton Browse
- Caption = "Bro&wse..."
- Height = 375
- Left = 5640
- TabIndex = 28
- Top = 200
- Width = 975
- End
- Begin VB.Label Label6
- Caption = "&Help File Name"
- Height = 255
- Left = 150
- TabIndex = 26
- Top = 270
- Width = 1155
- End
- Begin VB.Label Label7
- Caption = "Context Number"
- Height = 255
- Left = 1620
- TabIndex = 30
- Top = 690
- Width = 1155
- End
- Begin VB.Label Label8
- Caption = "Help Key Word"
- Height = 255
- Left = 1620
- TabIndex = 33
- Top = 1110
- Width = 1155
- End
- End
- Begin VB.Frame Frame3
- Caption = "Dialog Box Position"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1455
- Left = 120
- TabIndex = 37
- Top = 1680
- Width = 4215
- Begin VB.CheckBox SetDlgPosCheck
- Caption = "Set &Dialog Position"
- Height = 285
- Left = 120
- TabIndex = 6
- Top = 240
- Width = 1845
- End
- Begin VB.CheckBox SetDlgPosToScreenCheck
- Caption = "Set Dialog &Position Relative To Screen"
- Height = 285
- Left = 360
- TabIndex = 7
- Top = 630
- Width = 3075
- End
- Begin VB.TextBox XPosText
- Height = 345
- Left = 1380
- TabIndex = 9
- Text = "0"
- Top = 990
- Width = 555
- End
- Begin VB.TextBox YPosText
- Height = 345
- Left = 2880
- TabIndex = 11
- Text = "0"
- Top = 990
- Width = 555
- End
- Begin VB.Label Label1
- Caption = "&X Position"
- Height = 225
- Left = 540
- TabIndex = 8
- Top = 1050
- Width = 765
- End
- Begin VB.Label Label2
- Caption = "&Y Position"
- Height = 225
- Left = 2040
- TabIndex = 10
- Top = 1080
- Width = 735
- End
- End
- Begin VB.Frame Frame2
- Caption = "Other Options"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1335
- Index = 0
- Left = 120
- TabIndex = 36
- Top = 3210
- Width = 4215
- Begin VB.CheckBox RaiseEventCheck
- Caption = "Raise Callback &Event"
- Height = 285
- Left = 120
- TabIndex = 16
- Top = 960
- Width = 1875
- End
- Begin VB.CheckBox ChangeSampleCheck
- Caption = "Change ""Sample"" Text"
- Height = 285
- Left = 120
- TabIndex = 14
- Top = 630
- Width = 1965
- End
- Begin VB.TextBox SampleText
- Height = 315
- Left = 2130
- TabIndex = 15
- Text = "1234AaDd"
- Top = 630
- Width = 1965
- End
- Begin VB.TextBox FontCaptionText
- Height = 315
- Left = 1590
- TabIndex = 13
- Text = "Font"
- Top = 240
- Width = 2505
- End
- Begin VB.Label Label22
- Caption = "Di&alog Box Caption"
- Height = 255
- Left = 120
- TabIndex = 12
- Top = 270
- Width = 1455
- End
- End
- Begin VB.Label Label4
- AutoSize = -1 'True
- Caption = "Flags:"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 195
- Left = 4560
- TabIndex = 47
- Top = 120
- Width = 525
- End
- Attribute VB_Name = "FontForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim WithEvents dwCmdDialog As dwFont
- Attribute dwCmdDialog.VB_VarHelpID = -1
- Private Sub Browse_Click()
- Dim dwCmdDialog As dwFileOpenSave
- Dim lres As Long
- Dim lstr As String
- Set dwCmdDialog = New dwFileOpenSave
- dwCmdDialog.DialogTitle = "Select Help File"
- dwCmdDialog.Filter = "Help (*.hlp)|*.hlp|All Files (*.*)|*.*"
- dwCmdDialog.DlgWindowOwner = Me.hWnd
- dwCmdDialog.SetDialogPosition = True
- dwCmdDialog.PosX = 50
- dwCmdDialog.PosY = 50
- dwCmdDialog.CustomOkButtonCaption = True
- dwCmdDialog.OkButtonCaption = "Select"
- dwCmdDialog.Flags = glmcdOFNEnableHook Or glmcdOFNLongNames Or glmcdOFNFileMustexist Or glmcdOFNNoChangeDir Or glmcdOFNHideReadOnly
- If WindowsVersion <> 35 Then
- dwCmdDialog.Flags = dwCmdDialog.Flags Or glmcdOFNExplorer
- End If
- lres = dwCmdDialog.ShowOpen
- If lres = 1 Then
- HelpFileText.Text = dwCmdDialog.filename
- End If
- Set dwCmdDialog = Nothing
- End Sub
- Private Sub Form_Load()
- If SetDlgPosCheck.Value Then
- SetDlgPosToScreenCheck.Enabled = True
- XPosText.Enabled = True
- YPosText.Enabled = True
- Else
- SetDlgPosToScreenCheck.Enabled = False
- XPosText.Enabled = False
- YPosText.Enabled = False
- End If
- ' Initialize list box
- List1.Selected(0) = True ' use screen fonts
- List1.Selected(1) = True ' use printer fonts
- List1.Selected(2) = True ' show help button
- List1.Selected(3) = True ' enable hook
- List1.Selected(7) = True ' use style
- List1.Selected(8) = True ' show effects
- If HelpContextOpt.Value Then
- HelpContextNumberText.Enabled = True
- HelpKeyText.Enabled = False
- HelpKeyText.Text = ""
- Else
- HelpKeyText.Enabled = True
- HelpContextNumberText.Enabled = False
- HelpContextNumberText.Text = ""
- End If
- End Sub
- Private Sub HelpContextOpt_Click()
- HelpContextNumberText.Enabled = True
- HelpKeyText.Enabled = False
- HelpKeyText.Text = ""
- End Sub
- Private Sub HelpKeyOpt_Click()
- HelpKeyText.Enabled = True
- HelpContextNumberText.Enabled = False
- HelpContextNumberText.Text = ""
- End Sub
- Private Sub SetDlgPosCheck_Click()
- If SetDlgPosCheck.Value Then
- SetDlgPosToScreenCheck.Enabled = True
- XPosText.Enabled = True
- YPosText.Enabled = True
- Else
- SetDlgPosToScreenCheck.Enabled = False
- XPosText.Enabled = False
- YPosText.Enabled = False
- End If
- End Sub
- Private Sub ShowFontBut_Click()
- Dim lres As Long
- Dim lstr As String, fcolor As String
- Set dwCmdDialog = New dwFont
- dwCmdDialog.DialogTitle = FontCaptionText.Text
- '** Note, you can set the owner to 0, which would make the dialog
- '** a child of the desktop. This makes it a psuedo-modeless dialog.
- dwCmdDialog.DlgWindowOwner = Me.hWnd
- dwCmdDialog.HideCancel = HideCancelCheck.Value
- dwCmdDialog.SetDialogPosition = SetDlgPosCheck.Value
- dwCmdDialog.SetDialogRelativeToScreen = SetDlgPosToScreenCheck.Value
- dwCmdDialog.PosX = Val(XPosText.Text)
- dwCmdDialog.PosY = Val(YPosText.Text)
- dwCmdDialog.CustomOkButtonCaption = CustomButtonCaptionCheck.Value
- dwCmdDialog.OkButtonCaption = CustomButtonCaptionText.Text
- dwCmdDialog.CustomCancelButtonCaption = CustomCancelCaptionCheck.Value
- dwCmdDialog.CancelButtonCaption = CustomCancelCaptionText.Text
- dwCmdDialog.Flags = GetFontFlags()
- dwCmdDialog.RaiseCallbackEvent = RaiseEventCheck.Value
- dwCmdDialog.CancelError = CancelErrorCheck.Value
- dwCmdDialog.CustomSampleText = ChangeSampleCheck.Value
- dwCmdDialog.SampleText = SampleText.Text
- dwCmdDialog.HelpFile = Trim$(HelpFileText.Text)
- If dwCmdDialog.HelpFile <> "" Then
- If HelpContextOpt.Value Then
- dwCmdDialog.HelpCommand = glmcdHCContext
- dwCmdDialog.HelpContext = Val(HelpContextNumberText.Text)
- Else
- dwCmdDialog.HelpCommand = glmcdHCKey
- dwCmdDialog.HelpKey = HelpKeyText.Text
- End If
- End If
- fcolor = Trim$(FontColorText.Text)
- If Right$(fcolor, 1) <> "&" Then fcolor = fcolor & "&"
- dwCmdDialog.Color = Val(fcolor)
- dwCmdDialog.FontName = FontNameText.Text
- dwCmdDialog.FontSize = Val(FontSizeText.Text)
- dwCmdDialog.FontStyleName = FontStyleNameText.Text
- dwCmdDialog.FontBold = BoldCheck.Value
- dwCmdDialog.FontItalic = ItalicCheck.Value
- dwCmdDialog.FontUnderline = UnderLineCheck.Value
- dwCmdDialog.FontStrikethru = StrikeThruCheck.Value
- On Error GoTo dlgerror
- lres = dwCmdDialog.ShowFont
- On Error GoTo 0
- If lres = 1 Then
- FontColorPic.BackColor = dwCmdDialog.Color
- FontColorText.Text = "&H" & Hex$(dwCmdDialog.Color)
- FontNameText.Text = dwCmdDialog.FontName
- FontSizeText.Text = dwCmdDialog.FontSize
- If dwCmdDialog.FontUnderline Then UnderLineCheck.Value = vbChecked Else UnderLineCheck.Value = vbUnchecked
- If dwCmdDialog.FontStrikethru Then StrikeThruCheck.Value = vbChecked Else StrikeThruCheck.Value = vbUnchecked
- If dwCmdDialog.FontBold Then BoldCheck.Value = vbChecked Else BoldCheck.Value = vbUnchecked
- If dwCmdDialog.FontItalic Then ItalicCheck.Value = vbChecked Else ItalicCheck.Value = vbUnchecked
- FontStyleNameText.Text = dwCmdDialog.FontStyleName
- SampleFontText.ForeColor = dwCmdDialog.Color
-
- ' Used to avoid error caused by trying to set FontName to a
- ' printer font.
- On Error Resume Next
- SampleFontText.FontName = dwCmdDialog.FontName
- On Error GoTo 0
-
- SampleFontText.FontSize = dwCmdDialog.FontSize
- SampleFontText.FontUnderline = dwCmdDialog.FontUnderline
- SampleFontText.FontStrikethru = dwCmdDialog.FontStrikethru
- SampleFontText.FontBold = dwCmdDialog.FontBold
- SampleFontText.FontItalic = dwCmdDialog.FontItalic
- End If
-
- Set dwCmdDialog = Nothing
- Exit Sub
- dlgerror:
- Debug.Print Err.Description
- MsgBox "Error &H" & Hex$(Err.Number) & " occurred, " & Err.Description, vbOKOnly, "Font dialog error"
- Set dwCmdDialog = Nothing
- Exit Sub
- End Sub
- Private Function GetFontFlags() As Long
- Dim lcount As Long, lindex As Long
- Dim flagvalue As Long
- lindex = List1.ListCount
- For lcount = 0 To lindex - 1 Step 1
- If List1.Selected(lcount) Then
- flagvalue = flagvalue + 2 ^ lcount
- End If
- Next
- GetFontFlags = flagvalue
- End Function
-