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

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