Guidance
指路人
g.yi.org
software / rapidq / examples / gui / Edit & Richedit / editor / SimpleEdit / SimpleEdit.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
     $OPTIMIZE ON
     $TYPECHECK ON
     $INCLUDE "RAPIDQ.INC"

     Application.Icon =  "SimpleEdit.ico"
     Application.HintColor = 16776960


     TYPE QREdit EXTENDS QRICHEDIT
      RichFont AS QFONT
      CONSTRUCTOR
       PlainText = 1
       RichFont.Name = "Courier"
       Font = QREdit.RichFont
      END CONSTRUCTOR
     END TYPE

     DECLARE SUB New_Click
     DECLARE SUB Open_Click
     DECLARE SUB SaveAs_Click
     DECLARE SUB Save_Click
     DECLARE SUB Print_Click
     DECLARE SUB Cut_Click
     DECLARE SUB Copy_Click
     DECLARE SUB Paste_Click
     DECLARE SUB Delete_Click
     DECLARE SUB Undo_Click
     DECLARE SUB Font_Click
     DECLARE SUB Bold_Click
     DECLARE SUB Italic_Click
     DECLARE SUB Underline_Click
     DECLARE SUB WordWrap_Click
     DECLARE SUB SaveTxt
     DECLARE SUB Exit_Click
     DECLARE SUB SelectAll_Click
     DECLARE SUB Clear_Click
     DECLARE SUB Help_Click
     DECLARE SUB About_Load
     DECLARE SUB About_Click
     DECLARE SUB Statusbar_Update
     DECLARE SUB Form_Resize
     DECLARE SUB Change_Directories
     DECLARE SUB OpenFilelist_Click

     CONST IDCANCEL = 2 'Identification of the cancel button in Windows dialog boxes
     CONST EM_UNDO = &HC7 'value for the Win32 API function undo
     CONST HH_DISPLAY_TOPIC = &H0 'value used by HtmlHelp

     DIM tmpfile AS STRING
     tmpfile = "noname"
     DIM OpenDialog AS QOPENDIALOG
     DIM SaveDialog AS QSAVEDIALOG
     DIM FontDialog AS QFONTDIALOG
     DIM Font AS QFONT

     DECLARE FUNCTION HtmlHelp LIB "hhctrl.ocx" ALIAS "HtmlHelpA" (BYVAL hwndCaller AS LONG, _
      BYVAL pszFile AS STRING, BYVAL uCommand AS LONG, BYVAL dwData AS LONG) AS LONG 'HtmlHelp declaration

     CREATE frmSimpleEdit AS QFORM 'main form
      CAPTION = "SimpleEdit" & CHR$(32) & tmpfile
      Center
      COLOR = 12615680
      Height = 480
      Width = 635
      AutoScroll  = True
      BorderStyle = bsSizeable
      Cursor = crHandPoint
      FormStyle = fsNormal
      KeyPreview = True
      OnResize = Form_Resize
      ShowHint = False
      Visible = False
      WindowState = wsNormal
      CREATE popEdit AS QPOPUPMENU
       CREATE popUndo AS QMENUITEM
        CAPTION = "&Undo"
        Enabled = 1
        ShortCut = "Ctrl+Z"
        Onclick = Undo_Click
        Visible = 1
       END CREATE
       CREATE popBar0 AS QMENUITEM
        CAPTION = "-"
        Visible = True
       END CREATE
       CREATE popCut AS QMENUITEM
        CAPTION = "&Cut"
        Enabled = 1
        ShortCut = "Ctrl+X"
        OnClick = Cut_Click
        Visible = 1
       END CREATE
       CREATE popCopy AS QMENUITEM
        CAPTION = "C&opy"
        Enabled = 1
        ShortCut = "Ctrl+C"
        OnClick = Copy_Click
        Visible = 1
       END CREATE
       CREATE popPaste AS QMENUITEM
        CAPTION = "&Paste"
        Enabled = 1
        ShortCut = "Ctrl+P"
        OnClick = Paste_Click
        Visible = True
       END CREATE
       CREATE popBar1 AS QMENUITEM
        CAPTION = "-"
        Visible = True
       END CREATE
       CREATE popSelectAll AS QMENUITEM
        CAPTION = "&Select All"
        ENABLED = 1
        SHORTCUT = "Ctrl+A"
        VISIBLE = 1
        ONCLICK = SelectAll_Click
       END CREATE
       CREATE popDelete AS QMENUITEM
        CAPTION = "&Delete"
        ENABLED = 1
        SHORTCUT = "Del"
        VISIBLE = 1
        ONCLICK = Delete_Click
       END CREATE
       CREATE popClear AS QMENUITEM
        CAPTION = "&Clear"
        ENABLED = 1
        VISIBLE = 1
        ONCLICK = Clear_Click
       END CREATE
      END CREATE
      CREATE MNUMAIN AS QMAINMENU
       CREATE mnuFile AS QMENUITEM
        CAPTION = "&File"
        ENABLED = 1
        VISIBLE = 1
        CREATE mnuNew AS QMENUITEM
         CAPTION = "&New"
         ENABLED = 1
         SHORTCUT = "Ctrl+N"
         VISIBLE = 1
         OnClick = New_Click
        END CREATE
        CREATE mnuOpen AS QMENUITEM
         CAPTION = "&Open"
         ENABLED = 1
         SHORTCUT = "Ctrl+O"
         VISIBLE = 1
         OnClick = Open_Click
        END CREATE
        CREATE mnuSave AS QMENUITEM
         CAPTION = "&Save"
         ENABLED = 1
         SHORTCUT = "Ctrl+S"
         VISIBLE = 1
         OnClick = Save_Click
        END CREATE
        CREATE mnuSaveAs AS QMENUITEM
         CAPTION = "Save&As"
         ENABLED = 1
         VISIBLE = 1
         OnClick = SaveAs_Click
        END CREATE
        CREATE Bar0 AS QMENUITEM
         CAPTION = "-"
         ENABLED = 1
         VISIBLE = 1
        END CREATE
        CREATE mnuPrint AS QMENUITEM
         CAPTION = "&Print"
         ENABLED = 1
         SHORTCUT = "Ctrl+P"
         VISIBLE = 1
         OnClick = Print_Click
        END CREATE
        CREATE Bar1 AS QMENUITEM
         CAPTION = "-"
         ENABLED = 1
         VISIBLE = 1
        END CREATE
        CREATE mnuExit AS QMENUITEM
         CAPTION = "&Exit"
         ENABLED = 1
         SHORTCUT = "Alt+F4"
         VISIBLE = 1
         ONCLICK = Exit_Click
        END CREATE
       END CREATE
       CREATE mnuEdit AS QMENUITEM
        CAPTION = "&Edit"
        ENABLED = 1
        VISIBLE = 1
        CREATE mnuUndo AS QMENUITEM
         CAPTION = "&Undo"
         ENABLED = 1
         SHORTCUT = "Ctrl+Z"
         VISIBLE = 1
         ONCLICK = Undo_Click
        END CREATE
        CREATE Bar2 AS QMENUITEM
         CAPTION = "-"
         ENABLED = 1
         VISIBLE = 1
        END CREATE
        CREATE mnuCut AS QMENUITEM
         CAPTION = "&Cut"
         ENABLED = 1
         SHORTCUT = "Ctrl+X"
         VISIBLE = 1
         ONCLICK = Cut_Click
        END CREATE
        CREATE mnuCopy AS QMENUITEM
         CAPTION = "&Copy"
         ENABLED = 1
         SHORTCUT = "Ctrl+C"
         VISIBLE = 1
         ONCLICK = Copy_Click
        END CREATE
        CREATE mnuPaste AS QMENUITEM
         CAPTION = "&Paste"
         ENABLED = 1
         SHORTCUT = "Ctrl+V"
         VISIBLE = 1
         ONCLICK = Paste_Click
        END CREATE
        CREATE Bar3 AS QMENUITEM
         CAPTION = "-"
         ENABLED = 1
         VISIBLE = 1
        END CREATE
        CREATE mnuSelectAll AS QMENUITEM
         CAPTION = "&Select All"
         ENABLED = 1
         SHORTCUT = "Ctrl+A"
         VISIBLE = 1
         ONCLICK = SelectAll_Click
        END CREATE
        CREATE mnuDelete AS QMENUITEM
         CAPTION = "&Delete"
         ENABLED = 1
         SHORTCUT = "Del"
         VISIBLE = 1
         ONCLICK = Delete_Click
        END CREATE
        CREATE mnuClear AS QMENUITEM
         CAPTION = "&Clear"
         ENABLED = 1
         VISIBLE = 1
         ONCLICK = Clear_Click
        END CREATE
       END CREATE
       CREATE mnuFormat AS QMENUITEM
        CAPTION = "&Format"
        ENABLED = 1
        VISIBLE = 1
        CREATE mnuFont AS QMENUITEM
         CAPTION = "&Font"
         ENABLED = 1
         SHORTCUT = "F3"
         VISIBLE = 1
         ONCLICK = Font_Click
        END CREATE
        CREATE Bar4 AS QMENUITEM
         CAPTION = "-"
         ENABLED = 1
         VISIBLE = 1
        END CREATE
        CREATE mnuBold AS QMENUITEM
         CAPTION = "&Bold"
         ENABLED = 1
         SHORTCUT = "Ctrl+B"
         VISIBLE = 1
         ONCLICK = Bold_Click
        END CREATE
        CREATE mnuItalic AS QMENUITEM
         CAPTION = "&Italic"
         ENABLED = 1
         SHORTCUT = "Ctrl+I"
         VISIBLE = 1
         ONCLICK = Italic_Click
        END CREATE
        CREATE mnuUnderline AS QMENUITEM
         CAPTION = "&Underline"
         ENABLED = 1
         SHORTCUT = "Ctrl+U"
         VISIBLE = 1
         ONCLICK = Underline_Click
        END CREATE
        CREATE Bar5 AS QMENUITEM
         CAPTION = "-"
         ENABLED = 1
         VISIBLE = 1
        END CREATE
        CREATE mnuWordWrap AS QMENUITEM
         CAPTION = "&Word Wrap"
         Enabled = 1
         Visible = 1
         OnClick = WordWrap_Click
        END CREATE
       END CREATE
       CREATE mnuHelp AS QMENUITEM
        CAPTION = "&Help"
        ENABLED = 1
        VISIBLE = 1
        CREATE mnuContents AS QMENUITEM
         CAPTION = "&Contents"
         ENABLED = 1
         SHORTCUT = "F1"
         ONCLICK = Help_Click
         VISIBLE = 1
        END CREATE
        CREATE mnuAbout AS QMENUITEM
         CAPTION = "About"
         ENABLED = 1
         ONCLICK = About_Click
         VISIBLE = 1
        END CREATE
       END CREATE
      END CREATE
      CREATE EditBox AS QREDIT 'client area
       COLOR = 15461355
       Enabled = True
       Font.Name = "Times New Roman"
       Font.Size = 11
       Font.COLOR = 8388672
       Height = frmSimpleEdit.ClientHeight - 120
       Left = 170
       Modified = False
       OnKeyUp = Statusbar_Update
       PARENT = frmSimpleEdit
       PlainText = True
       PopupMenu = popEdit
       ScrollBars = ssBoth
       Top = 45
       Visible = True
       Width = frmSimpleEdit.ClientWidth - 30
       WordWrap = False
      END CREATE
      CREATE StatusBar AS QSTATUSBAR
       AddPanels "","","",""
       Align = alBottom 'align the statusbar at the bottom of the form
       Height = 25
       Panel(0).Width = 50
       Panel(1).Width = 300
       Panel(1).CAPTION = EditBox.Font.Name & CHR$(32) & STR$(EditBox.Font.Size)
       Panel(2).Width = 100
       Panel(2).CAPTION = DATE$
       Panel(3).CAPTION = TIME$
       Width = frmSimpleEdit.ClientWidth
       Visible = True
      END CREATE
      CREATE DirList AS QFILELISTBOX
       AddFileTypes(ftDirectory)
       DelFileTypes(ftNormal)
       Font.Name = "Arial"
       Font.Size = 10
       Font.COLOR = clRed
       Left = 0
       Mask = "*.*"
       OnDblClick = Change_Directories
       ShowIcons = True
       Top = 45
       Height = 200
       Width = 160
      END CREATE
      CREATE FileList AS QFILELISTBOX
       Left = 0
       Font.Name = "Arial"
       Font.Size = 10
       Font.COLOR = clBlue
       Top = 250
       Height = 150
       Width = 160
       Mask =  "*.txt;*.rtf;*.*"
       ShowIcons = True
       OnClick = OpenFilelist_Click
      END CREATE
      CREATE cmdNew AS QBUTTON 'control
       BMP = "New.bmp"
       Cancel = True
       Cursor = crHandPoint
       Default = True
       Enabled = True
       Height = 25
       HInt = "New"
       Layout = blBMPTop
       OnClick = New_Click
       Left = 14
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdOpen AS QBUTTON 'control
       BMP = "Open.bmp"
       Cancel = True
       Cursor = crHandPoint
       Font.COLOR = 16711808
       Height = 25
       HInt = "Open"
       Layout = blBMPTop
       Left = 39
       OnClick = Open_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdSave AS QBUTTON 'control
       BMP = "Save.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Save"
       Layout = blBMPTop
       Left = 64
       OnClick = Save_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdPrint AS QBUTTON 'control
       BMP = "Print.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Print"
       Layout = blBMPTop
       Left = 89
       OnClick = Print_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdCut AS QBUTTON 'control
       BMP = "Cut.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Cut"
       Layout = blBMPTop
       Left = 125
       OnClick = Cut_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdCopy AS QBUTTON 'control
       BMP = "Copy.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Copy"
       Layout = blBMPTop
       Left = 150
       OnClick = Copy_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdPaste AS QBUTTON 'control
       BMP = "Paste.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Paste"
       Layout = blBMPTop
       Left = 175
       OnClick = Paste_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdDelete AS QBUTTON 'control
       BMP = "Delete.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Delete"
       Layout = blBMPTop
       Left = 200
       OnClick = Delete_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdUndo AS QBUTTON 'control
       BMP = "Undo.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Undo"
       Layout = blBMPTop
       Left = 225
       OnClick = Undo_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdFont AS QBUTTON
       BMP = "Font.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "Font"
       Layout = blBMPTop
       Left = 260
       OnClick = Font_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdBold AS QCOOLBTN
       BMP = "Bold.bmp"
       Cursor = crHandPoint
       Enabled = True
       Flat = False
       Height = 25
       Hint = "Bold is off"
       Layout = blBMPTop
       Left = 285
       OnClick = Bold_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdItalic AS QCOOLBTN
       BMP = "Italics.bmp"
       Cursor = crHandPoint
       Enabled = True
       Flat = False
       Height = 25
       Hint = "Italic is off"
       Layout = blBMPTop
       Left = 310
       OnClick = Italic_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdUnderline AS QCOOLBTN
       BMP = "Underline.bmp"
       Cursor = crHandPoint
       Enabled = True
       Flat = False
       Height = 25
       Hint = "Underline is off"
       Layout = blBMPTop
       Left = 335
       OnClick = Underline_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdWordWrap AS QCOOLBTN
       BMP = "WordWrap.bmp"
       Cursor = crHandPoint
       Enabled = True
       Flat = False
       Height = 25
       Hint = "Word Wrap is off"
       Layout = blBMPTop
       Left = 360
       OnClick = WordWrap_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdAbout AS QBUTTON 'control
       BMP = "About.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "About"
       Layout = blBMPTop
       Left = 395
       OnClick = About_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdHelp AS QBUTTON
       BMP = "Help.bmp"
       Cancel = True
       Cursor = crHandPoint
       Enabled = True
       Height = 25
       Hint = "F1 Help"
       Layout = blBMPTop
       Left = 420
       OnClick = Help_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE cmdExit AS QBUTTON 'control
       BMP = "Exit.bmp"
       Cancel = True
       Enabled = True
       Height = 25
       Hint = "Exit"
       Layout = blBMPTop
       Left = 455
       OnClick = Exit_Click
       ShowHint = True
       Top = 10
       Visible = True
       Width = 25
      END CREATE
      CREATE frmAbout AS QFORM 'About dialog
       CAPTION = "About"
       Center
       COLOR = 13352477
       Height = 400
       Width = 400
       AutoScroll  = True
       BorderStyle = bsDialog
       Cursor = crDefault
       FormStyle = fsNormal
       KeyPreview = True
       OnShow = About_Load
       ShapeForm("AboutShape.bmp", &HFFFFFF)
       ShowHint = False
       Visible = False
       WindowState = wsNormal
      END CREATE
      CREATE cmdOk AS QBUTTON 'control
       Font.Name = "Arial"
       Font.Size = 9
       Font.COLOR = 12615680
       Height = 45
       Hint = "Ok"
       Kind = bkOk
       Layout = blBMPTop
       Left = 15
       ModalResult = mrOk
       PARENT = frmAbout
       ShowHint = True
       Top = 315
       Visible = True
       Width = 45
      END CREATE
      CREATE lblSimple AS QLABEL 'label
       Alignment = taCenter
       AutoSize = True
       CAPTION = "SimpleEdit"
       Cursor = crHandPoint
       Enabled = True
       Font.Name = "Arial"
       Font.Size = 36
       Font.COLOR  = 12632256
       Height  = 50
       LabelStyle  = lsRaised
       LayOut  = tlCenter
       Left  = frmAbout.ClientWidth - 320
       LowerColor  = 8388672
       PARENT  = frmAbout
       Top  = 5
       Transparent  = True
       UpperColor  = 15921906
       Visible  = True
       Width  = frmAbout.ClientWidth
       WordWrap  = True
      END CREATE
      CREATE AboutRich AS QRICHEDIT 'client area of frmAbout
       COLOR = 15461355
       Enabled = True
       Font.Name = "Times New Roman"
       Font.Size = 11
       Font.COLOR = 16711680
       Height = frmAbout.ClientHeight - 125
       Left = 15
       PARENT = frmAbout
       PlainText = True
       ScrollBars = ssBoth
       Top = 65
       Visible = True
       Width = frmAbout.ClientWidth - 30
      END CREATE
     END CREATE

     frmSimpleEdit.SHOWMODAL

     SUB New_Click 'create a new document
      EditBox.Text = "" 'clear the client area of frmAbout
      tmpfile = "noname" 'set filename
      frmSimpleEdit.CAPTION = ""
      frmSimpleEdit.CAPTION = "SimpleEdit" & CHR$(32) & tmpfile 'set program captio
     END SUB

     SUB Open_Click
      OpenDialog.Filter = "Text Files (*.txt)|*.txt|SimpleEdit Files(*.rtf)|*.rtf|All Files (*.*)|*.*" 'file filter
      IF OpenDialog.EXECUTE = IDCANCEL THEN 'if user presses cancel button
       EXIT SUB
      ELSE
       tmpfile = OpenDialog.FileName 'user selects a file to open
       EditBox.LoadFromFile(tmpfile) 'load file contents to the client area of SimpleEdit
       frmSimpleEdit.CAPTION = ""
       frmSimpleEdit.CAPTION = "SimpleEdit" & CHR$(32) & tmpfile 'set program caption
      END IF
      EditBox.Modified = False
     END SUB

     SUB SaveAs_Click
      SaveDialog.Filter = "Text Files (*.txt)|*.txt|SimpleEdit Files(*.rtf)|*.rtf|All Files (*.*)|*.*" 'file filter
      IF SaveDialog.EXECUTE = IDCANCEL THEN 'if user presses cancel button
       EXIT SUB
      ELSE
       tmpfile = SaveDialog.FileName 'user selects a filename to save under
       IF RIGHT$(tmpfile,3) = "txt" THEN SaveTxt 'test to see if the file is being saved as a text file
      ELSE
       EditBox.PlainText = False
       EditBox.SaveToFile(tmpfile) 'save The contents of the client area of SimpleEdit to file
       frmSimpleEdit.CAPTION = ""
       frmSimpleEdit.CAPTION = "SimpleEdit" & CHR$(32) & tmpfile 'set program caption
      END IF
      EditBox.Modified = False
     END SUB

     SUB Save_Click
      IF tmpfile = "noname" THEN 'if file is unsaved call the SaveAs subroutine
       SaveAs_Click
      ELSE
       IF RIGHT$(tmpfile,3) = "txt" THEN SaveTxt 'test to see if the file is being saved as a text file
      ELSE
       EditBox.PlainText = False
       EditBox.SaveToFile(tmpfile) 'save The contents of the client area of SimpleEdit to file
      END IF
      EditBox.Modified = False
     END SUB

     SUB SaveTxt
      EditBox.PlainText = True
      EditBox.SaveToFile(tmpfile)
      EditBox.Modified = False
     END SUB

     SUB  Print_Click
      Printer.Font.Name = EditBox.Font.Name 'set the printer font name
      Printer.Font.Size = EditBox.Font.Size 'set the printer font size
      Printer.Font.COLOR = EditBox.Font.COLOR 'set the printer font color
      Printer.BeginDoc
      Printer.TextOut(10,10,EditBox.Text, 0, -0) 'print the client area of SimpleEdit
      Printer.EndDoc 'printing will not start without this command
     END SUB

     SUB Cut_Click
      EditBox.CutToClipboard 'cut selected text to clipboard
     END SUB

     SUB Copy_Click 'copy selected text to clipboard
      EditBox.CopyToClipboard
     END SUB

     SUB Paste_Click
      EditBox.PasteFromClipboard 'paste clipboard's contents into the client area of SimpleEdit
     END SUB

     SUB SelectAll_Click
      Editbox.SelectAll
     END SUB

     SUB Delete_Click 'Delete selected text in client area of SimpleEdit
      EditBox.SelText = "" 'erases selected text
     END SUB

     SUB Clear_Click
      IF MESSAGEDLG("Warning! this will cause irrevocable data loss, continue?", mtWarning, mbyes OR mbNo,0) = mrYes THEN
       EditBox.Clear
       EditBox.Modified = True
      ELSE
       EXIT SUB
      END IF
     END SUB

     SUB Undo_Click
      SendMessage EditBox.Handle,EM_UNDO, 0, 0 'invoke the undo function
     END SUB

     SUB Font_Click
      IF FontDialog.EXECUTE = IDCANCEL THEN 'user presses the cancel button
       EXIT SUB
      ELSE
       EditBox.Font.Name = FontDialog.Name 'set the client area font
       EditBox.Font.Size = FontDialog.Size 'set the client area font size
       EditBox.Font.COLOR = FontDialog.COLOR 'set the client area font color
      END IF
      Statusbar.Panel(1).CAPTION = EditBox.Font.Name & CHR$(32) & STR$(EditBox.Font.Size)
     END SUB

     SUB Bold_Click
      IF cmdBold.Flat = False THEN
       Font.Name = EditBox.Font.Name
       Font.Size = EditBox.Font.size
       Font.COLOR = EditBox.Font.COLOR
       Font.AddStyles(fsBold)
       EditBox.SelAttributes = Font
       cmdBold.Flat = True
       mnuBold.Checked = True
       cmdBold.Hint = "Bold is on"
      ELSEIF cmdBold.Flat = True THEN
       Font.Name = EditBox.Font.Name
       Font.Size = EditBox.Font.size
       Font.COLOR = EditBox.Font.COLOR
       Font.DelStyles(fsBold)
       EditBox.SelAttributes = Font
       cmdBold.Flat = False
       mnuBold.Checked = False
       cmdBold.Hint = "Bold is off"
      END IF
     END SUB

     SUB Italic_Click
      IF cmdItalic.Flat = False THEN
       Font.Name = EditBox.Font.Name
       Font.Size = EditBox.Font.size
       Font.COLOR = EditBox.Font.COLOR
       Font.AddStyles(fsItalic)
       EditBox.SelAttributes = Font
       cmdItalic.Flat = True
       mnuItalic.Checked = True
       cmdItalic.Hint = "Italic is on"
      ELSEIF cmdItalic.Flat = True THEN
       Font.Name = EditBox.Font.Name
       Font.Size = EditBox.Font.size
       Font.COLOR = EditBox.Font.COLOR
       Font.DelStyles(fsItalic)
       EditBox.SelAttributes = Font
       cmdItalic.Flat = False
       mnuItalic.Checked = False
       cmdItalic.Hint = "Italic is off"
      END IF
     END SUB

     SUB Underline_Click
      IF cmdUnderline.Flat = False THEN
       Font.Name = EditBox.Font.Name
       Font.Size = EditBox.Font.size
       Font.COLOR = EditBox.Font.COLOR
       Font.AddStyles(fsUnderline)
       EditBox.SelAttributes = Font
       cmdUnderline.Flat = True
       mnuUnderline.Checked = True
       cmdUnderline.Hint = "Underline is on"
      ELSEIF cmdUnderline.Flat = True THEN
       Font.Name = EditBox.Font.Name
       Font.Size = EditBox.Font.size
       Font.COLOR = EditBox.Font.COLOR
       Font.DelStyles(fsUnderline)
       EditBox.SelAttributes = Font
       cmdUnderline.Flat = False
       mnuUnderline.Checked = False
       cmdUnderline.Hint = "Underline is Off"
      END IF
     END SUB

     SUB WordWrap_Click
      IF cmdWordWrap.Flat = False THEN
       EditBox.WordWrap = True
       cmdWordWrap.Flat = True
       mnuWordWrap.Checked = True
       cmdWordWrap.Hint = "Word Wrap is on"
      ELSEIF cmdWordWrap.Flat = True THEN
       EditBox.WordWrap = False
       cmdWordWrap.Flat = False
       mnuWordWrap.Checked = False
       cmdWordWrap.Hint = "Word Wrap is off"
      END IF
     END SUB

     SUB Help_Click
      HtmlHelp(frmSimpleEdit.handle, "SimpleEdit.chm", HH_DISPLAY_TOPIC, 0) 'display the help file
     END SUB


     SUB Exit_Click
      IF EditBox.Modified = True THEN 'check to see if the client areas' data has changed
       IF MESSAGEDLG(tmpfile & CHR$(32) & " Data has changed, save changes?", mtWarning, mbYes OR mbNo,0) = mrYes THEN
        Save_Click
        frmSimpleEdit.CLOSE
       END IF
      END IF
      frmSimpleEdit.CLOSE
     END SUB

     SUB About_Click
      PLAYWAV  "C:\WINDOWS\MEDIA\TADA.WAV", 1 'make noise
      frmAbout.SHOWMODAL 'show about dialog
     END SUB

     SUB About_Load
      AboutRich."LoadFromFileSimpleEdit.txt" 'loads text file into the client area of frmAbout
     END SUB

     SUB Statusbar_Update
      StatusBar.Panel(0).CAPTION = STR$(EditBox.WhereY+1)+":"+STR$(EditBox.WhereX+1)
     END SUB

     SUB Form_Resize
      EditBox.Width = frmSimpleEdit.ClientWidth - 170 'resize the client area to the form's clientwidth
      EditBox.Height = frmSimpleEdit.ClientHeight - 72 'resize the client area to the form's clientheight
     END SUB

     SUB Change_Directories
      CHDIR(DirList.Item(DirList.ItemIndex) - "[" - "]")
      DirList.Directory = CURDIR$:  FileList.Directory = CURDIR$
     END SUB

     SUB OpenFilelist_Click
      tmpfile = FileList.FileName
      EditBox.LoadFromFile(tmpfile)
      EditBox.Modified = False
      frmSimpleEdit.CAPTION = ""
      frmSimpleEdit.CAPTION = tmpfile & CHR$(32) & "Simple Edit"
     END SUB
掌柜推荐
 
 
¥370.00 ·
 
 
¥264.00 ·
 
 
¥648.00 ·
 
 
¥380.00 ·
 
 
¥289.00 ·
 
 
¥1,068.00 ·
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-04-10 01:01:46