home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l407 / 1.ddi / EDIT.FR_ / EDIT.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  11.1 KB  |  308 lines

  1. VERSION 2.00
  2. Begin Form frmEditor 
  3.    Caption         =   "Text Editor: Untitled"
  4.    ClientHeight    =   4020
  5.    ClientLeft      =   960
  6.    ClientTop       =   2190
  7.    ClientWidth     =   7200
  8.    ClipControls    =   0   'False
  9.    FontBold        =   0   'False
  10.    FontItalic      =   0   'False
  11.    FontName        =   "MS Sans Serif"
  12.    FontSize        =   8.25
  13.    FontStrikethru  =   0   'False
  14.    FontUnderline   =   0   'False
  15.    Height          =   4710
  16.    Left            =   900
  17.    LinkTopic       =   "Form2"
  18.    ScaleHeight     =   3753.867
  19.    ScaleMode       =   0  'User
  20.    ScaleWidth      =   7200
  21.    Top             =   1560
  22.    Width           =   7320
  23.    Begin CommonDialog CMDialog1 
  24.       CancelError     =   -1  'True
  25.       Left            =   0
  26.       Top             =   0
  27.    End
  28.    Begin TextBox txtEdit 
  29.       FontBold        =   -1  'True
  30.       FontItalic      =   0   'False
  31.       FontName        =   "MS Sans Serif"
  32.       FontSize        =   12
  33.       FontStrikethru  =   0   'False
  34.       FontUnderline   =   0   'False
  35.       Height          =   4289
  36.       Left            =   -30
  37.       MultiLine       =   -1  'True
  38.       ScrollBars      =   3  'Both
  39.       TabIndex        =   0
  40.       Top             =   -30
  41.       Width           =   7215
  42.    End
  43.    Begin Menu mnuFile 
  44.       Caption         =   "&File"
  45.       Begin Menu mnuFileItem 
  46.          Caption         =   "&New"
  47.          Index           =   0
  48.       End
  49.       Begin Menu mnuFileItem 
  50.          Caption         =   "&Open..."
  51.          Index           =   1
  52.       End
  53.       Begin Menu mnuFileItem 
  54.          Caption         =   "Save &As..."
  55.          Index           =   2
  56.       End
  57.       Begin Menu mnuFileItem 
  58.          Caption         =   "&Close"
  59.          Enabled         =   0   'False
  60.          Index           =   3
  61.       End
  62.       Begin Menu mnuFileItem 
  63.          Caption         =   "-"
  64.          Index           =   4
  65.       End
  66.       Begin Menu mnuFileItem 
  67.          Caption         =   "E&xit"
  68.          Index           =   5
  69.       End
  70.       Begin Menu mnuFileArray 
  71.          Caption         =   "-"
  72.          Index           =   0
  73.          Visible         =   0   'False
  74.       End
  75.    End
  76.    Begin Menu mnuEdit 
  77.       Caption         =   "&Edit"
  78.       Begin Menu mnuEditItem 
  79.          Caption         =   "Cu&t"
  80.          Index           =   0
  81.          Shortcut        =   ^X
  82.       End
  83.       Begin Menu mnuEditItem 
  84.          Caption         =   "C&opy"
  85.          Index           =   1
  86.          Shortcut        =   ^C
  87.       End
  88.       Begin Menu mnuEditItem 
  89.          Caption         =   "&Paste"
  90.          Index           =   2
  91.          Shortcut        =   ^V
  92.       End
  93.    End
  94.    Begin Menu mnuSettings 
  95.       Caption         =   "&Settings"
  96.       Begin Menu mnuSettingsItem 
  97.          Caption         =   "&Colors"
  98.          Index           =   0
  99.          Begin Menu mnuColorsItem 
  100.             Caption         =   "&BackColor"
  101.             Index           =   0
  102.             Begin Menu mnuBackColorItem 
  103.                Caption         =   "&Red"
  104.                Index           =   0
  105.             End
  106.             Begin Menu mnuBackColorItem 
  107.                Caption         =   "&Green"
  108.                Index           =   1
  109.             End
  110.             Begin Menu mnuBackColorItem 
  111.                Caption         =   "&Blue"
  112.                Index           =   2
  113.             End
  114.          End
  115.          Begin Menu mnuColorsItem 
  116.             Caption         =   "&ForeColor"
  117.             Index           =   1
  118.             Begin Menu mnuForeColorItem 
  119.                Caption         =   "&Red"
  120.                Index           =   0
  121.             End
  122.             Begin Menu mnuForeColorItem 
  123.                Caption         =   "&Green"
  124.                Index           =   1
  125.             End
  126.             Begin Menu mnuForeColorItem 
  127.                Caption         =   "&Blue"
  128.                Index           =   2
  129.                Begin Menu mnuBlueItem 
  130.                   Caption         =   "&Light Blue"
  131.                   Index           =   0
  132.                End
  133.                Begin Menu mnuBlueItem 
  134.                   Caption         =   "&Dark Blue"
  135.                   Index           =   1
  136.                   Begin Menu mnuDarkBlueItem 
  137.                      Caption         =   "&Sea Blue"
  138.                      Index           =   0
  139.                   End
  140.                   Begin Menu mnuDarkBlueItem 
  141.                      Caption         =   "&Midnight Blue"
  142.                      Index           =   1
  143.                   End
  144.                End
  145.             End
  146.          End
  147.       End
  148.       Begin Menu mnuSettingsItem 
  149.          Caption         =   "&Font Sizes"
  150.          Index           =   1
  151.          Begin Menu mnuFontSizesItem 
  152.             Caption         =   "12"
  153.             Checked         =   -1  'True
  154.             Index           =   0
  155.          End
  156.          Begin Menu mnuFontSizesItem 
  157.             Caption         =   "24"
  158.             Index           =   1
  159.          End
  160.       End
  161.    End
  162.    Begin Menu mnuAbout 
  163.       Caption         =   "&About..."
  164.    End
  165. Sub Form_Load ()
  166.     ' Change working directory to the directory
  167.     ' where the application was executed.
  168.     ChDir app.Path
  169.     ChDrive app.Path
  170.     ' position the text box
  171.     txtEdit.Move 0, 0
  172. ' The form is horizontally and vertically centered when loaded.
  173.     Top = Screen.Height / 2 - Height / 2
  174.     Left = Screen.Width / 2 - Width / 2
  175. End Sub
  176. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  177. ' The general procedure DoUnLoadPreCheck handles the possible unload options
  178. ' for all three forms in this sample application.
  179.     DoUnLoadPreCheck UnloadMode
  180. End Sub
  181. Sub Form_Resize ()
  182.     txtEdit.Width = Scalewidth
  183.     txtEdit.Height = Scaleheight
  184. End Sub
  185. Sub mnuAbout_Click ()
  186. ' All the CaptionTextn string variables below are concatenated together with the appropriate
  187. ' line feed characters to display text in the About dialog.
  188.     CaptionText1 = "This Text Editor sample application illustrates the various menu features available using Visual Basic, including..."
  189.     CaptionText2 = "...submenus, separator bars, access keys, shortcut keys, modal and modeless dialog boxes,"
  190.     CaptionText3 = " MsgBox, showing and hiding forms, disabling controls, invisible controls, check marks,"
  191.     CaptionText4 = " control arrays, and adding and removing menu controls at run time..."
  192.     CaptionText5 = "...and much, much, more!"
  193.     frmAbout!lblAbout.Caption = CaptionText1 & Chr$(10) & Chr$(10) & CaptionText2 & CaptionText3 & CaptionText4 & Chr$(10) & Chr$(10) & CaptionText5
  194. ' The Show method with style = 1 is used here to display the dialog as modal. Unloading the
  195. ' dialog is handled in the forms cmdOK_Click event procedure.
  196.     frmAbout.Show 1
  197. End Sub
  198. Sub mnuBackColorItem_Click (Index As Integer)
  199.     Select Case Index
  200.     Case 0    ' Set BackColor to Red
  201.         txtEdit.BackColor = RGB(255, 0, 0)
  202.     Case 1    ' Set BackColor to Green
  203.         txtEdit.BackColor = RGB(0, 255, 0)
  204.     Case 2    ' Set BackColor to Blue
  205.         txtEdit.BackColor = RGB(0, 0, 255)
  206.     End Select
  207. End Sub
  208. Sub mnuBlueItem_Click (Index As Integer)
  209. ' If Light Blue was selected then set the Forecolor to light
  210. ' blue otherwise do nothing.
  211.     If Index = 0 Then
  212.        txtEdit.ForeColor = RGB(0, 150, 255)
  213.     End If
  214. End Sub
  215. Sub mnuDarkBlueItem_Click (Index As Integer)
  216.     Select Case Index
  217.     Case 0              ' Set ForeColor to Sea Blue
  218.     txtEdit.ForeColor = RGB(0, 50, 175)
  219.     Case 1              ' Set ForeColor to Midnight Blue
  220.     txtEdit.ForeColor = RGB(0, 0, 255)
  221.     End Select
  222. End Sub
  223. Sub mnuEdit_Click ()
  224.     ' Disable Cut and Copy if no text selected.
  225.     mnuEditItem(0).Enabled = (txtEdit.SelLength > 0)
  226.     mnuEditItem(1).Enabled = (txtEdit.SelLength > 0)
  227. End Sub
  228. Sub mnuEditItem_Click (Index As Integer)
  229.     Select Case Index
  230.     Case 0 ' If Index = 0, user chose "Cut"
  231.         Clipboard.Clear
  232.         Clipboard.SetText txtEdit.SelText ' Copy selected text to Clipboard.
  233.         txtEdit.SelText = "" ' Clear selected text from the document.
  234.     Case 1 ' If Index = 1, user chose "Copy"
  235.         Clipboard.Clear
  236.         Clipboard.SetText txtEdit.SelText ' Copy selected text to Clipboard.
  237.     Case 2 ' If Index = 2, user chose "Paste"
  238.         txtEdit.SelText = Clipboard.GetText() ' Paste Clipboard text (if any) into document.
  239.     End Select
  240. End Sub
  241. Sub mnuFileArray_Click (Index As Integer)
  242. ' Open the selected file.
  243.     If Index >= 0 Then
  244.     OpenFile (mnuFileArray(Index).Caption)
  245.     End If
  246. End Sub
  247. Sub mnuFileItem_Click (Index As Integer)
  248. ' CancelError is True
  249. On Error GoTo errhandler
  250. Select Case Index   ' Check index value of selected menu item.
  251.     Case 0  ' If index = 0, the user chose "New"
  252.     txtEdit.Text = ""       ' Clear text box
  253.     Filename = "Untitled"   ' Set the title bar caption to "Text Editor: Untitled"
  254.     frmEditor.Caption = "Text Editor: " & Filename
  255.     Case 1  ' If index = 1, the user chose "Open..."
  256.     ' Set filters
  257.     CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
  258.     ' Specify default filter
  259.     CMDialog1.FilterIndex = 2
  260.     ' display the File Open dialog
  261.     CMDialog1.Action = 1
  262.     Filename = CMDialog1.Filename
  263.     OpenFile (Filename)
  264.     Case 2  ' If index = 2, the user chose "Save As..."
  265.     ' Set filters
  266.     CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
  267.     ' Specify default filter
  268.     CMDialog1.FilterIndex = 2
  269.     ' display the File Open dialog
  270.     CMDialog1.Action = 2
  271.     Filename = CMDialog1.Filename
  272.     CloseFile (Filename)
  273.     Case 3  ' If index = 3, the user chose "Close"
  274.     txtEdit.Text = ""                             ' Clear text box
  275.     frmEditor.Caption = "Text Editor: Untitled"   ' Refresh caption of form
  276.     mnuFileItem(3).Enabled = False                ' Disable this menu item.
  277.     CloseFile (Filename)                          ' Close the current file.
  278.     Case 4  ' This menu item is a separator bar, no code needs to be written here
  279.         ' because it cannot be selected and therefore cannot receive a Click event.
  280.     Case 5  ' If index = 5, the user chose "Exit"
  281.     End  ' End this application and return to the Windows operating system.
  282. End Select
  283. errhandler:
  284. ' user pressed cancel button
  285.     Exit Sub
  286. End Sub
  287. Sub mnuFontSizesItem_Click (Index As Integer)
  288. Select Case Index ' Perform action based on Index property value of menu control
  289.     Case 0 ' If Index = 0 then user chose font size 12
  290.     txtEdit.FontSize = 12   ' Set FontSize property of text box to 12
  291.     mnuFontSizesItem(0).Checked = True ' Display check mark next to 12
  292.     mnuFontSizesItem(1).Checked = False' Remove check mark next to 24
  293.     Case 1
  294.     txtEdit.FontSize = 24   ' Set FontSize property of text box to 24
  295.     mnuFontSizesItem(0).Checked = False' Remove check mark next to 12
  296.     mnuFontSizesItem(1).Checked = True ' Display check mark next to 24
  297. End Select
  298. End Sub
  299. Sub mnuForeColorItem_Click (Index As Integer)
  300. Select Case Index
  301.     Case 0 ' Set ForeColor to Red
  302.         txtEdit.ForeColor = RGB(255, 0, 0)
  303.     Case 1 ' Set ForeColor to Green
  304.         txtEdit.ForeColor = RGB(0, 255, 0)
  305.     Case 2 ' No code for this case because submenu is automatically displayed on Case 2.
  306. End Select
  307. End Sub
  308.