home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic new SourceCode and Projects / Adventure game / notepad2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-05-09  |  12.8 KB  |  380 lines

  1. VERSION 5.00
  2. Begin VB.Form frmNotePad2 
  3.    Caption         =   "Untitled"
  4.    ClientHeight    =   4095
  5.    ClientLeft      =   1515
  6.    ClientTop       =   3315
  7.    ClientWidth     =   7470
  8.    BeginProperty Font 
  9.       Name            =   "Times New Roman"
  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.    Icon            =   "notepad2.frx":0000
  18.    LinkTopic       =   "Form1"
  19.    MDIChild        =   -1  'True
  20.    ScaleHeight     =   4095
  21.    ScaleMode       =   0  'User
  22.    ScaleWidth      =   133.156
  23.    Begin VB.TextBox Text1 
  24.       Height          =   4095
  25.       HideSelection   =   0   'False
  26.       Left            =   0
  27.       MultiLine       =   -1  'True
  28.       ScrollBars      =   2  'Vertical
  29.       TabIndex        =   0
  30.       Top             =   0
  31.       Width           =   7455
  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. Attribute VB_Name = "frmNotePad2"
  152. Attribute VB_GlobalNameSpace = False
  153. Attribute VB_Creatable = False
  154. Attribute VB_PredeclaredId = True
  155. Attribute VB_Exposed = False
  156. '*** Child form for the MDI Notepad sample application  ***
  157. '**********************************************************
  158. Option Explicit
  159. Private Sub Form_Load()
  160.     Dim i As Integer        ' Counter variable.
  161.     ' Assign the name of the first font to a font
  162.     ' menu entry, then loop through the fonts
  163.     ' collection, adding them to the menu
  164.     mnuFontName(0).Caption = Screen.Fonts(0)
  165.     For i = 1 To Screen.FontCount - 1
  166.         Load mnuFontName(i)
  167.         mnuFontName(0).Caption = Screen.Fonts(i)
  168.     Next
  169. End Sub
  170. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  171.     Dim strMsg As String
  172.     Dim strFilename As String
  173.     Dim intResponse As Integer
  174.     ' Check to see if the text has been changed.
  175.     If FState(Me.Tag).Dirty Then
  176.         strFilename = Me.Caption
  177.         strMsg = "The text in [" & strFilename & "] has changed."
  178.         strMsg = strMsg & vbCrLf
  179.         strMsg = strMsg & "Do you want to save the changes?"
  180.         intResponse = MsgBox(strMsg, 51, frmMDI.Caption)
  181.         Select Case intResponse
  182.             Case 6      ' User chose Yes.
  183.                 If Left(Me.Caption, 8) = "Untitled" Then
  184.                     ' The file hasn't been saved yet.
  185.                     strFilename = "untitled.txt"
  186.                     ' Get the strFilename, and then call the save procedure, GetstrFilename.
  187.                     strFilename = GetFileName(strFilename)
  188.                 Else
  189.                     ' The form's Caption contains the name of the open file.
  190.                     strFilename = Me.Caption
  191.                 End If
  192.                 ' Call the save procedure. If strFilename = Empty, then
  193.                 ' the user chose Cancel in the Save As dialog box; otherwise,
  194.                 ' save the file.
  195.                 If strFilename <> "" Then
  196.                     SaveFileAs strFilename
  197.                 End If
  198.             Case 7      ' User chose No. Unload the file.
  199.                 Cancel = False
  200.             Case 2      ' User chose Cancel. Cancel the unload.
  201.                 Cancel = True
  202.         End Select
  203.     End If
  204. End Sub
  205. Private Sub Form_Resize()
  206.     ' Expand text box to fill the current child form's internal area.
  207.     Text1.Height = ScaleHeight
  208.     Text1.Width = ScaleWidth
  209. End Sub
  210. Private Sub Form_Unload(Cancel As Integer)
  211.     ' Show the current form instance as deleted
  212.     FState(Me.Tag).Deleted = True
  213.     ' Hide the toolbar edit buttons if no notepad windows exist.
  214.     If Not AnyPadsLeft() Then
  215.         frmMDI.imgCutButton.Visible = False
  216.         frmMDI.imgCopyButton.Visible = False
  217.         frmMDI.imgPasteButton.Visible = False
  218.         ' Toggle the public tool state variable
  219.         gToolsHidden = True
  220.         ' Call the recent file list procedure
  221.     End If
  222. End Sub
  223. Private Sub mnuEditCopy_Click()
  224.     ' Call the copy procedure
  225.     EditCopyProc
  226. End Sub
  227. Private Sub mnuEditCut_Click()
  228.     ' Call the cut procedure
  229.     EditCutProc
  230. End Sub
  231. Private Sub mnuEditDelete_Click()
  232.     ' If the mouse pointer is not at the end of the notepad...
  233.     If Screen.ActiveControl.SelStart <> Len(Screen.ActiveControl.Text) Then
  234.         ' If nothing is selected, extend the selection by one.
  235.         If Screen.ActiveControl.SelLength = 0 Then
  236.             Screen.ActiveControl.SelLength = 1
  237.             ' If the mouse pointer is on a blank line, extend the selection by two.
  238.             If Asc(Screen.ActiveControl.SelText) = 13 Then
  239.                 Screen.ActiveControl.SelLength = 2
  240.             End If
  241.         End If
  242.         ' Delete the selected text.
  243.         Screen.ActiveControl.SelText = ""
  244.     End If
  245. End Sub
  246. Private Sub mnuEditPaste_Click()
  247.     ' Call the paste procedure.
  248.     EditPasteProc
  249. End Sub
  250. Private Sub mnuEditSelectAll_Click()
  251.     ' Use SelStart & SelLength to select the text.
  252.     frmMDI.ActiveForm.Text1.SelStart = 0
  253.     frmMDI.ActiveForm.Text1.SelLength = Len(frmMDI.ActiveForm.Text1.Text)
  254. End Sub
  255. Private Sub mnuEditTime_Click()
  256.     ' Insert the current time and date.
  257.     Text1.SelText = Now
  258. End Sub
  259. Private Sub mnuFileClose_Click()
  260.     ' Unload this form.
  261.     Unload Me
  262. End Sub
  263. Private Sub mnuFileExit_Click()
  264.     ' Unloading the MDI form invokes the QueryUnload event
  265.     ' for each child form, and then the MDI form.
  266.     ' Setting the Cancel argument to True in any of the
  267.     ' QueryUnload events cancels the unload.
  268.     Unload frmMDI
  269. End Sub
  270. Private Sub mnuFileNew_Click()
  271.     ' Call the new form procedure
  272.     FileNew
  273. End Sub
  274. Private Sub mnuFontName_Click(index As Integer)
  275.     ' Assign the selected font to the textbox fontname property.
  276.     Text1.FontName = mnuFontName(index).Caption
  277. End Sub
  278. Private Sub mnuFileOpen_Click()
  279.     ' Call the file open procedure.
  280.     FileOpenProc
  281. End Sub
  282. Private Sub mnuFileSave_Click()
  283.     Dim strFilename As String
  284.     If Left(Me.Caption, 8) = "Untitled" Then
  285.         ' The file hasn't been saved yet.
  286.         ' Get the filename, and then call the save procedure, GetFileName.
  287.         strFilename = GetFileName(strFilename)
  288.     Else
  289.         ' The form's Caption contains the name of the open file.
  290.         strFilename = Me.Caption
  291.     End If
  292.     ' Call the save procedure. If Filename = Empty, then
  293.     ' the user chose Cancel in the Save As dialog box; otherwise,
  294.     ' save the file.
  295.     If strFilename <> "" Then
  296.         SaveFileAs strFilename
  297.     End If
  298. End Sub
  299. Private Sub mnuFileSaveAs_Click()
  300.     Dim strSaveFileName As String
  301.     Dim strDefaultName As String
  302.     ' Assign the form caption to the variable.
  303.     strDefaultName = Me.Caption
  304.     If Left(Me.Caption, 8) = "Untitled" Then
  305.         ' The file hasn't been saved yet.
  306.         ' Get the filename, and then call the save procedure, strSaveFileName.
  307.         
  308.         strSaveFileName = GetFileName("Untitled.txt")
  309.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  310.         ' Update the list of recently opened files in the File menu control array.
  311.         UpdateFileMenu (strSaveFileName)
  312.     Else
  313.         ' The form's Caption contains the name of the open file.
  314.         
  315.         strSaveFileName = GetFileName(strDefaultName)
  316.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  317.         ' Update the list of recently opened files in the File menu control array.
  318.         UpdateFileMenu (strSaveFileName)
  319.     End If
  320. End Sub
  321. Private Sub mnuOptions_Click()
  322.     ' Toggle the Checked property to match the .Visible property.
  323.     mnuOptionsToolbar.Checked = frmMDI.picToolbar.Visible
  324. End Sub
  325. Private Sub mnuOptionsToolbar_Click()
  326.     ' Call the toolbar procedure, passing a reference
  327.     ' to this form instance.
  328.     OptionsToolbarProc Me
  329. End Sub
  330. Private Sub mnuRecentFile_Click(index As Integer)
  331.     ' Call the file open procedure, passing a
  332.     ' reference to the selected file name
  333.     OpenFile (mnuRecentFile(index).Caption)
  334.     ' Update the list of recently opened files in the File menu control array.
  335.     GetRecentFiles
  336. End Sub
  337. Private Sub mnuSearchFind_Click()
  338.     ' If there is text in the textbox, assign it to
  339.     ' the textbox on the Find form, otherwise assign
  340.     ' the last findtext value.
  341.     If Me.Text1.SelText <> "" Then
  342.         frmFind.Text1.Text = Me.Text1.SelText
  343.     Else
  344.         frmFind.Text1.Text = gFindString
  345.     End If
  346.     ' Set the public variable to start at the beginning.
  347.     gFirstTime = True
  348.     ' Set the case checkbox to match the public variable
  349.     If (gFindCase) Then
  350.         frmFind.chkCase = 1
  351.     End If
  352.     ' Display the Find form.
  353.     frmFind.Show vbModal
  354. End Sub
  355. Private Sub mnuSearchFindNext_Click()
  356.     ' If the public variable isn't empty, call the
  357.     ' find procedure, otherwise call the find menu
  358.     If Len(gFindString) > 0 Then
  359.         FindIt
  360.     Else
  361.         mnuSearchFind_Click
  362.     End If
  363. End Sub
  364. Private Sub mnuWindowArrange_Click()
  365.     ' Arrange the icons for any minimzied child forms.
  366.     frmMDI.Arrange vbArrangeIcons
  367. End Sub
  368. Private Sub mnuWindowCascade_Click()
  369.     ' Cascade the child forms.
  370.     frmMDI.Arrange vbCascade
  371. End Sub
  372. Private Sub mnuWindowTile_Click()
  373.     ' Tile the child forms.
  374.     frmMDI.Arrange vbTileHorizontal
  375. End Sub
  376. Private Sub Text1_Change()
  377.     ' Set the public variable to show that text has changed.
  378.     FState(Me.Tag).Dirty = True
  379. End Sub
  380.