home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
- Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
- Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form EditorForm
- Caption = "RTFPad"
- ClientHeight = 5730
- ClientLeft = 2040
- ClientTop = 1965
- ClientWidth = 11160
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 5730
- ScaleWidth = 11160
- Begin RichTextLib.RichTextBox RichTextBox1
- Height = 3630
- Left = 150
- TabIndex = 0
- Top = 750
- Width = 10620
- _ExtentX = 18733
- _ExtentY = 6403
- _Version = 393217
- Enabled = -1 'True
- HideSelection = 0 'False
- ScrollBars = 2
- RightMargin = 4989.764
- TextRTF = $"RTBox.frx":0000
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Tahoma"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- End
- Begin ComctlLib.Slider Slider2
- Height = 300
- Left = 60
- TabIndex = 2
- TabStop = 0 'False
- Top = 360
- Width = 10800
- _ExtentX = 19050
- _ExtentY = 529
- _Version = 393216
- LargeChange = 4
- Max = 15
- End
- Begin ComctlLib.Slider Slider1
- Height = 285
- Left = 60
- TabIndex = 1
- TabStop = 0 'False
- Top = 120
- Width = 10800
- _ExtentX = 19050
- _ExtentY = 503
- _Version = 393216
- LargeChange = 4
- Max = 15
- TickStyle = 3
- End
- Begin VB.Frame Frame1
- Height = 750
- Left = 15
- TabIndex = 3
- Top = -30
- Width = 11040
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 195
- Top = 4515
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- FontSize = 1.17491e-38
- End
- Begin VB.Menu FileMenu
- Caption = "File"
- Begin VB.Menu FileNew
- Caption = "New"
- End
- Begin VB.Menu FileOpen
- Caption = "Open"
- End
- Begin VB.Menu separator1
- Caption = "-"
- End
- Begin VB.Menu FileSave
- Caption = "Save"
- End
- Begin VB.Menu FileSaveAs
- Caption = "Save As"
- End
- Begin VB.Menu separator2
- Caption = "-"
- End
- Begin VB.Menu FilePrint
- Caption = "Print"
- End
- Begin VB.Menu separator3
- Caption = "-"
- End
- Begin VB.Menu FileExit
- Caption = "Exit"
- End
- End
- Begin VB.Menu EditMenu
- Caption = "Edit"
- Begin VB.Menu EditCopy
- Caption = "Copy"
- End
- Begin VB.Menu EditCut
- Caption = "Cut"
- End
- Begin VB.Menu EditPaste
- Caption = "Paste"
- End
- Begin VB.Menu EditSelect
- Caption = "Select All"
- End
- Begin VB.Menu EditSeparator
- Caption = "-"
- End
- Begin VB.Menu EditFind
- Caption = "Find"
- End
- End
- Begin VB.Menu FormatMenu
- Caption = "Format"
- Begin VB.Menu EditFont
- Caption = "Font"
- End
- Begin VB.Menu FormatSeparator
- Caption = "-"
- End
- Begin VB.Menu FormatBold
- Caption = "Bold"
- End
- Begin VB.Menu FormatItalic
- Caption = "Italic"
- End
- Begin VB.Menu FormatUnderline
- Caption = "Underline"
- End
- Begin VB.Menu FormatRegular
- Caption = "Regular"
- End
- End
- Attribute VB_Name = "EditorForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Private Sub EditCopy_Click()
- Clipboard.SetText RichTextBox1.SelRTF
- End Sub
- Private Sub EditCut_Click()
- Clipboard.SetText RichTextBox1.SelRTF
- RichTextBox1.SelRTF = ""
- End Sub
- Private Sub EditFind_Click()
- 'SearchForm.Show
- SetWindowPos SearchForm.hwnd, HWND_TOPMOST, Me.CurrentX, Me.CurrentY, 470, 155, SWP_SHOWWINDOW
- End Sub
- Private Sub EditFont_Click()
- On Error Resume Next
- CommonDialog1.Flags = cdlCFBoth
- CommonDialog1.ShowFont
- RichTextBox1.SelFontName = CommonDialog1.FontName
- RichTextBox1.SelBold = CommonDialog1.FontBold
- RichTextBox1.SelItalic = CommonDialog1.FontItalic
- RichTextBox1.SelFontSize = CommonDialog1.FontSize
- End Sub
- Private Sub EditPaste_Click()
- If Clipboard.GetFormat(vbCFRTF) Then
- RichTextBox1.SelRTF = Clipboard.GetData(vbCFRTF)
- ElseIf Clipboard.GetFormat(vbCFText) Then
- RichTextBox1.SelText = Clipboard.GetText
- End If
- End Sub
- Private Sub EditSelect_Click()
- RichTextBox1.SelStart = 0
- RichTextBox1.SelLength = Len(RichTextBox1.Text)
- End Sub
- Private Sub FileNew_Click()
- RichTextBox1.Text = ""
- End Sub
- Private Sub FileOpen_Click()
- Dim txt As String
- Dim FNum As Integer
- On Error GoTo FileError:
- CommonDialog1.CancelError = True
- CommonDialog1.Flags = cdlOFNFileMustExist
- CommonDialog1.DefaultExt = "RTF"
- CommonDialog1.Filter = "RTF Files|*.RTF|Text Files|*.TXT|All Files|*.*"
- CommonDialog1.InitDir = App.Path
- CommonDialog1.ShowOpen
- If UCase(Right(CommonDialog1.FileName, 3)) = "RTF" Then
- tmode = rtfRTF
- Else
- tmode = rtfText
- End If
- RichTextBox1.LoadFile CommonDialog1.FileName, tmode
- OpenFile = CommonDialog1.FileName
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while opening file " & CommonDialog1.FileName
- OpenFile = ""
- End Sub
- Private Sub FilePrint_Click()
- Dim lastPosition As Long, lastSelection As Long
- EditSelect_Click
- RichTextBox1.SelPrint Printer.hDC
- RichTextBox1.SelStart = lastPosition
- RichTextBox1.SelLength = lastSelection
- End Sub
- Private Sub FileSave_Click()
- Dim FNum As Integer
- Dim txt As String
- If OpenFile = "" Then
- FileSaveAs_Click
- Exit Sub
- End If
- On Error GoTo FileError
- EditSelect_Click
- RichTextBox1.SaveFile OpenFile
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while saving file " & OpenFile
- OpenFile = ""
- End Sub
- Private Sub FileSaveAs_Click()
- Dim txt As String
- Dim FNum As Integer
- On Error GoTo FileError:
- CommonDialog1.CancelError = True
- CommonDialog1.DefaultExt = "RTF"
- CommonDialog1.Filter = "RTF Files|*.RTF|Text Files|*.TXT|All Files|*.*"
- CommonDialog1.ShowSave
- RichTextBox1.SaveFile CommonDialog1.FileName, rtfRTF
- OpenFile = CommonDialog1.FileName
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while opening file " & CommonDialog1.FileName
- OpenFile = ""
- End Sub
- Private Sub Form_Load()
- ' Slider1.Width = EditorForm.ScaleX(7.5, vbInches, vbTwips)
- ' Slider2.Width = EditorForm.ScaleX(7.5, vbInches, vbTwips)
- ' RichTextBox1.Top = EditorForm.Top + Frame1.Height + 100
- ' RichTextBox1.Width = EditorForm.ScaleX(7.5, vbInches, vbTwips) + 8 * Screen.TwipsPerPixelX
- ' RichTextBox1.Height = EditorForm.Height - Frame1.Height - 12 * Screen.TwipsPerPixelX
- ' RichTextBox1.RightMargin = RichTextBox1.Width - 15 * Screen.TwipsPerPixelX
- End Sub
- Private Sub Form_Resize()
- Slider1.Width = EditorForm.ScaleX(7.5, vbInches, vbTwips) + 6 * Screen.TwipsPerPixelX
- Slider2.Width = EditorForm.ScaleX(7.5, vbInches, vbTwips) + 6 * Screen.TwipsPerPixelX
- RichTextBox1.Top = Frame1.Top + Frame1.Height + 100
- RichTextBox1.Width = EditorForm.ScaleX(7.5, vbInches, vbTwips) + 12 * Screen.TwipsPerPixelX
- RichTextBox1.Height = EditorForm.ScaleHeight - Frame1.Height - 12 * Screen.TwipsPerPixelX
- RichTextBox1.RightMargin = RichTextBox1.Width - 15 * Screen.TwipsPerPixelX
- End Sub
- Private Sub FormatBold_Click()
- FormatBold.Checked = Not FormatBold.Checked
- RichTextBox1.SelBold = FormatBold.Checked
- End Sub
- Private Sub FormatItalic_Click()
- FormatItalic.Checked = Not FormatItalic.Checked
- RichTextBox1.SelItalic = FormatItalic.Checked
- End Sub
- Private Sub FormatRegular_Click()
- FormatBold.Checked = False
- FormatItalic.Checked = False
- FormatUnderline.Checked = False
- RichTextBox1.SelBold = False
- RichTextBox1.SelItalic = False
- RichTextBox1.SelUnderline = False
- End Sub
- Private Sub FormatUnderline_Click()
- FormatUnderline.Checked = Not FormatUnderline.Checked
- RichTextBox1.SelUnderline = FormatUnderline.Checked
- End Sub
- Private Sub RichTextBox1_KeyUp(KeyCode As Integer, Shift As Integer)
- ' Select word, or sentence
- If Shift = vbCtrlMask Then
- Select Case KeyCode
- ' If Ctrl+S:
- Case vbKeyS
- RichTextBox1.Span ".?!", False, True
- SelectionStart = RichTextBox1.SelStart
- ' Select to the end of the sentence.
- RichTextBox1.Span ".?!", True, True
- ' Extend selection to include punctuation.
- SelectionEnd = RichTextBox1.SelStart + RichTextBox1.SelLength
- RichTextBox1.SelStart = SelectionStart
- RichTextBox1.SelLength = SelectionEnd - SelectionStart
-
- ' If Ctrl+W:
- Case vbKeyW
- ' Select to the end of the word.
- RichTextBox1.Span " ,;:.?!", False, True
- SelectionStart = RichTextBox1.SelStart
- ' Select to the end of the word
- RichTextBox1.Span " ,;:.?!", True, True
-
- SelectionEnd = RichTextBox1.SelStart + RichTextBox1.SelLength
- RichTextBox1.SelStart = SelectionStart
- RichTextBox1.SelLength = SelectionEnd - SelectionStart
-
- End Select
- End If
- ' Move pointer by word or sentence
- If Shift = (vbCtrlMask Or vbShiftMask) Then
- Select Case KeyCode
- Case vbKeyS
- ' Move pointer to end of sentence.
- RichTextBox1.UpTo ".?!", True, False
- Case vbKeyW
- ' Move pointer to end of word.
- RichTextBox1.UpTo " ,;:.?!", True, False
- End Select
- End If
- End Sub
- Private Sub RichTextBox1_SelChange()
- If Not IsNull(RichTextBox1.SelBold) Then FormatBold.Checked = RichTextBox1.SelBold
- If Not IsNull(RichTextBox1.SelItalic) Then FormatItalic.Checked = RichTextBox1.SelItalic
- If Not IsNull(RichTextBox1.SelUnderline) Then FormatUnderline.Checked = RichTextBox1.SelUnderline
- ' Change the sliders' positions according to the selection's indentation
- If IsNull(RichTextBox1.SelIndent) Then
- Slider1.Enabled = False
- Slider2.Enabled = False
- Exit Sub
- Else
- Slider1.Enabled = True
- Slider2.Enabled = True
- On Error Resume Next
- Slider1.Value = RichTextBox1.SelIndent * Slider1.Max / RichTextBox1.RightMargin
- Slider2.Value = (RichTextBox1.SelHangingIndent / RichTextBox1.RightMargin) * Slider2.Max + Slider1.Value
- End If
- End Sub
- Private Sub Slider1_Scroll()
- RichTextBox1.SelIndent = RichTextBox1.RightMargin * (Slider1.Value / Slider1.Max)
- Slider2_Scroll
- End Sub
- Private Sub Slider2_Scroll()
- RichTextBox1.SelHangingIndent = RichTextBox1.RightMargin * ((Slider2.Value - Slider1.Value) / Slider2.Max)
- End Sub
-