Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Editor e visualizzatore HTML - frmMain.frm

frmMain.frm

Caricato da: Alceus
Scarica il programma completo

  1. Private Declare Function InitCommonControls Lib "Comctl32.dll" () As Long
  2. Dim miamodificata As Boolean
  3. Dim modificata As Boolean
  4. Private Sub Form_Initialize()
  5. Dim x As Long
  6.   x = InitCommonControls
  7. End Sub
  8. Private Sub cmdCattura_Click()
  9.  Dim oggetto As New MSHTML.HTMLDocument
  10.  Dim documento As MSHTML.HTMLDocument
  11.         If pagecode.Text = "" Then
  12.     Set documento = oggetto.createDocumentFromUrl("http://" + txtPage.Text, vbNullString)
  13.     Do While documento.ReadyState <> "complete"
  14.         DoEvents
  15.     Loop
  16.     pagecode.Text = documento.documentElement.outerHTML
  17.     Set documento = Nothing
  18.     Set oggetto = Nothing
  19.     Else
  20.     pagecode.Text = ""
  21.      Set documento = oggetto.createDocumentFromUrl("http://" + txtPage.Text, vbNullString)
  22.     Do While documento.ReadyState <> "complete"
  23.         DoEvents
  24.     Loop
  25.     pagecode.Text = documento.documentElement.outerHTML
  26.     Set documento = Nothing
  27.     Set oggetto = Nothing
  28.     End If
  29.     modificata = True
  30. End Sub
  31. Private Sub cmdPulisci_Click()
  32. WebBrowser1.Document.Script.Document.Clear
  33. WebBrowser1.Document.Script.Document.Write ""
  34. WebBrowser1.Document.Script.Document.Close
  35. RichTextBox1.Text = ""
  36. pagecode.Text = ""
  37. txtPage.Text = ""
  38. End Sub
  39. Private Sub cmdSee_Click()
  40. RichTextBox1.Text = pagecode.Text
  41. End Sub
  42. Private Sub Form_Load()
  43. WebBrowser1.Navigate ""
  44. End Sub
  45. Private Sub Form_Unload(Cancel As Integer)
  46. Dim msg As String
  47. Dim msg2 As String
  48. If miamodificata = True Then
  49. msg = MsgBox("Salvare le modifiche alla tua pagina HTML?", vbExclamation + vbYesNo)
  50. Select Case msg
  51. Case vbYes
  52. On Error GoTo Errore_2
  53. 1 CommonDialog1.Filter = "HTML Files|*.html|HTM files|*htm"
  54. CommonDialog1.ShowSave
  55. If Dir(CommonDialog1.FileName) = "" Then
  56. Open CommonDialog1.FileName For Output As #1
  57. Print #1, RichTextBox1.Text
  58. Close #1
  59.   Else: uguale = MsgBox("Il file " & Form1.CommonDialog1.FileTitle + " è gia esistente. Si desidera sostituirlo?", vbExclamation + vbYesNo, "Editor e visualizzatore HTML")
  60. Select Case uguale
  61. Case vbYes
  62. Open CommonDialog1.FileName For Output As #1
  63. Print #1, RichTextBox1.Text
  64. Close #1
  65. Case vbNo
  66. GoTo 1
  67. Case Else
  68. MsgBox "Errore interno", vbCritical, "Errore interno"
  69. End Select
  70.  End If
  71. Errore_2:
  72. End
  73. Case vbNo
  74. End
  75. Case Else
  76. MsgBox "Errore interno", vbCritical
  77. End
  78. End Select
  79. End If
  80. If modificata = True And miamodificata = False Then
  81. msg2 = MsgBox("Salvare le modifiche alla pagina HTML catturata?", vbExclamation + vbYesNo)
  82. Select Case msg2
  83. Case vbYes
  84. On Error GoTo Errore_3
  85. 2 CommonDialog1.Filter = "HTML Files|*.html|HTM files|*htm"
  86. CommonDialog1.ShowSave
  87. If Dir(CommonDialog1.FileName) = "" Then
  88. Open CommonDialog1.FileName For Output As #1
  89. Print #1, pagecode.Text
  90. Close #1
  91.   Else: uguale = MsgBox("Il file " & Form1.CommonDialog1.FileTitle + " è gia esistente. Si desidera sostituirlo?", vbExclamation + vbYesNo, "Editor e visualizzatore HTML")
  92. Select Case uguale
  93. Case vbYes
  94. Open CommonDialog1.FileName For Output As #1
  95. Print #1, pagecode.Text
  96. Close #1
  97. Case vbNo
  98. GoTo 2
  99. Case Else
  100. MsgBox "Errore interno", vbCritical, "Errore interno"
  101. End
  102. End Select
  103.  End If
  104. Errore_3:
  105. End
  106. Case vbNo
  107. End
  108. Case Else
  109. MsgBox "Errore interno", vbCritical
  110. End
  111. End Select
  112. End If
  113. End Sub
  114. Private Sub mnuAbout_Click()
  115. Form2.Show
  116. End Sub
  117. Private Sub mnuEnd_Click()
  118. End
  119. End Sub
  120. Private Sub mnuOpen_Click()
  121. On Error GoTo Errore
  122. CommonDialog1.Filter = "HTML Files|*.html|HTM Files|*.htm"
  123. CommonDialog1.ShowOpen
  124. Open CommonDialog1.FileName For Input As #1
  125. RichTextBox1.Text = Input(LOF(1), #1)
  126. Close #1
  127. RichTextBox1.SelStart = Len(RichTextBox1.Text)
  128. Errore:
  129. End Sub
  130. Private Sub mnuSave_Click()
  131. On Error GoTo Errore_2
  132. 1 CommonDialog1.Filter = "HTML Files|*.html|HTM files|*htm"
  133. CommonDialog1.ShowSave
  134. If Dir(CommonDialog1.FileName) = "" Then
  135. Open CommonDialog1.FileName For Output As #1
  136. Print #1, RichTextBox1.Text
  137. Close #1
  138.   Else: uguale = MsgBox("Il file " & Form1.CommonDialog1.FileTitle + " è gia esistente. Si desidera sostituirlo?", vbExclamation + vbYesNo, "Editor e visualizzatore HTML")
  139. Select Case uguale
  140. Case vbYes
  141. Open CommonDialog1.FileName For Output As #1
  142. Print #1, RichTextBox1.Text
  143. Close #1
  144. Case vbNo
  145. GoTo 1
  146. Case Else
  147. MsgBox "Errore interno", vbCritical, "Errore interno"
  148. End Select
  149.  End If
  150. Errore_2:
  151. Exit Sub
  152. miamodificata = False
  153. End Sub
  154. Private Sub mnuSaveCapture_Click()
  155. On Error GoTo Errore_3
  156. 2 CommonDialog1.Filter = "HTML Files|*.html|HTM files|*htm"
  157. CommonDialog1.ShowSave
  158. If Dir(CommonDialog1.FileName) = "" Then
  159. Open CommonDialog1.FileName For Output As #1
  160. Print #1, pagecode.Text
  161. Close #1
  162.   Else: uguale = MsgBox("Il file " & Form1.CommonDialog1.FileTitle + " è gia esistente. Si desidera sostituirlo?", vbExclamation + vbYesNo, "Editor e visualizzatore HTML")
  163. Select Case uguale
  164. Case vbYes
  165. Open CommonDialog1.FileName For Output As #1
  166. Print #1, pagecode.Text
  167. Close #1
  168. Case vbNo
  169. GoTo 2
  170. Case Else
  171. MsgBox "Errore interno", vbCritical, "Errore interno"
  172. End
  173. End Select
  174.  End If
  175. Errore_3:
  176. Exit Sub
  177. modificata = False
  178. End Sub
  179. Private Sub RichTextBox1_Change()
  180. WebBrowser1.Document.Script.Document.Clear
  181. WebBrowser1.Document.Script.Document.Write RichTextBox1.Text
  182. WebBrowser1.Document.Script.Document.Close
  183. miamodificata = True
  184. End Sub
  185. Private Sub txtPage_KeyPress(KeyAscii As Integer)
  186. If KeyAscii = vbKeyReturn Then
  187.   cmdCattura_Click
  188. End If
  189. End Sub