⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmrtf.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form frmRTF 
   Caption         =   "Fig. 11.24: RichTextBox Example"
   ClientHeight    =   4410
   ClientLeft      =   2535
   ClientTop       =   1590
   ClientWidth     =   4950
   LinkTopic       =   "Form1"
   ScaleHeight     =   4410
   ScaleWidth      =   4950
   Begin VB.CommandButton cmdUnderline 
      Caption         =   "U"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   -1  'True
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4560
      TabIndex        =   11
      Top             =   840
      Width           =   255
   End
   Begin VB.CommandButton cmdItalic 
      Caption         =   "I"
      BeginProperty Font 
         Name            =   "Roman"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4560
      TabIndex        =   10
      Top             =   480
      Width           =   255
   End
   Begin VB.CommandButton cmdBold 
      Caption         =   "B"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4560
      TabIndex        =   9
      Top             =   120
      Width           =   255
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "Save"
      Height          =   495
      Left            =   3480
      TabIndex        =   8
      Top             =   2520
      Width           =   975
   End
   Begin VB.Frame fraFind 
      Caption         =   "Find Options"
      Height          =   1095
      Left            =   120
      TabIndex        =   4
      Top             =   3120
      Width           =   4335
      Begin VB.CheckBox chkBoxes 
         Caption         =   "No Highlight"
         Height          =   375
         Index           =   8
         Left            =   3000
         TabIndex        =   7
         Top             =   360
         Width           =   1215
      End
      Begin VB.CheckBox chkBoxes 
         Caption         =   "Match Case"
         Height          =   375
         Index           =   4
         Left            =   1680
         TabIndex        =   6
         Top             =   360
         Width           =   1335
      End
      Begin VB.CheckBox chkBoxes 
         Caption         =   "Whole word"
         Height          =   375
         Index           =   2
         Left            =   240
         TabIndex        =   5
         Top             =   360
         Width           =   1335
      End
   End
   Begin VB.CommandButton cmdFind 
      Caption         =   "Find"
      Height          =   495
      Left            =   2160
      TabIndex        =   3
      Top             =   2520
      Width           =   975
   End
   Begin VB.TextBox txtKey 
      Height          =   405
      Left            =   720
      TabIndex        =   0
      Top             =   2520
      Width           =   1215
   End
   Begin RichTextLib.RichTextBox rtfTextBox 
      Height          =   2175
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   4335
      _ExtentX        =   7646
      _ExtentY        =   3836
      _Version        =   393217
      Enabled         =   -1  'True
      ScrollBars      =   2
      TextRTF         =   $"frmRTF.frx":0000
   End
   Begin VB.Label lblPrompt 
      Caption         =   "Name:"
      Height          =   375
      Left            =   150
      TabIndex        =   2
      Top             =   2595
      Width           =   735
   End
End
Attribute VB_Name = "frmRTF"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 11.24
' RichTextBox control example
Option Explicit

Private Sub Form_Load()
   ' Load RTF file into Rich TextBox
   Call rtfTextBox.LoadFile("d:\books\vbhtp\examples\" & _
                         "chap11\RichTextBox\sample.rtf", rtfRTF)
   
   ' Allow selected text to be visible even
   ' after user interacts with Rich TextBox
   rtfTextBox.HideSelection = False
End Sub

Private Sub cmdFind_Click()
   Dim options As Integer
   Dim x As Integer, y As Integer
      
   y = chkBoxes.LBound

   For x = 1 To chkBoxes.Count
    
      ' Sum the search options
      If chkBoxes(y).Value Then
         options = options + y
      End If

      y = y * 2   ' Adjust y for next control array element
   Next x
   
   ' Find text specified in TextBox
   Call rtfTextBox.Find(txtKey.Text, , , options)
End Sub

Private Sub cmdSave_Click()
   ' Save file to disk
   Call rtfTextBox.SaveFile("d:\books\vbhtp\examples\" & _
                         "chap11\RichTextBox\sample.rtf", rtfRTF)
End Sub

Private Sub cmdBold_Click()
   rtfTextBox.SelBold = Not rtfTextBox.SelBold
End Sub

Private Sub cmdItalic_Click()
   rtfTextBox.SelItalic = Not rtfTextBox.SelItalic
End Sub

Private Sub cmdUnderline_Click()
   rtfTextBox.SelUnderline = Not rtfTextBox.SelUnderline
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -