home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk1 / edit.fr_ / edit.bin
Text File  |  1993-04-28  |  11KB  |  327 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. End
  166.  
  167. Sub Form_Load ()
  168.     ' Change working directory to the directory
  169.     ' where the application was executed.
  170.     ChDir app.Path
  171.     ChDrive app.Path
  172.     
  173.     ' position the text box
  174.     txtEdit.Move 0, 0
  175.  
  176. ' The form is horizontally and vertically centered when loaded.
  177.     Top = Screen.Height / 2 - Height / 2
  178.     Left = Screen.Width / 2 - Width / 2
  179. End Sub
  180.  
  181. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  182. ' The general procedure DoUnLoadPreCheck handles the possible unload options
  183. ' for all three forms in this sample application.
  184.     DoUnLoadPreCheck UnloadMode
  185. End Sub
  186.  
  187. Sub Form_Resize ()
  188.     txtEdit.Width = Scalewidth
  189.     txtEdit.Height = Scaleheight
  190. End Sub
  191.  
  192. Sub mnuAbout_Click ()
  193. ' All the CaptionTextn string variables below are concatenated together with the appropriate
  194. ' line feed characters to display text in the About dialog.
  195.     CaptionText1 = "This Text Editor sample application illustrates the various menu features available using Visual Basic, including..."
  196.     CaptionText2 = "...submenus, separator bars, access keys, shortcut keys, modal and modeless dialog boxes,"
  197.     CaptionText3 = " MsgBox, showing and hiding forms, disabling controls, invisible controls, check marks,"
  198.     CaptionText4 = " control arrays, and adding and removing menu controls at run time..."
  199.     CaptionText5 = "...and much, much, more!"
  200.     frmAbout!lblAbout.Caption = CaptionText1 & Chr$(10) & Chr$(10) & CaptionText2 & CaptionText3 & CaptionText4 & Chr$(10) & Chr$(10) & CaptionText5
  201. ' The Show method with style = 1 is used here to display the dialog as modal. Unloading the
  202. ' dialog is handled in the forms cmdOK_Click event procedure.
  203.     frmAbout.Show 1
  204. End Sub
  205.  
  206. Sub mnuBackColorItem_Click (Index As Integer)
  207.     Select Case Index
  208.     Case 0    ' Set BackColor to Red
  209.         txtEdit.BackColor = RGB(255, 0, 0)
  210.     Case 1    ' Set BackColor to Green
  211.         txtEdit.BackColor = RGB(0, 255, 0)
  212.     Case 2    ' Set BackColor to Blue
  213.         txtEdit.BackColor = RGB(0, 0, 255)
  214.     End Select
  215. End Sub
  216.  
  217. Sub mnuBlueItem_Click (Index As Integer)
  218. ' If Light Blue was selected then set the Forecolor to light
  219. ' blue otherwise do nothing.
  220.     If Index = 0 Then
  221.        txtEdit.ForeColor = RGB(0, 150, 255)
  222.     End If
  223. End Sub
  224.  
  225. Sub mnuDarkBlueItem_Click (Index As Integer)
  226.     Select Case Index
  227.     Case 0              ' Set ForeColor to Sea Blue
  228.     txtEdit.ForeColor = RGB(0, 50, 175)
  229.     Case 1              ' Set ForeColor to Midnight Blue
  230.     txtEdit.ForeColor = RGB(0, 0, 255)
  231.     End Select
  232. End Sub
  233.  
  234. Sub mnuEdit_Click ()
  235.     ' Disable Cut and Copy if no text selected.
  236.     mnuEditItem(0).Enabled = (txtEdit.SelLength > 0)
  237.     mnuEditItem(1).Enabled = (txtEdit.SelLength > 0)
  238. End Sub
  239.  
  240. Sub mnuEditItem_Click (Index As Integer)
  241.     Select Case Index
  242.     Case 0 ' If Index = 0, user chose "Cut"
  243.         Clipboard.Clear
  244.         Clipboard.SetText txtEdit.SelText ' Copy selected text to Clipboard.
  245.         txtEdit.SelText = "" ' Clear selected text from the document.
  246.     Case 1 ' If Index = 1, user chose "Copy"
  247.         Clipboard.Clear
  248.         Clipboard.SetText txtEdit.SelText ' Copy selected text to Clipboard.
  249.     Case 2 ' If Index = 2, user chose "Paste"
  250.         txtEdit.SelText = Clipboard.GetText() ' Paste Clipboard text (if any) into document.
  251.     End Select
  252. End Sub
  253.  
  254. Sub mnuFileArray_Click (Index As Integer)
  255. ' Open the selected file.
  256.     If Index >= 0 Then
  257.     OpenFile (mnuFileArray(Index).Caption)
  258.     End If
  259. End Sub
  260.  
  261. Sub mnuFileItem_Click (Index As Integer)
  262.     
  263. ' CancelError is True
  264. On Error GoTo errhandler
  265.  
  266. Select Case Index   ' Check index value of selected menu item.
  267.     Case 0  ' If index = 0, the user chose "New"
  268.     txtEdit.Text = ""       ' Clear text box
  269.     Filename = "Untitled"   ' Set the title bar caption to "Text Editor: Untitled"
  270.     frmEditor.Caption = "Text Editor: " & Filename
  271.     Case 1  ' If index = 1, the user chose "Open..."
  272.     ' Set filters
  273.     CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
  274.     ' Specify default filter
  275.     CMDialog1.FilterIndex = 2
  276.     ' display the File Open dialog
  277.     CMDialog1.Action = 1
  278.     Filename = CMDialog1.Filename
  279.     OpenFile (Filename)
  280.     Case 2  ' If index = 2, the user chose "Save As..."
  281.     ' Set filters
  282.     CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
  283.     ' Specify default filter
  284.     CMDialog1.FilterIndex = 2
  285.     ' display the File Open dialog
  286.     CMDialog1.Action = 2
  287.     Filename = CMDialog1.Filename
  288.     CloseFile (Filename)
  289.     Case 3  ' If index = 3, the user chose "Close"
  290.     txtEdit.Text = ""                             ' Clear text box
  291.     frmEditor.Caption = "Text Editor: Untitled"   ' Refresh caption of form
  292.     mnuFileItem(3).Enabled = False                ' Disable this menu item.
  293.     CloseFile (Filename)                          ' Close the current file.
  294.     Case 4  ' This menu item is a separator bar, no code needs to be written here
  295.         ' because it cannot be selected and therefore cannot receive a Click event.
  296.     Case 5  ' If index = 5, the user chose "Exit"
  297.     End  ' End this application and return to the Windows operating system.
  298. End Select
  299. errhandler:
  300. ' user pressed cancel button
  301.     Exit Sub
  302. End Sub
  303.  
  304. Sub mnuFontSizesItem_Click (Index As Integer)
  305. Select Case Index ' Perform action based on Index property value of menu control
  306.     Case 0 ' If Index = 0 then user chose font size 12
  307.     txtEdit.FontSize = 12   ' Set FontSize property of text box to 12
  308.     mnuFontSizesItem(0).Checked = True ' Display check mark next to 12
  309.     mnuFontSizesItem(1).Checked = False' Remove check mark next to 24
  310.     Case 1
  311.     txtEdit.FontSize = 24   ' Set FontSize property of text box to 24
  312.     mnuFontSizesItem(0).Checked = False' Remove check mark next to 12
  313.     mnuFontSizesItem(1).Checked = True ' Display check mark next to 24
  314. End Select
  315. End Sub
  316.  
  317. Sub mnuForeColorItem_Click (Index As Integer)
  318. Select Case Index
  319.     Case 0 ' Set ForeColor to Red
  320.         txtEdit.ForeColor = RGB(255, 0, 0)
  321.     Case 1 ' Set ForeColor to Green
  322.         txtEdit.ForeColor = RGB(0, 255, 0)
  323.     Case 2 ' No code for this case because submenu is automatically displayed on Case 2.
  324. End Select
  325. End Sub
  326.  
  327.