home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0210 - 0219 / ibm0210-0219 / ibm0213.tar / ibm0213 / PWA_AWAR.ZIP / SAMPVB.Z / FPNOTES.BAS < prev    next >
Encoding:
BASIC Source File  |  1994-07-05  |  7.9 KB  |  323 lines

  1. VERSION 2.00
  2. Begin Form MainForm 
  3.    Caption         =   "fpMemo"
  4.    ClientHeight    =   4815
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1500
  7.    ClientWidth     =   7365
  8.    Height          =   5505
  9.    Icon            =   FPNOTES.FRX:0000
  10.    Left            =   1080
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3.344
  13.    ScaleMode       =   5  'Inch
  14.    ScaleWidth      =   5.115
  15.    Top             =   870
  16.    Width           =   7485
  17.    Begin AwareMemo fpMemo 
  18.       BorderStyle     =   0  'No Border
  19.       FontBold        =   -1  'True
  20.       FontItalic      =   0   'False
  21.       FontName        =   "Courier New"
  22.       FontSize        =   8.25
  23.       FontStrikethru  =   0   'False
  24.       FontUnderline   =   0   'False
  25.       Height          =   3015
  26.       Left            =   120
  27.       LineLimit       =   2147483647
  28.       OnFocusPosition =   3  'Caret
  29.       ScrollBars      =   3  'Both (auto)
  30.       TabIndex        =   0
  31.       ThreeDOutsideHighlightColor=   &H00FFFFFF&
  32.       Top             =   120
  33.       Width           =   3015
  34.    End
  35.    Begin CommonDialog CMDialog1 
  36.       Left            =   1200
  37.       Top             =   3660
  38.    End
  39.    Begin Menu MainMenu 
  40.       Caption         =   "&File"
  41.       Index           =   1
  42.       Begin Menu FileMenu 
  43.          Caption         =   "&New"
  44.          Index           =   1
  45.       End
  46.       Begin Menu FileMenu 
  47.          Caption         =   "&Open"
  48.          Index           =   2
  49.       End
  50.       Begin Menu FileMenu 
  51.          Caption         =   "&Save"
  52.          Index           =   3
  53.       End
  54.       Begin Menu FileMenu 
  55.          Caption         =   "Save&As"
  56.          Index           =   4
  57.       End
  58.       Begin Menu FileMenu 
  59.          Caption         =   "&Print"
  60.          Index           =   5
  61.       End
  62.       Begin Menu FileMenu 
  63.          Caption         =   "E&xit"
  64.          Index           =   6
  65.       End
  66.    End
  67.    Begin Menu MainMenu 
  68.       Caption         =   "&Edit"
  69.       Index           =   2
  70.       Begin Menu EditMenu 
  71.          Caption         =   "&Undo"
  72.          Enabled         =   0   'False
  73.          Index           =   1
  74.       End
  75.       Begin Menu EditMenu 
  76.          Caption         =   "-"
  77.          Index           =   2
  78.       End
  79.       Begin Menu EditMenu 
  80.          Caption         =   "&Copy"
  81.          Index           =   3
  82.       End
  83.       Begin Menu EditMenu 
  84.          Caption         =   "Cu&t"
  85.          Index           =   4
  86.       End
  87.       Begin Menu EditMenu 
  88.          Caption         =   "&Paste"
  89.          Index           =   5
  90.       End
  91.       Begin Menu EditMenu 
  92.          Caption         =   "&Delete"
  93.          Index           =   6
  94.       End
  95.    End
  96.    Begin Menu MainMenu 
  97.       Caption         =   "&Options"
  98.       Index           =   3
  99.       Begin Menu OptionMenu 
  100.          Caption         =   "E&xtend Selection"
  101.          Index           =   1
  102.       End
  103.       Begin Menu OptionMenu 
  104.          Caption         =   "Show&EOL"
  105.          Index           =   2
  106.       End
  107.       Begin Menu OptionMenu 
  108.          Caption         =   "&WordWrap"
  109.          Index           =   3
  110.       End
  111.    End
  112. End
  113.  
  114. Sub EditMenu_Click (index As Integer)
  115.     Select Case (index)
  116.        Case 1: 'Undo
  117.        Case 3: fpmemo.Action = 0 'Copy
  118.        Case 4: fpmemo.Action = 1 'Cut
  119.        Case 5: fpmemo.Action = 2 'Paste
  120.        Case 6: fpmemo.Action = 3 'Clear (Delete)
  121.     End Select
  122. End Sub
  123.  
  124. Sub FileMenu_Click (index As Integer)
  125.     Dim SaveIt As Integer
  126.     
  127.     SaveIt = False
  128.     If (gMemoChanged And index <> 3) Then
  129.         SaveIt = MsgBox("Save changes?", MB_YESNOCANCEL)
  130.     End If
  131.     
  132.     If (SaveIt = IDCANCEL) Then
  133.        index = 0
  134.     End If
  135.  
  136.     If (SaveIt = IDYES) Then
  137.        ' save changes
  138.     End If
  139.  
  140.     Select Case (index)
  141.        Case 1: ' New
  142.          fpmemo.Text = ""
  143.          gMemoChanged = False
  144.          gfilename = ""
  145.          mainform.Caption = "<noname>"
  146.        Case 2: ' Open
  147.          OpenFile
  148.          gMemoChanged = False
  149.        Case 3: ' Save
  150.          SaveFile
  151.          gMemoChanged = False
  152.        Case 4: ' SaveAs
  153.          SaveFileAs
  154.          gMemoChanged = False
  155.        Case 5:
  156.          PrintFile
  157.        Case 6: ' Exit
  158.           Unload mainform
  159.     End Select
  160.  
  161. End Sub
  162.  
  163. Sub Form_Load ()
  164.     
  165.     fpmemo.Visible = False
  166.     
  167.     ' initialize global variables
  168.     '
  169.     gMemoChanged = False
  170.     gfilename = ""
  171.  
  172. End Sub
  173.  
  174. Sub Form_Resize ()
  175.     fpmemo.Visible = False
  176.     fpmemo.Redraw = False
  177.     fpmemo.Left = 0
  178.     fpmemo.Top = 0
  179.     fpmemo.Width = mainform.ScaleWidth
  180.     fpmemo.Height = mainform.ScaleHeight
  181.     fpmemo.Redraw = True
  182.     fpmemo.Visible = True
  183. End Sub
  184.  
  185. Sub fpMemo_Change ()
  186.     gMemoChanged = True
  187. End Sub
  188.  
  189. Sub MainMenu_Click (index As Integer)
  190.     Dim IsSelected As Integer
  191.     If (index = 1) Then
  192.        filemenu(3).Enabled = gMemoChanged
  193.        filemenu(4).Enabled = gMemoChanged Or (gfilename <> "")
  194.     End If
  195.     If (index = 2) Then
  196.        IsSelected = (fpmemo.SelLength > 0)
  197.        editmenu(3).Enabled = IsSelected
  198.        editmenu(4).Enabled = IsSelected
  199.        editmenu(5).Enabled = (clipboard.GetText() <> "")
  200.        editmenu(6).Enabled = IsSelected
  201.     End If
  202. End Sub
  203.  
  204. Sub OpenFile ()
  205.     Dim fname As String
  206.  
  207.     cmdialog1.Filter = "*.txt(Text Files)"
  208.     cmdialog1.FilterIndex = 0
  209.     cmdialog1.DefaultExt = ".txt"
  210.     If (gfilename <> "") Then
  211.        cmdialog1.Filename = gfilename
  212.     Else
  213.        cmdialog1.Filename = "*.txt"
  214.     End If
  215.     cmdialog1.Flags = &H1000&            'file must exist
  216.     cmdialog1.DialogTitle = "Load File"
  217.  
  218.     cmdialog1.CancelError = True
  219.     
  220.     On Error Resume Next
  221.     
  222.     cmdialog1.Action = 1
  223.     fname = cmdialog1.Filename
  224.  
  225.     Call LoadFile(fpmemo, fname)
  226.     gfilename = fname
  227.     mainform.Caption = gfilename
  228.  
  229. End Sub
  230.  
  231. Sub OptionMenu_Click (index As Integer)
  232.    Select Case index
  233.        Case 1: ' Extended Selection
  234.           If (fpmemo.SelMode = 0) Then
  235.              fpmemo.SelMode = 1
  236.              optionmenu(1).Checked = True
  237.           Else
  238.              fpmemo.SelMode = 0
  239.              optionmenu(1).Checked = False
  240.           End If
  241.        Case 2:
  242.           If (fpmemo.ShowEOL = True) Then
  243.              fpmemo.ShowEOL = False
  244.              optionmenu(2).Checked = False
  245.           Else
  246.              fpmemo.ShowEOL = True
  247.              optionmenu(2).Checked = True
  248.           End If
  249.        Case 3:
  250.           If (fpmemo.WordWrap = True) Then
  251.              fpmemo.WordWrap = False
  252.              optionmenu(3).Checked = False
  253.           Else
  254.              fpmemo.WordWrap = True
  255.              optionmenu(3).Checked = True
  256.           End If
  257.    End Select
  258. End Sub
  259.  
  260. Sub PrintFile ()
  261. ' Print file using "line mode" to retrieve one line
  262. ' at a time using the Text property (and write it
  263. ' to the printer)
  264. '
  265.  
  266.    fpmemo.TextMode = 3
  267.    Load PrintDialog
  268.    PrintDialog.Show modeless
  269.    On Error GoTo printerror
  270.    For i = 0 To fpmemo.LineCount
  271.       fpmemo.LineIndex = i
  272.       printer.Print fpmemo.Text
  273.    Next i
  274.    printer.NewPage
  275.    printer.EndDoc
  276.    
  277. printquit:
  278.    Unload PrintDialog
  279.    Exit Sub
  280.  
  281. printerror:
  282.    Resume printquit
  283.  
  284. End Sub
  285.  
  286. Sub SaveFile ()
  287.     
  288.     Dim fname As String
  289.  
  290.     If (gfilename = "") Then
  291.        cmdialog1.DefaultExt = ".txt"
  292.        cmdialog1.Flags = &H800&
  293.        cmdialog1.DialogTitle = "Save File"
  294.        cmdialog1.Action = 2
  295.     End If
  296.  
  297.     If (cmdialog1.Filename <> "") Then
  298.        gfilename = cmdialog1.Filename
  299.        mainform.Caption = gfilename
  300.        Call WriteFile(fpmemo, gfilename)
  301.     End If
  302.  
  303. End Sub
  304.  
  305. Sub SaveFileAs ()
  306.     
  307.     Dim fname As String
  308.  
  309.     cmdialog1.DefaultExt = ".txt"
  310.     cmdialog1.Flags = &H800&
  311.     cmdialog1.DialogTitle = "Save File As"
  312.     
  313.     cmdialog1.Action = 2
  314.     
  315.     If (cmdialog1.Filename <> "") Then
  316.        gfilename = cmdialog1.Filename
  317.        mainform.Caption = gfilename
  318.        Call WriteFile(fpmemo, gfilename)
  319.     End If
  320.  
  321. End Sub
  322.  
  323.