home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap25 / mdi / notepad.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1995-09-12  |  12.3 KB  |  403 lines

  1. VERSION 4.00
  2. Begin VB.Form frmNotePad 
  3.    Caption         =   "Untitled"
  4.    ClientHeight    =   4845
  5.    ClientLeft      =   1200
  6.    ClientTop       =   1770
  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          =   5535
  18.    Left            =   1140
  19.    LinkTopic       =   "Form1"
  20.    MDIChild        =   -1  'True
  21.    ScaleHeight     =   4845
  22.    ScaleMode       =   0  'User
  23.    ScaleWidth      =   101.07
  24.    Top             =   1140
  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 MSMAPI.MAPIMessages MAPIMessages1 
  38.       Left            =   1140
  39.       Top             =   4260
  40.       _version        =   65536
  41.       _extentx        =   741
  42.       _extenty        =   741
  43.       _stockprops     =   0
  44.    End
  45.    Begin MSMAPI.MAPISession MAPISession1 
  46.       Left            =   360
  47.       Top             =   4260
  48.       _version        =   65536
  49.       _extentx        =   741
  50.       _extenty        =   741
  51.       _stockprops     =   0
  52.    End
  53.    Begin VB.Menu mnuFile 
  54.       Caption         =   "&File"
  55.       WindowList      =   -1  'True
  56.       Begin VB.Menu mnuFNew 
  57.          Caption         =   "&New"
  58.       End
  59.       Begin VB.Menu mnuFOpen 
  60.          Caption         =   "&Open..."
  61.       End
  62.       Begin VB.Menu mnuFClose 
  63.          Caption         =   "&Close"
  64.       End
  65.       Begin VB.Menu mnuFSave 
  66.          Caption         =   "&Save"
  67.       End
  68.       Begin VB.Menu mnuFSaveAs 
  69.          Caption         =   "Save &As..."
  70.       End
  71.       Begin VB.Menu mnuFileSp01 
  72.          Caption         =   "-"
  73.       End
  74.       Begin VB.Menu mnuFileSend 
  75.          Caption         =   "&Send..."
  76.       End
  77.       Begin VB.Menu mnuFSep 
  78.          Caption         =   "-"
  79.       End
  80.       Begin VB.Menu mnuFExit 
  81.          Caption         =   "E&xit"
  82.       End
  83.       Begin VB.Menu mnuRecentFile 
  84.          Caption         =   "-"
  85.          Index           =   0
  86.          Visible         =   0   'False
  87.       End
  88.       Begin VB.Menu mnuRecentFile 
  89.          Caption         =   "RecentFile1"
  90.          Index           =   1
  91.          Visible         =   0   'False
  92.       End
  93.       Begin VB.Menu mnuRecentFile 
  94.          Caption         =   "RecentFile2"
  95.          Index           =   2
  96.          Visible         =   0   'False
  97.       End
  98.       Begin VB.Menu mnuRecentFile 
  99.          Caption         =   "RecentFile3"
  100.          Index           =   3
  101.          Visible         =   0   'False
  102.       End
  103.       Begin VB.Menu mnuRecentFile 
  104.          Caption         =   "RecentFile4"
  105.          Index           =   4
  106.          Visible         =   0   'False
  107.       End
  108.    End
  109.    Begin VB.Menu mnuEdit 
  110.       Caption         =   "&Edit"
  111.       Begin VB.Menu mnuECut 
  112.          Caption         =   "Cu&t"
  113.          Shortcut        =   ^X
  114.       End
  115.       Begin VB.Menu mnuECopy 
  116.          Caption         =   "&Copy"
  117.          Shortcut        =   ^C
  118.       End
  119.       Begin VB.Menu mnuEPaste 
  120.          Caption         =   "&Paste"
  121.          Shortcut        =   ^V
  122.       End
  123.       Begin VB.Menu mnuEDelete 
  124.          Caption         =   "De&lete"
  125.          Shortcut        =   {DEL}
  126.       End
  127.       Begin VB.Menu mnuESep1 
  128.          Caption         =   "-"
  129.       End
  130.       Begin VB.Menu mnuESelectAll 
  131.          Caption         =   "Select &All"
  132.       End
  133.       Begin VB.Menu mnuETime 
  134.          Caption         =   "Time/&Date"
  135.       End
  136.    End
  137.    Begin VB.Menu mnuSearch 
  138.       Caption         =   "&Search"
  139.       Begin VB.Menu mnuSFind 
  140.          Caption         =   "&Find"
  141.       End
  142.       Begin VB.Menu mnuSFindNext 
  143.          Caption         =   "Find &Next"
  144.          Shortcut        =   {F3}
  145.       End
  146.    End
  147.    Begin VB.Menu mnuOptions 
  148.       Caption         =   "&Options"
  149.       Begin VB.Menu mnuOToolbar 
  150.          Caption         =   "&Toolbar"
  151.       End
  152.       Begin VB.Menu mnuFont 
  153.          Caption         =   "&Font"
  154.          Begin VB.Menu mnuFontName 
  155.             Caption         =   "FontName"
  156.             Index           =   0
  157.          End
  158.       End
  159.    End
  160.    Begin VB.Menu mnuWindow 
  161.       Caption         =   "&Window"
  162.       Begin VB.Menu mnuWCascade 
  163.          Caption         =   "&Cascade"
  164.       End
  165.       Begin VB.Menu mnuWTile 
  166.          Caption         =   "&Tile"
  167.       End
  168.       Begin VB.Menu mnuWArrange 
  169.          Caption         =   "&Arrange Icons"
  170.       End
  171.    End
  172. Attribute VB_Name = "frmNotePad"
  173. Attribute VB_Creatable = False
  174. Attribute VB_Exposed = False
  175. Private Sub Form_Load()
  176.     Dim i As Integer
  177.     mnuFontName(0).Caption = Screen.Fonts(0)
  178.     For i = 1 To Screen.FontCount - 1
  179.         Load mnuFontName(i)
  180.         mnuFontName(0).Caption = Screen.Fonts(i)
  181.     Next
  182. End Sub
  183. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  184.     Dim Msg, Filename, NL
  185.     Dim Response As Integer
  186.     If FState(Me.Tag).Dirty Then
  187.         Filename = Me.Caption
  188.         NL = Chr(10) & Chr(13)
  189.         Msg = "The text in [" & Filename & "] has changed."
  190.         Msg = Msg & NL
  191.         Msg = Msg & "Do you want to save the changes?"
  192.         Response = MsgBox(Msg, 51, frmMDI.Caption)
  193.         Select Case Response
  194.             Case 6      ' User chose Yes.
  195.             If Left(Me.Caption, 8) = "Untitled" Then
  196.             ' The file hasn't been saved yet.
  197.             Filename = "untitled.txt"
  198.             ' Get the filename, and then call the save procedure, GetFileName.
  199.                 Filename = GetFileName(Filename)
  200.             Else
  201.                 ' The form's Caption contains the name of the open file.
  202.                 Filename = Me.Caption
  203.             End If
  204.             ' Call the save procedure. If Filename = Empty, then
  205.             ' the user chose Cancel in the Save As dialog box; otherwise,
  206.             ' save the file.
  207.             If Filename <> "" Then
  208.                 SaveFileAs Filename
  209.             End If
  210.             Case 7      ' User chose No. Unload the file.
  211.                 Cancel = False
  212.             Case 2      ' User chose Cancel. Cancel the unload.
  213.                 Cancel = True
  214.         End Select
  215.     End If
  216. End Sub
  217. Private Sub Form_Resize()
  218.     If WindowState <> 1 And ScaleHeight <> 0 Then
  219.         Text1.Visible = False
  220.         Text1.Height = ScaleHeight
  221.         Text1.Width = ScaleWidth
  222.         
  223.         Text1.Visible = True
  224.     End If
  225. End Sub
  226. Private Sub Form_Unload(Cancel As Integer)
  227.     FState(Me.Tag).Deleted = True
  228.     ' Hide the toolbar edit buttons if no notepad windows exist.
  229.     If Not AnyPadsLeft() Then
  230.         frmMDI!imgcutbutton.Visible = False
  231.         frmMDI!imgcopybutton.Visible = False
  232.         frmMDI!imgPasteButton.Visible = False
  233.         gToolsHidden = True
  234.         GetRecentFiles
  235.     End If
  236. End Sub
  237. Private Sub mnuECopy_Click()
  238.     EditCopyProc
  239. End Sub
  240. Private Sub mnuECut_Click()
  241.     EditCutProc
  242. End Sub
  243. Private Sub mnuEDelete_Click()
  244.     ' If the mouse pointer is not at the end of the notepad...
  245.     If Screen.ActiveControl.SelStart <> Len(Screen.ActiveControl.Text) Then
  246.         ' If nothing is selected, extend the selection by one.
  247.         If Screen.ActiveControl.SelLength = 0 Then
  248.             Screen.ActiveControl.SelLength = 1
  249.             ' If the mouse pointer is on a blank line, extend the selection by two.
  250.             If Asc(Screen.ActiveControl.SelText) = 13 Then
  251.                 Screen.ActiveControl.SelLength = 2
  252.             End If
  253.         End If
  254.         ' Delete the selected text.
  255.         Screen.ActiveControl.SelText = ""
  256.     End If
  257. End Sub
  258. Private Sub mnuEPaste_Click()
  259.     EditPasteProc
  260. End Sub
  261. Private Sub mnuESelectAll_Click()
  262.     frmMDI.ActiveForm.Text1.SelStart = 0
  263.     frmMDI.ActiveForm.Text1.SelLength = Len(frmMDI.ActiveForm.Text1.Text)
  264. End Sub
  265. Private Sub mnuETime_Click()
  266.     Dim TimeStr As String, DateStr As String
  267.     Text1.SelText = Now
  268. End Sub
  269. Private Sub mnuFClose_Click()
  270.     Unload Me
  271. End Sub
  272. Private Sub mnuFExit_Click()
  273.     ' Unloading the MDI form invokes the QueryUnload event
  274.     ' for each child form, and then the MDI form.
  275.     ' Setting the Cancel argument to True in any of the
  276.     ' QueryUnload events cancels the unload.
  277.     Unload frmMDI
  278. End Sub
  279. Private Sub mnuFileSend_Click()
  280.     '
  281.     ' log onto mail server
  282.     ' start mail compose session
  283.     ' log off mail server
  284.     '
  285.     On Error GoTo mnuFileSendErr
  286.     '
  287.     '
  288.     MAPISession1.DownloadMail = False   ' dont check box
  289.     MAPISession1.SignOn     ' start mail session
  290.     MAPIMessages1.SessionID = MAPISession1.SessionID
  291.     '
  292.     ' handle sending msg
  293.     MAPIMessages1.Compose   ' clear buffer
  294.     MAPIMessages1.MsgNoteText = Me.Text1    ' get text
  295.     MAPIMessages1.MsgSubject = Me.Caption
  296.     MAPIMessages1.Show
  297.     MAPIMessages1.Send
  298.     '
  299.     MAPISession1.SignOff    ' end mail session
  300.     '
  301.     Exit Sub
  302.     '
  303. mnuFileSendErr:
  304.     MsgBox Error$, vbCritical, "Mail Send Error " + Str(Err)
  305.     On Error Resume Next
  306.     MAPISession1.SignOff
  307.     '
  308. End Sub
  309. Private Sub mnuFNew_Click()
  310.     FileNew
  311. End Sub
  312. Private Sub mnuFontName_Click(index As Integer)
  313.     Text1.FontName = mnuFontName(index).Caption
  314. End Sub
  315. Private Sub mnuFOpen_Click()
  316.     FOpenProc
  317. End Sub
  318. Private Sub mnuFSave_Click()
  319.     Dim Filename As String
  320.     If Left(Me.Caption, 8) = "Untitled" Then
  321.         ' The file hasn't been saved yet.
  322.         ' Get the filename, and then call the save procedure, GetFileName.
  323.         Filename = GetFileName(Filename)
  324.     Else
  325.         ' The form's Caption contains the name of the open file.
  326.         Filename = Me.Caption
  327.     End If
  328.     ' Call the save procedure. If Filename = Empty, then
  329.     ' the user chose Cancel in the Save As dialog box; otherwise,
  330.     ' save the file.
  331.     If Filename <> "" Then
  332.         SaveFileAs Filename
  333.     End If
  334. End Sub
  335. Private Sub mnuFSaveAs_Click()
  336.     Dim SaveFileName As String
  337.     Dim DefaultName As String
  338.     DefaultName = Me.Caption
  339.     If Left(Me.Caption, 8) = "Untitled" Then
  340.         ' The file hasn't been saved yet.
  341.         ' Get the filename, and then call the save procedure, SaveFileName.
  342.         
  343.         SaveFileName = GetFileName("Untitled.txt")
  344.         If SaveFileName <> "" Then SaveFileAs (SaveFileName)
  345.         ' Update the list of recently opened files in the File menu control array.
  346.         UpdateFileMenu (SaveFileName)
  347.     Else
  348.         ' The form's Caption contains the name of the open file.
  349.         
  350.         SaveFileName = GetFileName(DefaultName)
  351.         If SaveFileName <> "" Then SaveFileAs (SaveFileName)
  352.         ' Update the list of recently opened files in the File menu control array.
  353.         UpdateFileMenu (SaveFileName)
  354.     End If
  355. End Sub
  356. Private Sub mnuOptions_Click()
  357.     mnuOToolbar.Checked = frmMDI!picToolbar.Visible
  358. End Sub
  359. Private Sub mnuOToolbar_Click()
  360.     OptionsToolbarProc Me
  361. End Sub
  362. Private Sub mnuRecentFile_Click(index As Integer)
  363.     OpenFile (mnuRecentFile(index).Caption)
  364.     ' Update the list of recently opened files in the File menu control array.
  365.     GetRecentFiles
  366. End Sub
  367. Private Sub mnuSFind_Click()
  368.     If Me!Text1.SelText <> "" Then
  369.         frmFind!Text1.Text = Me!Text1.SelText
  370.     Else
  371.         frmFind!Text1.Text = gFindString
  372.     End If
  373.     gFirstTime = True
  374.     If (gFindCase) Then
  375.         frmFind.chkCase = 1
  376.     End If
  377.     frmFind.Show
  378. End Sub
  379. Private Sub mnuSFindNext_Click()
  380.     If Len(gFindString) > 0 Then
  381.         FindIt
  382.     Else
  383.         mnuSFind_Click
  384.     End If
  385. End Sub
  386. Private Sub mnuWArrange_Click()
  387.     frmMDI.Arrange vbArrangeIcons
  388. End Sub
  389. Private Sub mnuWCascade_Click()
  390.     frmMDI.Arrange vbCascade
  391. End Sub
  392. Private Sub mnuWTile_Click()
  393.     frmMDI.Arrange vbTileHorizontal
  394. End Sub
  395. Private Sub Text1_Change()
  396.     FState(Me.Tag).Dirty = True
  397. End Sub
  398. Private Sub Text1_GotFocus()
  399.     If frmFind.Visible Then
  400.         frmFind.ZOrder 0
  401.     End If
  402. End Sub
  403.