home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch21 / htmledit / htmledit.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-05-18  |  9.3 KB  |  285 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.1#0"; "RICHTX32.OCX"
  4. Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "SHDOCVW.DLL"
  5. Begin VB.Form HTMLEdit 
  6.    Caption         =   "HTML Editor"
  7.    ClientHeight    =   6285
  8.    ClientLeft      =   390
  9.    ClientTop       =   1590
  10.    ClientWidth     =   10245
  11.    LinkTopic       =   "Form1"
  12.    PaletteMode     =   1  'UseZOrder
  13.    ScaleHeight     =   6285
  14.    ScaleWidth      =   10245
  15.    Begin SHDocVwCtl.WebBrowser WebBrowser1 
  16.       Height          =   3180
  17.       Left            =   90
  18.       TabIndex        =   0
  19.       Top             =   2955
  20.       Width           =   9960
  21.       ExtentX         =   17568
  22.       ExtentY         =   5609
  23.       ViewMode        =   1
  24.       Offline         =   0
  25.       Silent          =   0
  26.       RegisterAsBrowser=   0
  27.       RegisterAsDropTarget=   0
  28.       AutoArrange     =   -1  'True
  29.       NoClientEdge    =   -1  'True
  30.       AlignLeft       =   0   'False
  31.       ViewID          =   "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
  32.       Location        =   ""
  33.    End
  34.    Begin RichTextLib.RichTextBox RichTextBox1 
  35.       Height          =   2775
  36.       Left            =   60
  37.       TabIndex        =   1
  38.       Top             =   30
  39.       Width           =   10020
  40.       _ExtentX        =   17674
  41.       _ExtentY        =   4895
  42.       _Version        =   393217
  43.       Enabled         =   -1  'True
  44.       HideSelection   =   0   'False
  45.       ScrollBars      =   3
  46.       TextRTF         =   $"HTMLEdit.frx":0000
  47.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  48.          Name            =   "Times New Roman"
  49.          Size            =   9.75
  50.          Charset         =   0
  51.          Weight          =   400
  52.          Underline       =   0   'False
  53.          Italic          =   0   'False
  54.          Strikethrough   =   0   'False
  55.       EndProperty
  56.    End
  57.    Begin MSComDlg.CommonDialog CommonDialog1 
  58.       Left            =   7005
  59.       Top             =   -135
  60.       _ExtentX        =   847
  61.       _ExtentY        =   847
  62.       _Version        =   393216
  63.       FontSize        =   1.17485e-38
  64.    End
  65.    Begin VB.Menu FileMenu 
  66.       Caption         =   "File"
  67.       Begin VB.Menu FileNew 
  68.          Caption         =   "New Document"
  69.       End
  70.       Begin VB.Menu FileOpen 
  71.          Caption         =   "Open Document"
  72.       End
  73.       Begin VB.Menu FileSave 
  74.          Caption         =   "Save Document"
  75.       End
  76.       Begin VB.Menu FileSaveAs 
  77.          Caption         =   "Save As ..."
  78.       End
  79.       Begin VB.Menu NavigateTo 
  80.          Caption         =   "Open URL"
  81.       End
  82.       Begin VB.Menu FileExit 
  83.          Caption         =   "Exit"
  84.       End
  85.    End
  86.    Begin VB.Menu EditMenu 
  87.       Caption         =   "Edit"
  88.       Begin VB.Menu EditCopy 
  89.          Caption         =   "Copy"
  90.          Shortcut        =   ^C
  91.       End
  92.       Begin VB.Menu EditCut 
  93.          Caption         =   "Cut"
  94.          Shortcut        =   ^X
  95.       End
  96.       Begin VB.Menu EditPaste 
  97.          Caption         =   "Paste"
  98.          Shortcut        =   +{INSERT}
  99.       End
  100.       Begin VB.Menu EditClear 
  101.          Caption         =   "Clear"
  102.       End
  103.       Begin VB.Menu EditAll 
  104.          Caption         =   "Select All"
  105.          Shortcut        =   ^A
  106.       End
  107.       Begin VB.Menu ShorcutSeparator1 
  108.          Caption         =   "-"
  109.       End
  110.       Begin VB.Menu EditRender 
  111.          Caption         =   "Render Document"
  112.          Shortcut        =   ^R
  113.       End
  114.    End
  115.    Begin VB.Menu shortcutMenu 
  116.       Caption         =   "Edit"
  117.       Enabled         =   0   'False
  118.       Visible         =   0   'False
  119.       Begin VB.Menu ShortcutCopy 
  120.          Caption         =   "Copy"
  121.       End
  122.       Begin VB.Menu ShortcutCut 
  123.          Caption         =   "Cut"
  124.       End
  125.       Begin VB.Menu ShortcutPaste 
  126.          Caption         =   "Paste"
  127.       End
  128.       Begin VB.Menu ShortcutClear 
  129.          Caption         =   "Clear"
  130.       End
  131.       Begin VB.Menu ShortcutAll 
  132.          Caption         =   "Select All"
  133.       End
  134.       Begin VB.Menu ShortcutSeparator2 
  135.          Caption         =   "-"
  136.       End
  137.       Begin VB.Menu ShortcutRender 
  138.          Caption         =   "Render Document"
  139.       End
  140.    End
  141. Attribute VB_Name = "HTMLEdit"
  142. Attribute VB_GlobalNameSpace = False
  143. Attribute VB_Creatable = False
  144. Attribute VB_PredeclaredId = True
  145. Attribute VB_Exposed = False
  146. Dim RestoreText
  147. Dim OpenFileName
  148. Dim ResizeWindows As Boolean
  149. Dim DragStartY As Integer
  150. Dim HTMLHeight As Integer, WebHeight As Integer
  151. Private Sub EditAll_Click()
  152.     HTMLPad.RichTextBox1.SelStart = 0
  153.     HTMLPad.RichTextBox1.SelLength = Len(HTMLPad.RichTextBox1.Text)
  154. End Sub
  155. Private Sub EditClear_Click()
  156.     HTMLPad.RichTextBox1.Text = ""
  157. End Sub
  158. Private Sub EditCopy_Click()
  159.     Clipboard.Clear
  160.     Clipboard.SetText RichTextBox1.SelText
  161. End Sub
  162. Private Sub EditCut_Click()
  163.     Clipboard.Clear
  164.     Clipboard.SetText RichTextBox1.SelText
  165.     RichTextBox1.SelText = ""
  166. End Sub
  167. Private Sub EditPaste_Click()
  168.     Temp = Clipboard.GetText(vbCFText)
  169.     SelTextStart = RichTextBox1.SelStart
  170.     SelTextEnd = Len(Temp)
  171.     RichTextBox1.SelText = Temp
  172.     RichTextBox1.SelFontName = RichTextBox1.Font
  173.     RichTextBox1.SelBold = False
  174.     RichTextBox1.SelItalic = False
  175.     RichTextBox1.SelUnderline = False
  176.     RichTextBox1.SelColor = vbBlack
  177. End Sub
  178. Private Sub EditRender_Click()
  179.     RenderDocument
  180. End Sub
  181. Private Sub EditUndo_Click()
  182.     RichTextBox1.Text = RestoreText
  183. End Sub
  184. Private Sub EditSelect_Click()
  185.     RichTextBox1.SelStart = 0
  186.     RichTextBox1.SelLength = Len(RichTextBox1.Text)
  187. End Sub
  188. Private Sub FileNew_Click()
  189.     RichTextBox1.Text = ""
  190.     OpenFileName = ""
  191. End Sub
  192. Private Sub FileOpen_Click()
  193. On Error Resume Next
  194.     CommonDialog1.Filter = "HML Documents|*.htm;*.html|ActiveX Documents|*.vbd|All Files|*.*"
  195.     CommonDialog1.ShowOpen
  196.     If Trim(CommonDialog1.FileName) = "" Then Exit Sub
  197.     dPos = InStr(CommonDialog1.FileName, ".")
  198.     If dPos > 0 Then ext = Mid$(CommonDialog1.FileName, dPos + 1)
  199.     If UCase$(ext) = "HTM" Or UCase$(ext) = "HTML" Or UCase$(ext) = "TXT" Then
  200.         RichTextBox1.LoadFile CommonDialog1.FileName, 1
  201.         WebBrowser1.Navigate CommonDialog1.FileName
  202.         OpenFileName = CommonDialog1.FileName
  203.     End If
  204. ' The following lines handle non-HTML file types
  205. ' like sounds and images
  206.     WebBrowser1.Navigate CommonDialog1.FileName
  207. End Sub
  208. Private Sub FileSave_Click()
  209.     If OpenFileName <> "" Then
  210.         RichTextBox1.SaveFile OpenFileName, 1
  211.     Else
  212.         FileSaveAs_Click
  213.     End If
  214. End Sub
  215. Private Sub FileSaveAs_Click()
  216.     CommonDialog1.DefaultExt = "htm"
  217.     CommonDialog1.Filter = "HTML Documents|*.htm|All Files|*.*"
  218.     CommonDialog1.ShowSave
  219.     If CommonDialog1.FileName = "" Then Exit Sub
  220.     RichTextBox1.SaveFile CommonDialog1.FileName, 1
  221.     OpenFile = CommonDialog1.FileName
  222. End Sub
  223. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  224.     If Button = 1 And (Y > RichTextBox1.Top + RichTextBox1.Height) And (Y < WebBrowser1.Top) Then
  225.         Screen.MousePointer = vbSizeNS
  226.         ResizeWindows = True
  227.         DragStartY = Y
  228.         WebHeight = WebBrowser1.Height
  229.         HTMLHeight = RichTextBox1.Height
  230.     End If
  231. End Sub
  232. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  233. On Error Resume Next
  234.     If ResizeWindows Then
  235.         RichTextBox1.Height = HTMLHeight + (Y - DragStartY)
  236.         WebBrowser1.Move WebBrowser1.Left, RichTextBox1.Top + RichTextBox1.Height + 120, WebBrowser1.Width, WebHeight - (Y - DragStartY)
  237.         HTMLEdit.Refresh
  238.     End If
  239. End Sub
  240. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  241.     ResizeWindows = False
  242.     Screen.MousePointer = vbDefault
  243. End Sub
  244. Private Sub Form_Resize()
  245.     RichTextBox1.Width = HTMLEdit.Width - RichTextBox1.Left - 200
  246.     WebBrowser1.Width = RichTextBox1.Width
  247.     RichTextBox1.Height = 0.3 * HTMLEdit.Height
  248.     WebBrowser1.Move WebBrowser1.Left, RichTextBox1.Top _
  249.     + RichTextBox1.Height + 120, WebBrowser1.Width, HTMLEdit.Height _
  250.     - RichTextBox1.Top - RichTextBox1.Height - 940
  251.     WebBrowser1.Navigate App.Path & "\empty.htm"
  252. End Sub
  253. Private Sub NavigateTo_Click()
  254.     URL = InputBox("Enter URL to navigate to")
  255.     If URL <> "" Then
  256.         WebBrowser1.Navigate URL
  257.     End If
  258. End Sub
  259. Private Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  260.     If Button = 2 Then
  261.         PopupMenu shortcutMenu
  262.     End If
  263. End Sub
  264. Private Sub ShortcutAll_Click()
  265.     Call EditAll_Click
  266. End Sub
  267. Private Sub ShortCutClear_Click()
  268.     HTMLEdit.RichTextBox1.Text = ""
  269. End Sub
  270. Private Sub ShortcutCopy_Click()
  271.     Call EditCopy_Click
  272. End Sub
  273. Private Sub ShortcutCut_Click()
  274.     Call EditCut_Click
  275. End Sub
  276. Private Sub ShortcutPaste_Click()
  277.     Call EditPaste_Click
  278. End Sub
  279. Private Sub ShortcutRender_Click()
  280.     RenderDocument
  281. End Sub
  282. Private Sub WebBrowser1_Validate(Cancel As Boolean)
  283. Debug.Print "Error"
  284. End Sub
  285.