home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / PGUIDE / MDI / NOTEPAD.FRM (.txt) < prev   
Encoding:
Visual Basic Form  |  1997-01-20  |  11.9 KB  |  423 lines

  1. VERSION 5.00
  2. Begin VB.Form frmNotePad 
  3.    Caption         =   "
  4.    ClientHeight    =   3990
  5.    ClientLeft      =   1515
  6.    ClientTop       =   3315
  7.    ClientWidth     =   5775
  8.    BeginProperty Font 
  9.       Name            =   "
  10.       Size            =   9
  11.       Charset         =   134
  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      =   102.941
  22.    Begin VB.TextBox Text1 
  23.       BeginProperty Font 
  24.          Name            =   "
  25.          Size            =   9
  26.          Charset         =   134
  27.          Weight          =   400
  28.          Underline       =   0   'False
  29.          Italic          =   0   'False
  30.          Strikethrough   =   0   'False
  31.       EndProperty
  32.       Height          =   3975
  33.       HideSelection   =   0   'False
  34.       Left            =   0
  35.       MultiLine       =   -1  'True
  36.       ScrollBars      =   2  'Vertical
  37.       TabIndex        =   0
  38.       Top             =   0
  39.       Width           =   5655
  40.    End
  41.    Begin VB.Menu mnuFile 
  42.       Caption         =   "
  43. (&F)"
  44.       Begin VB.Menu mnuFileNew 
  45.          Caption         =   "
  46. (&N)"
  47.       End
  48.       Begin VB.Menu mnuFileOpen 
  49.          Caption         =   "
  50. (&O)..."
  51.       End
  52.       Begin VB.Menu mnuFileClose 
  53.          Caption         =   "
  54. (&C)"
  55.       End
  56.       Begin VB.Menu mnuFileSave 
  57.          Caption         =   "
  58. (&S)"
  59.       End
  60.       Begin VB.Menu mnuFileSaveAs 
  61.          Caption         =   "
  62. (&A)..."
  63.       End
  64.       Begin VB.Menu mnuFSep 
  65.          Caption         =   "-"
  66.       End
  67.       Begin VB.Menu mnuFileExit 
  68.          Caption         =   "
  69. (&X)"
  70.       End
  71.       Begin VB.Menu mnuRecentFile 
  72.          Caption         =   "-"
  73.          Index           =   0
  74.          Visible         =   0   'False
  75.       End
  76.       Begin VB.Menu mnuRecentFile 
  77.          Caption         =   "RecentFile1"
  78.          Index           =   1
  79.          Visible         =   0   'False
  80.       End
  81.       Begin VB.Menu mnuRecentFile 
  82.          Caption         =   "RecentFile2"
  83.          Index           =   2
  84.          Visible         =   0   'False
  85.       End
  86.       Begin VB.Menu mnuRecentFile 
  87.          Caption         =   "RecentFile3"
  88.          Index           =   3
  89.          Visible         =   0   'False
  90.       End
  91.       Begin VB.Menu mnuRecentFile 
  92.          Caption         =   "RecentFile4"
  93.          Index           =   4
  94.          Visible         =   0   'False
  95.       End
  96.       Begin VB.Menu mnuRecentFile 
  97.          Caption         =   "RecentFile5"
  98.          Index           =   5
  99.          Visible         =   0   'False
  100.       End
  101.    End
  102.    Begin VB.Menu mnuEdit 
  103.       Caption         =   "
  104. (&E)"
  105.       Begin VB.Menu mnuEditCut 
  106.          Caption         =   "
  107. (&U)"
  108.          Shortcut        =   ^X
  109.       End
  110.       Begin VB.Menu mnuEditCopy 
  111.          Caption         =   "
  112. (&C)"
  113.          Shortcut        =   ^C
  114.       End
  115.       Begin VB.Menu mnuEditPaste 
  116.          Caption         =   "
  117. (&P)"
  118.          Shortcut        =   ^V
  119.       End
  120.       Begin VB.Menu mnuEditDelete 
  121.          Caption         =   "
  122. (&L)"
  123.          Shortcut        =   {DEL}
  124.       End
  125.       Begin VB.Menu mnuESep1 
  126.          Caption         =   "-"
  127.       End
  128.       Begin VB.Menu mnuEditSelectAll 
  129.          Caption         =   "
  130. (&A)"
  131.       End
  132.       Begin VB.Menu mnuEditTime 
  133.          Caption         =   "
  134. (&D)"
  135.       End
  136.    End
  137.    Begin VB.Menu mnuSearch 
  138.       Caption         =   "
  139. (&S)"
  140.       Begin VB.Menu mnuSearchFind 
  141.          Caption         =   "
  142. (&F)"
  143.       End
  144.       Begin VB.Menu mnuSearchFindNext 
  145.          Caption         =   "
  146. (&N)"
  147.          Shortcut        =   {F3}
  148.       End
  149.    End
  150.    Begin VB.Menu mnuOptions 
  151.       Caption         =   "
  152. (&O)"
  153.       Begin VB.Menu mnuOptionsToolbar 
  154.          Caption         =   "
  155. (&T)"
  156.       End
  157.       Begin VB.Menu mnuFont 
  158.          Caption         =   "
  159. (&F)"
  160.          Begin VB.Menu mnuFontName 
  161.             Caption         =   "
  162.             Index           =   0
  163.          End
  164.       End
  165.    End
  166.    Begin VB.Menu mnuWindow 
  167.       Caption         =   "
  168. (&W)"
  169.       WindowList      =   -1  'True
  170.       Begin VB.Menu mnuWindowCascade 
  171.          Caption         =   "
  172. (&C)"
  173.       End
  174.       Begin VB.Menu mnuWindowTile 
  175.          Caption         =   "
  176. (&T)"
  177.       End
  178.       Begin VB.Menu mnuWindowArrange 
  179.          Caption         =   "
  180. (&A)"
  181.       End
  182.    End
  183. Attribute VB_Name = "frmNotePad"
  184. Attribute VB_GlobalNameSpace = False
  185. Attribute VB_Creatable = False
  186. Attribute VB_PredeclaredId = True
  187. Attribute VB_Exposed = False
  188. '***        MDI 
  189.              ***
  190. '*******************************************************
  191. Option Explicit
  192. Private Sub Form_Load()
  193.     Dim i As Integer        ' 
  194.     ' 
  195.     mnuFontName(0).Caption = Screen.Fonts(0)
  196.     For i = 1 To Screen.FontCount - 1
  197.         Load mnuFontName(i)
  198.         mnuFontName(0).Caption = Screen.Fonts(i)
  199.     Next
  200. End Sub
  201. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  202.     Dim strMsg As String
  203.     Dim strFilename As String
  204.     Dim intResponse As Integer
  205.     ' 
  206.     If FState(Me.Tag).Dirty Then
  207.         strFilename = Me.Caption
  208.         strMsg = "[" & strFilename & "] 
  209.         strMsg = strMsg & vbCrLf
  210.         strMsg = strMsg & "
  211.         intResponse = MsgBox(strMsg, 51, frmMDI.Caption)
  212.         Select Case intResponse
  213.             Case 6      ' 
  214.                 If Left(Me.Caption, 3) = "
  215. " Then
  216.                     ' 
  217.                     strFilename = "
  218. .txt"
  219.                     ' 
  220.  strFilename
  221. GetstrFilename.
  222.                     strFilename = GetFileName(strFilename)
  223.                 Else
  224.                     ' 
  225.                     strFilename = Me.Caption
  226.                 End If
  227.                 ' 
  228.                 ' 
  229.  strFilename = Empty
  230.                 If strFilename <> "" Then
  231.                     SaveFileAs strFilename
  232.                 End If
  233.             Case 7      ' 
  234.                 Cancel = False
  235.             Case 2      ' 
  236.                 Cancel = True
  237.         End Select
  238.     End If
  239. End Sub
  240. Private Sub Form_Resize()
  241.     ' 
  242.     Text1.Height = ScaleHeight
  243.     Text1.Width = ScaleWidth
  244. End Sub
  245. Private Sub Form_Unload(Cancel As Integer)
  246.     ' 
  247.     FState(Me.Tag).Deleted = True
  248.     ' 
  249.     If Not AnyPadsLeft() Then
  250.         frmMDI.imgCutButton.Visible = False
  251.         frmMDI.imgCopyButton.Visible = False
  252.         frmMDI.imgPasteButton.Visible = False
  253.         ' 
  254.         gToolsHidden = True
  255.         ' 
  256.         GetRecentFiles
  257.     End If
  258. End Sub
  259. Private Sub mnuEditCopy_Click()
  260.     ' 
  261.     EditCopyProc
  262. End Sub
  263. Private Sub mnuEditCut_Click()
  264.     ' 
  265.     EditCutProc
  266. End Sub
  267. Private Sub mnuEditDelete_Click()
  268.     ' 
  269.     If Screen.ActiveControl.SelStart <> Len(Screen.ActiveControl.Text) Then
  270.         ' 
  271.         If Screen.ActiveControl.SelLength = 0 Then
  272.             Screen.ActiveControl.SelLength = 1
  273.             ' 
  274.             If Asc(Screen.ActiveControl.SelText) = 13 Then
  275.                 Screen.ActiveControl.SelLength = 2
  276.             End If
  277.         End If
  278.         ' 
  279.         Screen.ActiveControl.SelText = ""
  280.     End If
  281. End Sub
  282. Private Sub mnuEditPaste_Click()
  283.     ' 
  284.     EditPasteProc
  285. End Sub
  286. Private Sub mnuEditSelectAll_Click()
  287.     ' 
  288.  SelStart 
  289.  SelLength 
  290.     frmMDI.ActiveForm.Text1.SelStart = 0
  291.     frmMDI.ActiveForm.Text1.SelLength = Len(frmMDI.ActiveForm.Text1.Text)
  292. End Sub
  293. Private Sub mnuEditTime_Click()
  294.     ' 
  295.     Text1.SelText = Now
  296. End Sub
  297. Private Sub mnuFileClose_Click()
  298.     ' 
  299.     Unload Me
  300. End Sub
  301. Private Sub mnuFileExit_Click()
  302.  MDI 
  303.  MDI 
  304.  QueryUnload 
  305.  QueryUnload 
  306.  Cancel 
  307.  True  
  308.     Unload frmMDI
  309. End Sub
  310. Private Sub mnuFileNew_Click()
  311.     ' 
  312.     FileNew
  313. End Sub
  314. Private Sub mnuFontName_Click(index As Integer)
  315.     ' 
  316.  textbox 
  317.  fontname 
  318.     Text1.FontName = mnuFontName(index).Caption
  319. End Sub
  320. Private Sub mnuFileOpen_Click()
  321.     ' 
  322.     FileOpenProc
  323. End Sub
  324. Private Sub mnuFileSave_Click()
  325.     Dim strFilename As String
  326.     If Left(Me.Caption, 3) = "
  327. " Then
  328.         ' 
  329.         ' 
  330. GetFileName
  331.         strFilename = GetFileName(strFilename)
  332.     Else
  333.         ' 
  334.         strFilename = Me.Caption
  335.     End If
  336.     ' 
  337.     ' 
  338.  Filename = Empty
  339.     If strFilename <> "" Then
  340.         SaveFileAs strFilename
  341.     End If
  342. End Sub
  343. Private Sub mnuFileSaveAs_Click()
  344.     Dim strSaveFileName As String
  345.     Dim strDefaultName As String
  346.     ' 
  347.     strDefaultName = Me.Caption
  348.     If Left(Me.Caption, 3) = "
  349. " Then
  350.         ' 
  351.         ' 
  352. strSaveFileName
  353.         
  354.         strSaveFileName = GetFileName("
  355. .txt")
  356.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  357.         ' 
  358.         UpdateFileMenu (strSaveFileName)
  359.     Else
  360.         ' 
  361.         
  362.         strSaveFileName = GetFileName(strDefaultName)
  363.         If strSaveFileName <> "" Then SaveFileAs (strSaveFileName)
  364.         ' 
  365.         UpdateFileMenu (strSaveFileName)
  366.     End If
  367. End Sub
  368. Private Sub mnuOptions_Click()
  369.     ' 
  370.  Checked 
  371.  .Visible 
  372.     mnuOptionsToolbar.Checked = frmMDI.picToolbar.Visible
  373. End Sub
  374. Private Sub mnuOptionsToolbar_Click()
  375.     ' 
  376.     OptionsToolbarProc Me
  377. End Sub
  378. Private Sub mnuRecentFile_Click(index As Integer)
  379.     ' 
  380.     OpenFile (mnuRecentFile(index).Caption)
  381.     ' 
  382.     GetRecentFiles
  383. End Sub
  384. Private Sub mnuSearchFind_Click()
  385.     If Me.Text1.SelText <> "" Then
  386.         frmFind.Text1.Text = Me.Text1.SelText
  387.     Else
  388.         frmFind.Text1.Text = gFindString
  389.     End If
  390.     ' 
  391.     gFirstTime = True
  392.     ' 
  393.     If (gFindCase) Then
  394.         frmFind.chkCase = 1
  395.     End If
  396.     ' 
  397.     frmFind.Show vbModal
  398. End Sub
  399. Private Sub mnuSearchFindNext_Click()
  400.     ' 
  401.     If Len(gFindString) > 0 Then
  402.         FindIt
  403.     Else
  404.         mnuSearchFind_Click
  405.     End If
  406. End Sub
  407. Private Sub mnuWindowArrange_Click()
  408.     ' 
  409.     frmMDI.Arrange vbArrangeIcons
  410. End Sub
  411. Private Sub mnuWindowCascade_Click()
  412.     ' 
  413.     frmMDI.Arrange vbCascade
  414. End Sub
  415. Private Sub mnuWindowTile_Click()
  416.     ' 
  417.     frmMDI.Arrange vbTileHorizontal
  418. End Sub
  419. Private Sub Text1_Change()
  420.     ' 
  421.     FState(Me.Tag).Dirty = True
  422. End Sub
  423.