home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Java Apple24334892001.psc / JACE / frmEditor.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-08-09  |  4.3 KB  |  120 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmEditor 
  4.    Caption         =   "Untitled - JACE"
  5.    ClientHeight    =   4335
  6.    ClientLeft      =   2760
  7.    ClientTop       =   1215
  8.    ClientWidth     =   6495
  9.    Icon            =   "frmEditor.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MDIChild        =   -1  'True
  12.    ScaleHeight     =   4335
  13.    ScaleWidth      =   6495
  14.    Begin MSComDlg.CommonDialog saveJava 
  15.       Left            =   5400
  16.       Top             =   240
  17.       _ExtentX        =   847
  18.       _ExtentY        =   847
  19.       _Version        =   393216
  20.    End
  21.    Begin VB.TextBox txtsrc 
  22.       BeginProperty Font 
  23.          Name            =   "Courier New"
  24.          Size            =   8.25
  25.          Charset         =   0
  26.          Weight          =   400
  27.          Underline       =   0   'False
  28.          Italic          =   0   'False
  29.          Strikethrough   =   0   'False
  30.       EndProperty
  31.       Height          =   4335
  32.       Left            =   0
  33.       MultiLine       =   -1  'True
  34.       ScrollBars      =   2  'Vertical
  35.       TabIndex        =   0
  36.       Top             =   0
  37.       Width           =   6495
  38.    End
  39. Attribute VB_Name = "frmEditor"
  40. Attribute VB_GlobalNameSpace = False
  41. Attribute VB_Creatable = False
  42. Attribute VB_PredeclaredId = True
  43. Attribute VB_Exposed = False
  44. ''''''''''''''''''''''''''''''''''''''''''''''
  45. '' Name: frmEditor
  46. '' Decription: This window allows the user to
  47. '' type up their Java programs and applets.
  48. '' Author: RJ45
  49. '' Copyright (C) RJ45
  50. '' Send email to rj45software@hotmail.com
  51. '' for comments, suggestions and improvements
  52. ''''''''''''''''''''''''''''''''''''''''''''''
  53. Private Sub Form_Resize()
  54.     txtsrc.Move 0, 0, ScaleWidth, ScaleHeight
  55. End Sub
  56. Private Sub Form_Unload(Cancel As Integer)
  57.     Dim title, prompt As String
  58.     title = mainEditor.ActiveForm.Caption
  59.     prompt$ = "Document: " & Left(title, Len(title) - 7) & " has not been saved. Would like to save it now?"
  60.     res = MsgBox(prompt$, 35, "Save Document")
  61.     If res = 6 Then
  62.         Call saveDoc
  63.         mainEditor.ActiveForm.Hide
  64.     ElseIf res = 7 Then
  65.         'do nothing
  66.     ElseIf res = 2 Then
  67.         mainEditor.ActiveForm.Caption = mainEditor.ActiveForm.Caption
  68.     End If
  69. End Sub
  70. Private Sub txtsrc_Change()
  71.     If InStr(1, mainEditor.ActiveForm.Caption, "*") = 0 Then
  72.         mainEditor.ActiveForm.Caption = mainEditor.ActiveForm.Caption & "*"
  73.     End If
  74. End Sub
  75. Private Sub saveDoc()
  76.     Dim id As Integer
  77.     id = InStr(1, mainEditor.ActiveForm.Caption, "Untitled")
  78.     If id > 0 Then
  79.         'declare variables
  80.         Dim fullpath As String
  81.         'create and initialise an open file dialog box
  82.         saveJava.DialogTitle = "Save" 'title
  83.         saveJava.Flags = cdlOFNOverwritePrompt Or cdlOFNPathMustExist 'checks
  84.         saveJava.FileName = "" 'default name that appears in the filename
  85.         'all possible file extensions
  86.         saveJava.Filter = "Java Source File (*.java)|*.java|All Files (*.*)|*.*"
  87.         saveJava.CancelError = True 'catch errors generated
  88.         saveJava.InitDir = "C:\WINDOWS\JAVA" 'open up in the root dir initially
  89.         'this is executed when an error happens
  90.         On Error Resume Next
  91.         saveJava.ShowSave
  92.         'this is executed when no errors are executed
  93.         If Err = 0 Then
  94.         
  95.             fullpath = saveJava.FileName 'grab the full path of the filename
  96.         
  97.         Open fullpath For Output As #1
  98.              Print #1, Trim(mainEditor.ActiveForm.txtsrc.Text)
  99.         Close #1
  100.                
  101.             mainEditor.ActiveForm.Caption = fullpath & " - JACE"
  102.         End If
  103.         
  104.         'if cancel is pressed execute this
  105.         If Err = cdlCancel Then Exit Sub
  106.     Else
  107.         
  108.         Open Left(mainEditor.ActiveForm.Caption, _
  109.                         Len(mainEditor.ActiveForm.Caption) - 7) For Output As #2
  110.              Print #2, Trim(mainEditor.ActiveForm.txtsrc.Text)
  111.         Close #2
  112.         
  113.         mainEditor.ActiveForm.Caption = Trim(Left(mainEditor.ActiveForm.Caption, _
  114.                         Len(mainEditor.ActiveForm.Caption) - 7)) & " - JACE"
  115.     End If
  116. End Sub
  117. Public Sub selall()
  118.     txtsrc.SelLength = Len(txtsrc.Text)
  119. End Sub
  120.