home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / notepad.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  10.9 KB  |  351 lines

  1. VERSION 4.00
  2. Begin VB.Form frmNotePad 
  3.    Caption         =   "Untitled"
  4.    ClientHeight    =   3990
  5.    ClientLeft      =   1515
  6.    ClientTop       =   3315
  7.    ClientWidth     =   5670
  8.    BeginProperty Font 
  9.       name            =   "MS Sans Serif"
  10.       charset         =   1
  11.       weight          =   700
  12.       size            =   8.25
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   4680
  18.    Left            =   1455
  19.    LinkTopic       =   "Form1"
  20.    MDIChild        =   -1  'True
  21.    ScaleHeight     =   3990
  22.    ScaleMode       =   0  'User
  23.    ScaleWidth      =   101.07
  24.    Top             =   2685
  25.    Visible         =   0   'False
  26.    Width           =   5790
  27.    Begin VB.TextBox Text1 
  28.       Height          =   3975
  29.       HideSelection   =   0   'False
  30.       Left            =   0
  31.       MultiLine       =   -1  'True
  32.       ScrollBars      =   2  'Vertical
  33.       TabIndex        =   0
  34.       Top             =   0
  35.       Width           =   5655
  36.    End
  37.    Begin VB.Menu mnuFile 
  38.       Caption         =   "&File"
  39.       WindowList      =   -1  'True
  40.       Begin VB.Menu mnuFNew 
  41.          Caption         =   "&New"
  42.       End
  43.       Begin VB.Menu mnuFOpen 
  44.          Caption         =   "&Open..."
  45.       End
  46.       Begin VB.Menu mnuFClose 
  47.          Caption         =   "&Close"
  48.       End
  49.       Begin VB.Menu mnuFSave 
  50.          Caption         =   "&Save"
  51.       End
  52.       Begin VB.Menu mnuFSaveAs 
  53.          Caption         =   "Save &As..."
  54.       End
  55.       Begin VB.Menu mnuFSep 
  56.          Caption         =   "-"
  57.       End
  58.       Begin VB.Menu mnuFExit 
  59.          Caption         =   "E&xit"
  60.       End
  61.       Begin VB.Menu mnuRecentFile 
  62.          Caption         =   "-"
  63.          Index           =   0
  64.          Visible         =   0   'False
  65.       End
  66.       Begin VB.Menu mnuRecentFile 
  67.          Caption         =   "RecentFile1"
  68.          Index           =   1
  69.          Visible         =   0   'False
  70.       End
  71.       Begin VB.Menu mnuRecentFile 
  72.          Caption         =   "RecentFile2"
  73.          Index           =   2
  74.          Visible         =   0   'False
  75.       End
  76.       Begin VB.Menu mnuRecentFile 
  77.          Caption         =   "RecentFile3"
  78.          Index           =   3
  79.          Visible         =   0   'False
  80.       End
  81.       Begin VB.Menu mnuRecentFile 
  82.          Caption         =   "RecentFile4"
  83.          Index           =   4
  84.          Visible         =   0   'False
  85.       End
  86.    End
  87.    Begin VB.Menu mnuEdit 
  88.       Caption         =   "&Edit"
  89.       Begin VB.Menu mnuECut 
  90.          Caption         =   "Cu&t"
  91.          Shortcut        =   ^X
  92.       End
  93.       Begin VB.Menu mnuECopy 
  94.          Caption         =   "&Copy"
  95.          Shortcut        =   ^C
  96.       End
  97.       Begin VB.Menu mnuEPaste 
  98.          Caption         =   "&Paste"
  99.          Shortcut        =   ^V
  100.       End
  101.       Begin VB.Menu mnuEDelete 
  102.          Caption         =   "De&lete"
  103.          Shortcut        =   {DEL}
  104.       End
  105.       Begin VB.Menu mnuESep1 
  106.          Caption         =   "-"
  107.       End
  108.       Begin VB.Menu mnuESelectAll 
  109.          Caption         =   "Select &All"
  110.       End
  111.       Begin VB.Menu mnuETime 
  112.          Caption         =   "Time/&Date"
  113.       End
  114.    End
  115.    Begin VB.Menu mnuSearch 
  116.       Caption         =   "&Search"
  117.       Begin VB.Menu mnuSFind 
  118.          Caption         =   "&Find"
  119.       End
  120.       Begin VB.Menu mnuSFindNext 
  121.          Caption         =   "Find &Next"
  122.          Shortcut        =   {F3}
  123.       End
  124.    End
  125.    Begin VB.Menu mnuOptions 
  126.       Caption         =   "&Options"
  127.       Begin VB.Menu mnuOToolbar 
  128.          Caption         =   "&Toolbar"
  129.       End
  130.       Begin VB.Menu mnuFont 
  131.          Caption         =   "&Font"
  132.          Begin VB.Menu mnuFontName 
  133.             Caption         =   "FontName"
  134.             Index           =   0
  135.          End
  136.       End
  137.    End
  138.    Begin VB.Menu mnuWindow 
  139.       Caption         =   "&Window"
  140.       Begin VB.Menu mnuWCascade 
  141.          Caption         =   "&Cascade"
  142.       End
  143.       Begin VB.Menu mnuWTile 
  144.          Caption         =   "&Tile"
  145.       End
  146.       Begin VB.Menu mnuWArrange 
  147.          Caption         =   "&Arrange Icons"
  148.       End
  149.    End
  150. Attribute VB_Name = "frmNotePad"
  151. Attribute VB_Creatable = False
  152. Attribute VB_Exposed = False
  153. Private Sub Form_Load()
  154.     Dim i As Integer
  155.     mnuFontName(0).Caption = Screen.Fonts(0)
  156.     For i = 1 To Screen.FontCount - 1
  157.         Load mnuFontName(i)
  158.         mnuFontName(0).Caption = Screen.Fonts(i)
  159.     Next
  160. End Sub
  161. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  162.     Dim Msg, Filename, NL
  163.     Dim Response As Integer
  164.     If FState(Me.Tag).Dirty Then
  165.         Filename = Me.Caption
  166.         NL = Chr(10) & Chr(13)
  167.         Msg = "The text in [" & Filename & "] has changed."
  168.         Msg = Msg & NL
  169.         Msg = Msg & "Do you want to save the changes?"
  170.         Response = MsgBox(Msg, 51, frmMDI.Caption)
  171.         Select Case Response
  172.             Case 6      ' User chose Yes.
  173.             If Left(Me.Caption, 8) = "Untitled" Then
  174.             ' The file hasn't been saved yet.
  175.             Filename = "untitled.txt"
  176.             ' Get the filename, and then call the save procedure, GetFileName.
  177.                 Filename = GetFileName(Filename)
  178.             Else
  179.                 ' The form's Caption contains the name of the open file.
  180.                 Filename = Me.Caption
  181.             End If
  182.             ' Call the save procedure. If Filename = Empty, then
  183.             ' the user chose Cancel in the Save As dialog box; otherwise,
  184.             ' save the file.
  185.             If Filename <> "" Then
  186.                 SaveFileAs Filename
  187.             End If
  188.             Case 7      ' User chose No. Unload the file.
  189.                 Cancel = False
  190.             Case 2      ' User chose Cancel. Cancel the unload.
  191.                 Cancel = True
  192.         End Select
  193.     End If
  194. End Sub
  195. Private Sub Form_Resize()
  196.     If WindowState <> 1 And ScaleHeight <> 0 Then
  197.         Text1.Visible = False
  198.         Text1.Height = ScaleHeight
  199.         Text1.Width = ScaleWidth
  200.         
  201.         Text1.Visible = True
  202.     End If
  203. End Sub
  204. Private Sub Form_Unload(Cancel As Integer)
  205.     FState(Me.Tag).Deleted = True
  206.     ' Hide the toolbar edit buttons if no notepad windows exist.
  207.     If Not AnyPadsLeft() Then
  208.         frmMDI!imgcutbutton.Visible = False
  209.         frmMDI!imgcopybutton.Visible = False
  210.         frmMDI!imgPasteButton.Visible = False
  211.         gToolsHidden = True
  212.         GetRecentFiles
  213.     End If
  214. End Sub
  215. Private Sub mnuECopy_Click()
  216.     EditCopyProc
  217. End Sub
  218. Private Sub mnuECut_Click()
  219.     EditCutProc
  220. End Sub
  221. Private Sub mnuEDelete_Click()
  222.     ' If the mouse pointer is not at the end of the notepad...
  223.     If Screen.ActiveControl.SelStart <> Len(Screen.ActiveControl.TEXT) Then
  224.         ' If nothing is selected, extend the selection by one.
  225.         If Screen.ActiveControl.SelLength = 0 Then
  226.             Screen.ActiveControl.SelLength = 1
  227.             ' If the mouse pointer is on a blank line, extend the selection by two.
  228.             If Asc(Screen.ActiveControl.SelText) = 13 Then
  229.                 Screen.ActiveControl.SelLength = 2
  230.             End If
  231.         End If
  232.         ' Delete the selected text.
  233.         Screen.ActiveControl.SelText = ""
  234.     End If
  235. End Sub
  236. Private Sub mnuEPaste_Click()
  237.     EditPasteProc
  238. End Sub
  239. Private Sub mnuESelectAll_Click()
  240.     frmMDI.ActiveForm.Text1.SelStart = 0
  241.     frmMDI.ActiveForm.Text1.SelLength = Len(frmMDI.ActiveForm.Text1.TEXT)
  242. End Sub
  243. Private Sub mnuETime_Click()
  244.     Dim TimeStr As String, DateStr As String
  245.     Text1.SelText = Now
  246. End Sub
  247. Private Sub mnuFClose_Click()
  248.     Unload Me
  249. End Sub
  250. Private Sub mnuFExit_Click()
  251.     ' Unloading the MDI form invokes the QueryUnload event
  252.     ' for each child form, and then the MDI form.
  253.     ' Setting the Cancel argument to True in any of the
  254.     ' QueryUnload events cancels the unload.
  255.     Unload frmMDI
  256. End Sub
  257. Private Sub mnuFNew_Click()
  258.     FileNew
  259. End Sub
  260. Private Sub mnuFontName_Click(index As Integer)
  261.     Text1.FontName = mnuFontName(index).Caption
  262. End Sub
  263. Private Sub mnuFOpen_Click()
  264.     FOpenProc
  265. End Sub
  266. Private Sub mnuFSave_Click()
  267.     Dim Filename As String
  268.     If Left(Me.Caption, 8) = "Untitled" Then
  269.         ' The file hasn't been saved yet.
  270.         ' Get the filename, and then call the save procedure, GetFileName.
  271.         Filename = GetFileName(Filename)
  272.     Else
  273.         ' The form's Caption contains the name of the open file.
  274.         Filename = Me.Caption
  275.     End If
  276.     ' Call the save procedure. If Filename = Empty, then
  277.     ' the user chose Cancel in the Save As dialog box; otherwise,
  278.     ' save the file.
  279.     If Filename <> "" Then
  280.         SaveFileAs Filename
  281.     End If
  282. End Sub
  283. Private Sub mnuFSaveAs_Click()
  284.     Dim SaveFileName As String
  285.     Dim DefaultName As String
  286.     DefaultName = Me.Caption
  287.     If Left(Me.Caption, 8) = "Untitled" Then
  288.         ' The file hasn't been saved yet.
  289.         ' Get the filename, and then call the save procedure, SaveFileName.
  290.         
  291.         SaveFileName = GetFileName("Untitled.txt")
  292.         If SaveFileName <> "" Then SaveFileAs (SaveFileName)
  293.         ' Update the list of recently opened files in the File menu control array.
  294.         UpdateFileMenu (SaveFileName)
  295.     Else
  296.         ' The form's Caption contains the name of the open file.
  297.         
  298.         SaveFileName = GetFileName(DefaultName)
  299.         If SaveFileName <> "" Then SaveFileAs (SaveFileName)
  300.         ' Update the list of recently opened files in the File menu control array.
  301.         UpdateFileMenu (SaveFileName)
  302.     End If
  303. End Sub
  304. Private Sub mnuOptions_Click()
  305.     mnuOToolbar.Checked = frmMDI!picToolbar.Visible
  306. End Sub
  307. Private Sub mnuOToolbar_Click()
  308.     OptionsToolbarProc Me
  309. End Sub
  310. Private Sub mnuRecentFile_Click(index As Integer)
  311.     OpenFile (mnuRecentFile(index).Caption)
  312.     ' Update the list of recently opened files in the File menu control array.
  313.     GetRecentFiles
  314. End Sub
  315. Private Sub mnuSFind_Click()
  316.     If Me!Text1.SelText <> "" Then
  317.         frmFind!Text1.TEXT = Me!Text1.SelText
  318.     Else
  319.         frmFind!Text1.TEXT = gFindString
  320.     End If
  321.     gFirstTime = True
  322.     If (gFindCase) Then
  323.         frmFind.chkCase = 1
  324.     End If
  325.     frmFind.Show
  326. End Sub
  327. Private Sub mnuSFindNext_Click()
  328.     If Len(gFindString) > 0 Then
  329.         FindIt
  330.     Else
  331.         mnuSFind_Click
  332.     End If
  333. End Sub
  334. Private Sub mnuWArrange_Click()
  335.     frmMDI.Arrange vbArrangeIcons
  336. End Sub
  337. Private Sub mnuWCascade_Click()
  338.     frmMDI.Arrange vbCascade
  339. End Sub
  340. Private Sub mnuWTile_Click()
  341.     frmMDI.Arrange vbTileHorizontal
  342. End Sub
  343. Private Sub Text1_Change()
  344.     FState(Me.Tag).Dirty = True
  345. End Sub
  346. Private Sub Text1_GotFocus()
  347.     If frmFind.Visible Then
  348.         frmFind.ZOrder 0
  349.     End If
  350. End Sub
  351.