home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / actassst / notepad.fr_ / notepad.fr (.txt)
Encoding:
Visual Basic Form  |  1998-02-25  |  14.9 KB  |  444 lines

  1. VERSION 5.00
  2. Begin VB.Form frmNotePad 
  3.    Caption         =   "Untitled"
  4.    ClientHeight    =   3990
  5.    ClientLeft      =   2160
  6.    ClientTop       =   2235
  7.    ClientWidth     =   5670
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    MDIChild        =   -1  'True
  19.    ScaleHeight     =   3990
  20.    ScaleMode       =   0  'User
  21.    ScaleWidth      =   101.07
  22.    Begin VB.TextBox Text1 
  23.       Height          =   3975
  24.       HideSelection   =   0   'False
  25.       Left            =   0
  26.       MultiLine       =   -1  'True
  27.       ScrollBars      =   2  'Vertical
  28.       TabIndex        =   0
  29.       Text            =   "notepad.frx":0000
  30.       Top             =   0
  31.       Width           =   5655
  32.    End
  33.    Begin VB.Menu mnuFile 
  34.       Caption         =   "&File"
  35.       Begin VB.Menu mnuFileNew 
  36.          Caption         =   "&New"
  37.       End
  38.       Begin VB.Menu mnuFileOpen 
  39.          Caption         =   "&Open..."
  40.       End
  41.       Begin VB.Menu mnuFileClose 
  42.          Caption         =   "&Close"
  43.       End
  44.       Begin VB.Menu mnuFileSave 
  45.          Caption         =   "&Save"
  46.       End
  47.       Begin VB.Menu mnuFileSaveAs 
  48.          Caption         =   "Save &As..."
  49.       End
  50.       Begin VB.Menu mnuFSep 
  51.          Caption         =   "-"
  52.       End
  53.       Begin VB.Menu mnuFileExit 
  54.          Caption         =   "E&xit"
  55.       End
  56.       Begin VB.Menu mnuRecentFile 
  57.          Caption         =   "-"
  58.          Index           =   0
  59.          Visible         =   0   'False
  60.       End
  61.       Begin VB.Menu mnuRecentFile 
  62.          Caption         =   "RecentFile1"
  63.          Index           =   1
  64.          Visible         =   0   'False
  65.       End
  66.       Begin VB.Menu mnuRecentFile 
  67.          Caption         =   "RecentFile2"
  68.          Index           =   2
  69.          Visible         =   0   'False
  70.       End
  71.       Begin VB.Menu mnuRecentFile 
  72.          Caption         =   "RecentFile3"
  73.          Index           =   3
  74.          Visible         =   0   'False
  75.       End
  76.       Begin VB.Menu mnuRecentFile 
  77.          Caption         =   "RecentFile4"
  78.          Index           =   4
  79.          Visible         =   0   'False
  80.       End
  81.       Begin VB.Menu mnuRecentFile 
  82.          Caption         =   "RecentFile5"
  83.          Index           =   5
  84.          Visible         =   0   'False
  85.       End
  86.    End
  87.    Begin VB.Menu mnuEdit 
  88.       Caption         =   "&Edit"
  89.       Begin VB.Menu mnuEditCut 
  90.          Caption         =   "Cu&t"
  91.          Shortcut        =   ^X
  92.       End
  93.       Begin VB.Menu mnuEditCopy 
  94.          Caption         =   "&Copy"
  95.          Shortcut        =   ^C
  96.       End
  97.       Begin VB.Menu mnuEditPaste 
  98.          Caption         =   "&Paste"
  99.          Shortcut        =   ^V
  100.       End
  101.       Begin VB.Menu mnuEditDelete 
  102.          Caption         =   "De&lete"
  103.          Shortcut        =   {DEL}
  104.       End
  105.       Begin VB.Menu mnuESep1 
  106.          Caption         =   "-"
  107.       End
  108.       Begin VB.Menu mnuEditSelectAll 
  109.          Caption         =   "Select &All"
  110.       End
  111.       Begin VB.Menu mnuEditTime 
  112.          Caption         =   "Time/&Date"
  113.       End
  114.    End
  115.    Begin VB.Menu mnuSearch 
  116.       Caption         =   "&Search"
  117.       Begin VB.Menu mnuSearchFind 
  118.          Caption         =   "&Find"
  119.       End
  120.       Begin VB.Menu mnuSearchFindNext 
  121.          Caption         =   "Find &Next"
  122.          Shortcut        =   {F3}
  123.       End
  124.    End
  125.    Begin VB.Menu mnuOptions 
  126.       Caption         =   "&Options"
  127.       Begin VB.Menu mnuOptionsToolbar 
  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.       WindowList      =   -1  'True
  141.       Begin VB.Menu mnuWindowCascade 
  142.          Caption         =   "&Cascade"
  143.       End
  144.       Begin VB.Menu mnuWindowTile 
  145.          Caption         =   "&Tile"
  146.       End
  147.       Begin VB.Menu mnuWindowArrange 
  148.          Caption         =   "&Arrange Icons"
  149.       End
  150.    End
  151.    Begin VB.Menu mnuHelp 
  152.       Caption         =   "&Help"
  153.       Begin VB.Menu mnuHelpAssistantHelp 
  154.          Caption         =   "A&ssistant Help"
  155.       End
  156.       Begin VB.Menu mnuHelpAbout 
  157.          Caption         =   "&About"
  158.       End
  159.    End
  160.    Begin VB.Menu mnuAssistant 
  161.       Caption         =   "PopUp"
  162.       Visible         =   0   'False
  163.       Begin VB.Menu mnuAssistantHide 
  164.          Caption         =   "&Hide Assistant"
  165.       End
  166.       Begin VB.Menu mnuAssistantBreak1 
  167.          Caption         =   "-"
  168.       End
  169.       Begin VB.Menu mnuAssistantFont 
  170.          Caption         =   "&Font"
  171.          Begin VB.Menu mnuAssistantFontName 
  172.             Caption         =   "&FontName"
  173.             Index           =   0
  174.          End
  175.       End
  176.       Begin VB.Menu mnuAssistantAnimate 
  177.          Caption         =   "&Animate"
  178.       End
  179.    End
  180. Attribute VB_Name = "frmNotePad"
  181. Attribute VB_GlobalNameSpace = False
  182. Attribute VB_Creatable = False
  183. Attribute VB_PredeclaredId = True
  184. Attribute VB_Exposed = False
  185. '*** Child form for the MDI Notepad sample application  ***
  186. '**********************************************************
  187. Option Explicit
  188. Private Sub Form_Load()
  189.     Dim i As Integer        ' Counter variable.
  190.     ' Assign the name of the first font to a font
  191.     ' menu entry, then loop through the fonts
  192.     ' collection, adding them to the menu
  193.     mnuFontName(0).Caption = Screen.Fonts(0)
  194.     mnuAssistantFontName(0).Caption = Screen.Fonts(0)
  195.     For i = 1 To Screen.FontCount - 1
  196.         Load mnuFontName(i)
  197.         Load mnuAssistantFontName(i)
  198.         mnuFontName(0).Caption = Screen.Fonts(i)
  199.         mnuAssistantFontName(0).Caption = Screen.Fonts(i)
  200.     Next
  201.     ''Text1.Text = "Try closing down this document and watch how ActiveAssistant can take over from VB's MsgBox function."
  202. End Sub
  203. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  204.     Dim strMsg As String
  205.     Dim strFilename As String
  206.     Dim intResponse As Integer
  207.     ' Check to see if the text has been changed.
  208.     If FState(Me.Tag).Dirty Then
  209.         strFilename = Me.Caption
  210.         strMsg = "The text in [" & strFilename & "] has changed."
  211.         strMsg = strMsg & vbCrLf
  212.         strMsg = strMsg & "Do you want to save the changes?"
  213.         On Error Resume Next
  214.         intResponse = frmMDI.Assistant1.MsgBox(strMsg, 51, frmMDI.Caption)
  215.         Select Case intResponse
  216.             Case 6      ' User chose Yes.
  217.                 If Left(Me.Caption, 8) = "Untitled" Then
  218.                     ' The file hasn't been saved yet.
  219.                     strFilename = "untitled.txt"
  220.                     ' Get the strFilename, and then call the save procedure, GetstrFilename.
  221.                     strFilename = GetFileName(strFilename)
  222.                 Else
  223.                     ' The form's Caption contains the name of the open file.
  224.                     strFilename = Me.Caption
  225.                 End If
  226.                 ' Call the save procedure. If strFilename = Empty, then
  227.                 ' the user chose Cancel in the Save As dialog box; otherwise,
  228.                 ' save the file.
  229.                 If strFilename <> "" Then
  230.                     SaveFileAs strFilename
  231.                 End If
  232.             Case 7      ' User chose No. Unload the file.
  233.                 Cancel = False
  234.             Case 2      ' User chose Cancel. Cancel the unload.
  235.                 Cancel = True
  236.         End Select
  237.     End If
  238. End Sub
  239. Private Sub Form_Resize()
  240.     ' Expand text box to fill the current child form's internal area.
  241.     Text1.Height = ScaleHeight
  242.     Text1.Width = ScaleWidth
  243. End Sub
  244. Private Sub Form_Unload(Cancel As Integer)
  245.     ' Show the current form instance as deleted
  246.     FState(Me.Tag).Deleted = True
  247.         
  248. ''    frmMDI.Assistant1.MsgBox "Do You Wish To Save Any Changes to this Document?", vbYesNoCancel + vbQuestion
  249.     ' Hide the toolbar edit buttons if no notepad windows exist.
  250.     If Not AnyPadsLeft() Then
  251.         frmMDI.imgCutButton.Visible = False
  252.         frmMDI.imgCopyButton.Visible = False
  253.         frmMDI.imgPasteButton.Visible = False
  254.         ' Toggle the public tool state variable
  255.         gToolsHidden = True
  256.         ' Call the recent file list procedure
  257.         GetRecentFiles
  258.     End If
  259. End Sub
  260. Private Sub mnuAssistantAnimate_Click()
  261.     AnimateAssis
  262.     ' Set focus back to MDI.
  263.     frmMDI.SetFocus
  264. End Sub
  265. Private Sub mnuAssistantFontName_Click(index As Integer)
  266.     ' Assign the selected font to the textbox fontname property.
  267.     Text1.FontName = mnuAssistantFontName(index).Caption
  268. End Sub
  269. Private Sub mnuAssistantHide_Click()
  270.     ' Hide the assistant.
  271.     With frmMDI
  272.     If .Assistant1.AssistantVisible Then
  273.         If .Assistant1.IsAnimationPlaying Then
  274.             .Assistant1.StopAnimation
  275.         End If
  276.         ''.Assistant1.Visible = False
  277.         .Assistant1.AssistantHide
  278.     End If
  279.     ' Set focus back to MDI.
  280.     .SetFocus
  281.     End With
  282. End Sub
  283. Private Sub mnuEditCopy_Click()
  284.     ' Call the copy procedure
  285.     EditCopyProc
  286. End Sub
  287. Private Sub mnuEditCut_Click()
  288.     ' Call the cut procedure
  289.     EditCutProc
  290. End Sub
  291. Private Sub mnuEditDelete_Click()
  292.     ' If the mouse pointer is not at the end of the notepad...
  293.     If Screen.ActiveControl.SelStart <> Len(Screen.ActiveControl.Text) Then
  294.         ' If nothing is selected, extend the selection by one.
  295.         If Screen.ActiveControl.SelLength = 0 Then
  296.             Screen.ActiveControl.SelLength = 1
  297.             ' If the mouse pointer is on a blank line, extend the selection by two.
  298.             If Asc(Screen.ActiveControl.SelText) = 13 Then
  299.                 Screen.ActiveControl.SelLength = 2
  300.             End If
  301.         End If
  302.         ' Delete the selected text.
  303.         Screen.ActiveControl.SelText = ""
  304.     End If
  305. End Sub
  306. Private Sub mnuEditPaste_Click()
  307.     ' Call the paste procedure.
  308.     EditPasteProc
  309. End Sub
  310. Private Sub mnuEditSelectAll_Click()
  311.     ' Use SelStart & SelLength to select the text.
  312.     frmMDI.ActiveForm.Text1.SelStart = 0
  313.     frmMDI.ActiveForm.Text1.SelLength = Len(frmMDI.ActiveForm.Text1.Text)
  314. End Sub
  315. Private Sub mnuEditTime_Click()
  316.     ' Insert the current time and date.
  317.     Text1.SelText = Now
  318. End Sub
  319. Private Sub mnuFileClose_Click()
  320.     ' Unload this form.
  321.     Unload Me
  322. End Sub
  323. Private Sub mnuFileExit_Click()
  324.     ' Unloading the MDI form invokes the QueryUnload event
  325.     ' for each child form, and then the MDI form.
  326.     ' Setting the Cancel argument to True in any of the
  327.     ' QueryUnload events cancels the unload.
  328.     Unload frmMDI
  329. End Sub
  330. Private Sub mnuFileNew_Click()
  331.     ' Call the new form procedure
  332.     FileNew
  333. End Sub
  334. Public Sub mnuFontName_Click(index As Integer)
  335.     ' Assign the selected font to the textbox fontname property.
  336.     Text1.FontName = mnuFontName(index).Caption
  337. End Sub
  338. Private Sub mnuFileOpen_Click()
  339.     ' Call the file open procedure.
  340.     FileOpenProc
  341. End Sub
  342. Private Sub mnuFileSave_Click()
  343.     Dim strFilename As String
  344.     If Left(Me.Caption, 8) = "Untitled" Then
  345.         ' The file hasn't been saved yet.
  346.         ' Get the filename, and then call the save procedure, GetFileName.
  347.         strFilename = GetFileName(strFilename)
  348.     Else
  349.         ' The form's Caption contains the name of the open file.
  350.         strFilename = Me.Caption
  351.     End If
  352.     ' Call the save procedure. If Filename = Empty, then
  353.     ' the user chose Cancel in the Save As dialog box; otherwise,
  354.     ' save the file.
  355.     If strFilename <> "" Then
  356.         SaveFileAs strFilename
  357.     End If
  358. End Sub
  359. Private Sub mnuFileSaveAs_Click()
  360.     Dim strSaveFileName As String
  361.     Dim strDefaultName As String
  362.     ' Assign the form caption to the variable.
  363.     strDefaultName = Me.Caption
  364.     If Left(Me.Caption, 8) = "Untitled" Then
  365.         ' The file hasn't been saved yet.
  366.         ' Get the filename, and then call the save procedure, strSaveFileName.
  367.         
  368.         strSaveFileName = GetFileName("Untitled.txt")
  369.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  370.         ' Update the list of recently opened files in the File menu control array.
  371.         UpdateFileMenu (strSaveFileName)
  372.     Else
  373.         ' The form's Caption contains the name of the open file.
  374.         
  375.         strSaveFileName = GetFileName(strDefaultName)
  376.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  377.         ' Update the list of recently opened files in the File menu control array.
  378.         UpdateFileMenu (strSaveFileName)
  379.     End If
  380. End Sub
  381. Private Sub mnuHelpAssistantHelp_Click()
  382.     ' Call the Assistant procedure
  383.     Assistant
  384. End Sub
  385. Private Sub mnuOptions_Click()
  386.     ' Toggle the Checked property to match the .Visible property.
  387.     mnuOptionsToolbar.Checked = frmMDI.picToolbar.Visible
  388. End Sub
  389. Private Sub mnuOptionsToolbar_Click()
  390.     ' Call the toolbar procedure, passing a reference
  391.     ' to this form instance.
  392.     OptionsToolbarProc Me
  393. End Sub
  394. Private Sub mnuRecentFile_Click(index As Integer)
  395.     ' Call the file open procedure, passing a
  396.     ' reference to the selected file name
  397.     OpenFile (mnuRecentFile(index).Caption)
  398.     ' Update the list of recently opened files in the File menu control array.
  399.     GetRecentFiles
  400. End Sub
  401. Private Sub mnuSearchFind_Click()
  402.     ' If there is text in the textbox, assign it to
  403.     ' the textbox on the Find form, otherwise assign
  404.     ' the last findtext value.
  405.     If Me.Text1.SelText <> "" Then
  406.         frmFind.Text1.Text = Me.Text1.SelText
  407.     Else
  408.         frmFind.Text1.Text = gFindString
  409.     End If
  410.     ' Set the public variable to start at the beginning.
  411.     gFirstTime = True
  412.     ' Set the case checkbox to match the public variable
  413.     If (gFindCase) Then
  414.         frmFind.chkCase = 1
  415.     End If
  416.     ' Display the Find form.
  417.     frmFind.Show vbModal
  418. End Sub
  419. Private Sub mnuSearchFindNext_Click()
  420.     ' If the public variable isn't empty, call the
  421.     ' find procedure, otherwise call the find menu
  422.     If Len(gFindString) > 0 Then
  423.         FindIt
  424.     Else
  425.         mnuSearchFind_Click
  426.     End If
  427. End Sub
  428. Private Sub mnuWindowArrange_Click()
  429.     ' Arrange the icons for any minimzied child forms.
  430.     frmMDI.Arrange vbArrangeIcons
  431. End Sub
  432. Private Sub mnuWindowCascade_Click()
  433.     ' Cascade the child forms.
  434.     frmMDI.Arrange vbCascade
  435. End Sub
  436. Private Sub mnuWindowTile_Click()
  437.     ' Tile the child forms.
  438.     frmMDI.Arrange vbTileHorizontal
  439. End Sub
  440. Private Sub Text1_Change()
  441.     ' Set the public variable to show that text has changed.
  442.     FState(Me.Tag).Dirty = True
  443. End Sub
  444.