home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / zkuste / vbasic / Data / Utils / glm2demo.exe / %MAINDIR% / Taskbar / notepad.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  2002-06-10  |  13.5 KB  |  407 lines

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