home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 Secrets (4th Edition) / Windows95Secrets4thEdition.iso / tools / spellers / spelmate / notepad.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-08-25  |  8.7 KB  |  324 lines

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