DECLARE SUB SetWindowPos LIB "User32" ALIAS "SetWindowPos"(hWnd AS LONG, hWndInsertAfter AS LONG, X AS LONG, Y AS LONG, cx AS LONG, cy AS LONG, wFlags AS LONG)
DECLARE FUNCTION SetFocus LIB "USER32" ALIAS "SetFocus" (HWnd AS LONG) AS LONG
DECLARE FUNCTION SetWindowLong LIB "user32" ALIAS "SetWindowLongA" (hwnd AS LONG, nIndex AS LONG, dwNewLong AS LONG) AS LONG
DECLARE SUB Splash
DECLARE SUB Process(Sender AS QMENUITEM)
DECLARE SUB Find(Sender AS QBUTTON)
DECLARE SUB Exits(Sender AS QMENUITEM)
DECLARE SUB CheckSave(key AS BYTE, shift AS INTEGER)
DECLARE SUB Saving
DECLARE SUB PrintClick
DECLARE SUB CloseFind
DECLARE SUB Changed
DECLARE SUB PasteClipboard
DECLARE SUB FormEShow
DECLARE SUB PrintDlgShow
DECLARE SUB ComboBoxChange(Sender AS QCOMBOBOX)
DEFBYTE sresult, saved
DEFSTR filename, oldtext, newtext, previous
DEFINT beginT
DIM ESave AS QSAVEDIALOG
DIM Font AS QFONT
DIM Fonts AS QFONTDIALOG
DIM OpenDialog AS QOPENDIALOG
DIM File AS QFILESTREAM
CREATE Arial12 AS QFONT
Name = "Arial"
Size = 12
END CREATE
CREATE Arial11 AS QFONT
Name = "Arial"
Size = 11
END CREATE
CREATE Timer1 AS QTIMER
Interval = 1000
OnTimer = PasteClipboard
END CREATE
CREATE SplashTimer AS QTIMER
Interval = 1000
OnTimer = Splash
END CREATE
CREATE SplashForm AS QFORM
Height = 213
Width = 213
Center
BorderStyle = 0
CREATE SplashLabel AS QLABEL
COLOR = &HEE00CC
Align = 5
Alignment = 3
Layout = 1
Font = Arial12
CAPTION = CHR$(13) + CHR$(13) + "YetNaderEd" + _
CHR$(13) + CHR$(13) + "Yet another text editor," + _
CHR$(13) + "but without all that" + _
CHR$(13) + "intrusive formatting." + _
CHR$(13) + CHR$(13) + "And it's FREE!"
END CREATE
CREATE FormE AS QFORM
CAPTION = "YetNaderEd"
Center
Width = 415
Height = 205
Visible = 0
AutoScroll = 0
KeyPreview = 1
OnShow = FormEShow
OnKeyDown = CheckSave
OnClose = Exits
CREATE StatusBar AS QSTATUSBAR
AddPanels "","","","",""
Panel(0).Width = 50
Panel(1).Width = 70
Panel(2).Width = 63
Panel(2).CAPTION = DATE$
Panel(3).Width = 69
END CREATE
CREATE Main AS QMAINMENU
CREATE MFile AS QMENUITEM
CAPTION = "&File"
CREATE iNew AS QMENUITEM
CAPTION = "&New"
OnClick = Process
END CREATE
CREATE iOpen AS QMENUITEM
CAPTION = "&Open"
OnClick = Process
END CREATE
CREATE iSave AS QMENUITEM
CAPTION = "&Save"
OnClick = Process
END CREATE
CREATE iSaveAs AS QMENUITEM
CAPTION = "Save &As"
OnClick = Process
END CREATE
CREATE iClose AS QMENUITEM
CAPTION = "&Close"
OnClick = Exits
END CREATE
CREATE iLine1 AS QMENUITEM
CAPTION = "-"
END CREATE
CREATE iPrint AS QMENUITEM
CAPTION = "&Print"
OnClick = Process
END CREATE
CREATE iPrintPreview AS QMENUITEM
CAPTION = "Print Pre&view"
OnClick = Process
END CREATE
CREATE iLine2 AS QMENUITEM
CAPTION = "-"
END CREATE
CREATE iExit AS QMENUITEM
CAPTION = "&Exit"
OnClick = Exits
END CREATE
END CREATE
CREATE MEdit AS QMENUITEM
CAPTION = "&Edit"
CREATE iSelect AS QMENUITEM
CAPTION = "&Select All"
OnClick = Process
END CREATE
CREATE iLine3 AS QMENUITEM
CAPTION = "-"
END CREATE
CREATE iClear AS QMENUITEM
CAPTION = "Cl&ear All"
OnClick = Process
END CREATE
CREATE iLine4 AS QMENUITEM
CAPTION = "-"
END CREATE
CREATE iCopy AS QMENUITEM
CAPTION = "&Copy"
OnClick = Process
END CREATE
CREATE iPaste AS QMENUITEM
CAPTION = "&Paste"
OnClick = Process
END CREATE
CREATE iCut AS QMENUITEM
CAPTION = "Cu&t"
OnClick = Process
END CREATE
END CREATE
CREATE MUndo AS QMENUITEM
CAPTION = "&Undo"
CREATE iUndo AS QMENUITEM
CAPTION = "&Undo"
OnClick = Process
END CREATE
CREATE iRedo AS QMENUITEM
CAPTION = "&Redo"
OnClick = Process
END CREATE
END CREATE
CREATE MFormat AS QMENUITEM
CAPTION = "For&mat"
CREATE iFormat AS QMENUITEM
CAPTION = "&Font"
OnClick = Process
END CREATE
CREATE iRegular AS QMENUITEM
CAPTION = "&Regular"
OnClick = Process
END CREATE
CREATE iItalic AS QMENUITEM
CAPTION = "&Italic"
OnClick = Process
END CREATE
CREATE iBold AS QMENUITEM
CAPTION = "&Bold"
OnClick = Process
END CREATE
CREATE iUnderline AS QMENUITEM
CAPTION = "&Underline"
OnClick = Process
END CREATE
CREATE iUpper AS QMENUITEM
CAPTION = "Upper&case"
OnClick = Process
END CREATE
CREATE iLower AS QMENUITEM
CAPTION = "&Lowercase"
OnClick = Process
END CREATE
CREATE iUpLow AS QMENUITEM
CAPTION = "U&pperLower"
OnClick = Process
END CREATE
END CREATE
CREATE MFind AS QMENUITEM
CAPTION = "&Search"
CREATE iFind AS QMENUITEM
CAPTION = "&Find/Replace"
OnClick = Process
END CREATE
CREATE iCount AS QMENUITEM
CAPTION = "&Word Count"
OnClick = Process
END CREATE
END CREATE
CREATE MOptions AS QMENUITEM
CAPTION = "&Options"
CREATE iSaveAuto AS QMENUITEM
CAPTION = "&Autosave"
Checked = 1
OnClick = Process
END CREATE
CREATE iSaveBack AS QMENUITEM
CAPTION = "&Backup"
Checked = 1
OnClick = Process
END CREATE
CREATE iCapture AS QMENUITEM
CAPTION = "&Capture"
Checked = 0
OnClick = Process
END CREATE
CREATE iTop AS QMENUITEM
CAPTION = "&Topmost"
Checked = 0
OnClick = Process
END CREATE
END CREATE
CREATE MAbout AS QMENUITEM
CAPTION = "&About"
OnClick = Process
END CREATE
END CREATE
CREATE Rich AS QRICHEDIT
Align = 5
ScrollBars = 2
HideSelection = 0
WantTabs = 1
SelAttributes.Name = "Arial"
SelAttributes.Size = 11
OnChange = Changed
END CREATE
CREATE PrintDlg AS QFORM
CAPTION = "Print Dialog"
BorderStyle = 3
Height = 375
Width = 225
FormStyle = 3
Visible = 0
Center
CREATE ComboBox AS QCOMBOBOX
Left = 5
Top = 6
Width = 210
OnChange = ComboBoxChange
END CREATE
CREATE PrintBox AS QGROUPBOX
CAPTION = "Print Preview"
Top = 35
Left = 5
Width = 210
Height = 210
END CREATE
CREATE PagesBox AS QGROUPBOX
CAPTION = "Pages"
Top = 280
Left = 80
Width = 135
Height = 30
END CREATE
CREATE PagesFrom AS QEDIT
Top = 287
Left = 125
Width = 25
Height = 20
Autosize = 0
END CREATE
CREATE PagesPanel AS QPANEL
Top = 287
Left = 150
Width = 30
Height = 20
BevelWidth = 0
CAPTION = "To:"
END CREATE
CREATE PagesTo AS QEDIT
Top = 287
Left = 180
Width = 25
Height = 20
Autosize = 0
END CREATE
CREATE CopiesBox AS QGROUPBOX
CAPTION = "Copies"
Top = 280
Left = 5
Width = 75
Height = 30
END CREATE
CREATE PagesCopy AS QEDIT
Top = 288
Left = 52
Width = 25
Height = 20
Autosize = 0
END CREATE
CREATE OrientationBox AS QGROUPBOX
CAPTION = "Orientation"
Top = 247
Left = 5
Width = 210
Height = 30
END CREATE
CREATE Portrait AS QRADIOBUTTON
CAPTION = "Portrait"
Left = 65
Top = 258
Width = 50
Checked = 1
END CREATE
CREATE Landscape AS QRADIOBUTTON
CAPTION = "Landscape"
Left = 120
Top = 258
Width = 70
END CREATE
CREATE PreviewBox AS QRICHEDIT
Top = 55
Left = 31
Width = PrintDlg.ClientWidth - 60
Height = 180
ReadOnly = 1
ScrollBars = 3
Font.Name = "Arial"
Font.Size = 3
END CREATE
CREATE Button AS QBUTTON
CAPTION = "&Print"
Top = 317
Left = 31
Width = PrintDlg.ClientWidth - 60
Default = 1
OnClick = PrintClick
END CREATE
END CREATE
CREATE FindDlg AS QFORM
Height = 150
CAPTION = "Find Dialog"
BorderStyle = 3
FormStyle = 3
Center
OnClose = CloseFind
CREATE FindText AS QEDIT
Top = 10
Left = 15
Width = 170
Height = 45
Tag = 1
END CREATE
CREATE FindLabel AS QLABEL
Top = 35
Left = 18
Width = 50
CAPTION = "Find what word/s?"
END CREATE
CREATE FindButt AS QBUTTON
Top = 10
Left = 187
Height = 22
Width = 111
CAPTION = "Find"
Default = 1
OnClick = Find
END CREATE
CREATE Panel AS QPANEL
Top = 60
Left = 15
Width = 283
Height = 3
END CREATE
CREATE ReplaceText AS QEDIT
Top = 75
Left = 15
Width = 170
Height = 45
END CREATE
CREATE ReplaceLabel AS QLABEL
Top = 100
Left = 18
Width = 50
CAPTION = "Replace with what?"
END CREATE
CREATE ReplaceButt AS QBUTTON
Top = 75
Left = 187
Height = 22
Width = 55
CAPTION = "This"
Default = 1
Enabled = 0
OnClick = Find
END CREATE
CREATE ReplaceAButt AS QBUTTON
Top = 75
Left = 243
Height = 22
Width = 55
CAPTION = "All"
Default = 1
OnClick = Find
END CREATE
CREATE WholeW AS QCHECKBOX
CAPTION = "Whole word"
Left = 135
Top = 35
Checked = 1
END CREATE
CREATE Match AS QCHECKBOX
CAPTION = "Match case"
Left = 223
Top = 35
Width = 80
END CREATE
CREATE Replaced AS QLABEL
Top = 100
Left = 215
Width = 50
CAPTION = "0 replaced"
END CREATE
END CREATE
END CREATE
END CREATE
SUB Process(Sender)
Rich.Visible = 1
SELECT CASE Sender.Handle
CASE iNew.Handle
IF saved = 0 THEN
ESave.CAPTION = "Save As"
ESave.Filename = filename
Saving
END IF
filename = ""
ESave.Filename = "
Rich.Clear
Rich.SelAttributes.Name = ""Arial
Rich.SelAttributes.Size = 11
StatusBar.Panel(4).Caption = ""
SetFocus(Rich.Handle)
CASE iOpen.Handle
CREATE Load AS QOPENDIALOG
Caption = "Load "File
Filter = "All files|*.*|Rich Text Format|*.rtf|Word|*.doc|Plain text|*."txt
END CREATE
Timer1.Enabled = 0
IF Load.Execute THEN
Rich.Clear
Rich.LoadFromFile(Load.FileName)
filename = Load.FileName
IF RIGHT$(fileName,4) = "."txt THEN
Rich.SelectAll
Rich.SelAttributes.Italic = 0
Rich.SelAttributes.Bold = 0
Rich.SelAttributes.Underline = 0
Rich.Plaintext = 1
END IF
saved = 1
END IF
Timer1.Enabled = 1
StatusBar.Panel(4).Caption = filename
CASE iSave.Handle
IF saved = 0 AND filename = "" THEN
ESave.Caption = "Save "As
Saving
ELSE
Rich.SaveToFile(fileName)
IF iSaveBack.Checked = 1 THEN
Rich.SaveToFile(REPLACE$(fileName,"."bak,INSTR(fileName,".")))
END IF
END IF
saved = 1
CASE iSaveAs.Handle
ESave.Caption = "Save "As
backslash = RINSTR(filename,"\")
ESave.Filename = RIGHT$(filename,LEN(filename)-backslash)
dotis = INSTR(filename,".")
IF dotis <> 0 THEN ESave.Filename = LEFT$(ESave.filename,dotis-1)
Saving
CASE iSaveAuto.Handle
IF iSaveAuto.Checked = 1 THEN
iSaveAuto.Checked = 0
ELSE
iSaveAuto.Checked = 1
END IF
CASE iSaveBack.Handle
IF iSaveBack.Checked = 1 THEN
iSaveBack.Checked = 0
ELSE
iSaveBack.Checked = 1
END IF
CASE iPrint.Handle
PrintClick
CASE iPrintPreview.Handle
PrintDlgShow
CASE iSelect.Handle
Rich.SelectAll
CASE iClear.Handle
Rich.Clear
CASE iCopy.Handle
Rich.CopyToClipboard
CASE iPaste.Handle
oldtext = Rich.Text
Rich.PasteFromClipboard
CASE iCut.Handle
oldtext = Rich.Text
Rich.CutToClipboard
CASE iUndo.Handle
newtext = Rich.Text
Rich.Text = oldtext
'Rich.PasteFromClipboard
Rich.SelStart = LEN(Rich.Text)
CASE iRedo.Handle
Rich.Text = newtext
Rich.SelStart = LEN(Rich.Text)
CASE iFormat.Handle
oldtext = Rich.Text
Fonts.GetFont(Arial11)
Timer1.Enabled = 0
IF Fonts.Execute THEN Fonts.SetFont(Font)
Timer1.Enabled = 1
Rich.SelAttributes = Font
CASE iFind.Handle
Timer1.Enabled = 0
FindDlg.Visible = 1
replacedcount = 0
Replaced.Caption = "0 "replaced
CASE iCount.Handle
DIM wordcount AS WORD, charcount AS WORD, charcount0 AS WORD
wordcount = 0
charcount = LEN(Rich.Text)
charcount0 = LEN(Rich.Text- CHR$(9) - CHR$(13) - CHR$(10) - " ")
text$ = REPLACESUBSTR$(Rich.Text,CHR$(13)+CHR$(10)," ")
DO
text$ = REPLACESUBSTR$(text$," "," ")
LOOP UNTIL TALLY(text$," ") = 0
text$ = RTRIM$(LTRIM$(text$))
IF INSTR(text$," ") <> 0 THEN
wordcount = TALLY(text$," ") + 1
ELSEIF INSTR(text$," ") = 0 THEN
IF LEN(text$) = 0 THEN
wordcount = 0
ELSE
wordcount = 1
END IF
END IF
IF wordcount > 1 THEN
words$ = ""Words
ELSE
words$ = ""Word
END IF
IF charcount > 1 THEN
characters$ = ""Characters
ELSE
characters$ = ""Character
END IF
IF charcount0 > 1 THEN
characters0$ = ""Characters
ELSE
characters0$ = ""Character
END IF
Timer1.Enabled = 0
SHOWMESSAGE words$ + ": " + STR$(wordcount) + CHR$(13) +_
characters$ + ": " + STR$(charcount) + CHR$(13) +_
characters0$ + ": " + STR$(charcount0) + CHR$(13) +_
"(no blanks)"
Timer1.Enabled = 1
CASE iTop.Handle
IF iTop.Checked = 1 THEN
iTop.Checked = 0
ELSE
iTop.Checked = 1
END IF
CASE iCapture.Handle
IF iCapture.Checked = 1 THEN
iCapture.Checked = 0
ELSE
iCapture.Checked = 1
END IF
CASE iRegular.Handle
Rich.SelAttributes.Italic = 0
Rich.SelAttributes.Bold = 0
Rich.SelAttributes.Underline = 0
CASE iItalic.Handle
Rich.SelAttributes.Italic = 1
CASE iBold.Handle
Rich.SelAttributes.Bold = 1
CASE iUnderline.Handle
Rich.SelAttributes.Underline = 1
CASE iUpper.Handle
Rich.Seltext = UCASE$(Rich.Seltext)
CASE iLower.Handle
Rich.Seltext = LCASE$(Rich.Seltext)
CASE iUpLow.Handle
text$ = LCASE$(Rich.Seltext)
FOR x = 1 TO LEN(text$)
char$ = MID$(text$,x,1)
IF char$ = " " THEN
nextchar$ = UCASE$(MID$(text$,x+1,1))
text$ = REPLACE$(text$,nextchar$,x+1)
END IF
NEXT
Rich.Seltext = REPLACE$(text$,UCASE$(LEFT$(text$,1)),1)
CASE mAbout.Handle
Timer1.Enabled = 0
MESSAGEBOX (" This IS freeware." + CHR$(13) +_
"Copyright (c) "2002 + CHR$(13) +_
" Achilles B. "Mina + CHR$(13) + CHR$(13) +_
"YetNaderEd IS "yet + CHR$(13) +_
"another text editor." + CHR$(13) +_
" It was written "in + CHR$(13) +_
" Rapid-Q." + CHR$(13) + CHR$(13) +_
" It "demonstrates + CHR$(13) +_
" Rapid-Q
"for producing highly" + CHR$(13) +_
" useful apps easily." + CHR$(13) +_
" It also shows the" + CHR$(13) +_
" author's lack of" + CHR$(13) +_
" talent for" + CHR$(13) +_
" innovative coding.","YetNaderEd",0)
Timer1.Enabled = 1
END SELECT
END SUB
SUB Find(Sender)
DEFBYTE back
DEFINT replacedcount
IF Match.Checked = 1 THEN
rich$ = Rich.Text
find$ = FindText.Text
ELSE
rich$ = LCASE$(Rich.Text)
find$ = LCASE$(FindText.Text)
END IF
SELECT CASE Sender.Handle
CASE FindButt.Handle
FindButt.CAPTION = "Next"
back = 0
DO
whereword = INSTR(starts,rich$,find$)
wherelast = whereword + LEN(find$)
IF wherelast > LEN(rich$) THEN DEC wherelast
IF whereword > 1 THEN
IF WholeW.Checked = 1 THEN
SELECT CASE MID$(rich$,whereword-1,1)
CASE " ",CHR$(13),CHR$(10)
SELECT CASE MID$(rich$,wherelast,1)
CASE " ", ".", ",", ";", ":", CHR$(13),CHR$(10),RIGHT$(find$,1)
Rich.SelStart = whereword - 1
back = 0
CASE ELSE
starts = whereword + LEN(find$)
back = 1
END SELECT
CASE ELSE
starts = whereword + LEN(find$)
back = 1
END SELECT
ELSE
Rich.SelStart = whereword - 1
END IF
Rich.SelLength = LEN(find$)
starts = whereword + LEN(find$)
ELSEIF whereword = 1 THEN
IF WholeW.Checked = 1 THEN
SELECT CASE MID$(rich$,wherelast,1)
CASE " ", ".", ",", ";", ":", CHR$(13),CHR$(10)
Rich.SelStart = whereword - 1
back = 0
END SELECT
ELSE
Rich.SelStart = whereword - 1
END IF
Rich.SelLength = LEN(find$)
starts = whereword + LEN(find$)
ELSE
Rich.SelLength = 0
SHOWMESSAGE "No more instances of " + FindText.Text
starts = 0
back = 0
replacedcount = 0
END IF
SetFocus(FindText.Handle)
LOOP UNTIL back = 0
ReplaceButt.Enabled = 1
CASE ReplaceButt.Handle
oldtext = Rich.Text
diff = LEN(ReplaceText.Text) - LEN(FindText.Text)
IF diff > 0 THEN
Rich.Text = INSERT$(SPACE$(diff),Rich.Text,whereword)
Rich.Text = REPLACE$(Rich.Text,ReplaceText.Text,whereword)
ELSEIF diff < 0 THEN
Rich.Text = REPLACE$(Rich.Text,ReplaceText.Text,whereword)
Rich.Text = DELETE$(Rich.Text,whereword+LEN(ReplaceText.Text),ABS(SPACE$(diff)))
ELSE
Rich.Text = REPLACE$(Rich.Text,ReplaceText.Text,whereword)
END IF
Rich.SelStart = whereword + LEN(ReplaceText.Text) - 1
ReplaceButt.Enabled = 0
SetFocus(ReplaceText.Handle)
Replaced.CAPTION = STR$(replacedcount) + " replaced"
replacedcount = replacedcount + 1
CASE ReplaceAButt.Handle
replacedcount = 0
IF WholeW.Checked = 0 THEN
oldtext = Rich.Text
replacedcount = TALLY(Rich.Text,FindText.Text)
Replaced.CAPTION = STR$(replacedcount) + " replaced"
Rich.Text = REPLACESUBSTR$(Rich.Text,FindText.Text,ReplaceText.Text)
Rich.SelStart = RINSTR(Rich.Text,ReplaceText.Text) + LEN(ReplaceText.Text) -1
SetFocus(ReplaceText.Handle)
ELSE
oldtext = Rich.Text
x = 1
DO
x = INSTR(x,rich$,find$)
IF x <> 0 THEN
IF x = 1 THEN
spacer1$ = MID$(rich$,1,1)
ELSE
spacer1$ = MID$(rich$,x-1,1)
END IF
IF LEN(RIGHT$(rich$,LEN(rich$)-(x-1))) <= LEN(find$) THEN
spacer2$ = RIGHT$(rich$,1)
ELSE
spacer2$ = MID$(rich$,x+LEN(find$),1)
END IF
SELECT CASE spacer1$
CASE " ", LEFT$(find$,1), CHR$(10), CHR$(13)
SELECT CASE spacer2$
CASE " ", ".", ",", ";", ":", CHR$(10), CHR$(13),RIGHT$(find$,1)
Rich.Text = DELETE$(Rich.Text,x,LEN(FindText.Text))
Rich.Text = INSERT$(ReplaceText.Text,Rich.Text,x)
INC replacedcount
INC x,LEN(ReplaceText.Text)
IF Match.Checked = 1 THEN
rich$ = Rich.Text
ELSE
rich$ = LCASE$(Rich.Text)
END IF
CASE ELSE
INC x
END SELECT
CASE ELSE
INC x
END SELECT
END IF
LOOP UNTIL x = 0
Replaced.CAPTION = STR$(replacedcount) + " replaced"
Rich.SelStart = RINSTR(Rich.Text,ReplaceText.Text) + LEN(ReplaceText.Text) -1
SetFocus(ReplaceText.Handle)
END IF
END SELECT
END SUB
SUB CheckSave(key,shift)
SELECT CASE shift
CASE 0
SELECT CASE key
CASE 8,46
CASE 27
FormE.WindowState = 1
CASE ELSE
oldtext = Rich.Text
END SELECT
CASE 1
SELECT CASE key
CASE 83
IF saved = 0 AND filename = "" THEN
ESave.CAPTION = "Save As"
Saving
ELSE
Rich.SaveToFile(fileName)
IF iSaveBack.Checked = 1 THEN
Rich.SaveToFile(REPLACE$(fileName,".bak",INSTR(fileName,".")))
END IF
END IF
saved = 1
CASE 67
Rich.CopyToClipboard
oldtext = Rich.Text
CASE 86
CASE 88
oldtext = Rich.Text
Rich.CutToClipboard
END SELECT
END SELECT
END SUB
SUB ComboBoxChange(Sender AS QCOMBOBOX)
Printer.PrinterIndex = Sender.ItemIndex
END SUB
SUB PrintClick
Timer1.Enabled = 1
PrintDlg.Visible = 0
IF Portrait.Checked = 1 THEN
Printer.Orientation = 0
ELSE
Printer.Orientation = 1
END IF
Printer.Font = Arial11
Printer.Copies = VAL(PagesCopy.Text)
LPRINT Rich.Text
LFLUSH
END SUB
SUB PrintDlgShow
Timer1.Enabled = 0
PrintDlg.Visible = 1
PreviewBox.Text = Rich.Text
END SUB
SUB CloseFind
Timer1.Enabled = 1
FindDlg.Visible = 0
END SUB
SUB Saving
sresult = 6
Timer1.Enabled = 0
DO
ESave.Filter = "All files|*.*|Rich Text Format|*.rtf|Word|*.doc|Plain text|*.txt"
IF ESave.EXECUTE THEN
SELECT CASE ESave.FilterIndex
CASE 1
IF RINSTR(ESave.Filename,".") <> 0 THEN ext$ = RIGHT$(ESave.Filename,4)
CASE 2
ext$ = ".rtf"
CASE 3
ext$ = ".doc"
CASE 4
ext$ = ".txt"
Rich.Plaintext = 1
Rich.SelectAll
Rich.SelAttributes.Italic = 0
Rich.SelAttributes.Bold = 0
Rich.SelAttributes.Underline = 0
END SELECT
dotis = RINSTR(ESave.Filename,".")
IF dotis <> 0 THEN
filename = LEFT$(ESave.FileName,dotis-1) + ext$
ELSE
filename = ESave.FileName + ext$
END IF
IF FILEEXISTS(fileName) THEN
sresult = MESSAGEDLG ("File already exists. Overwrite?", 3, 1 OR 2 OR 8, 0)
ELSE
sresult = 6
END IF
IF sresult = 6 THEN
Rich.SaveToFile(filename)
IF iSaveBack.Checked = 1 THEN
Rich.SaveToFile(REPLACE$(fileName,".bak",INSTR(fileName,".")))
END IF
saved = 1
StatusBar.Panel(4).CAPTION = filename
END IF
ELSE
sresult = 2
END IF
LOOP UNTIL sresult = 6 OR sresult = 2
Timer1.Enabled = 1
Rich.SelLength = 0
END SUB
SUB Exits(Sender)
IF Rich.Modified = 0 THEN
IF Sender.Handle <> iClose.Handle THEN Application.Terminate
ELSEIF saved = 0 AND Rich.Modified = 1 THEN
ESave.CAPTION = "Save As"
ESave.Filename = filename
Saving
IF Sender.Handle = iClose.Handle THEN
filename = ""
StatusBar.Panel(4).CAPTION = ""
Rich.Clear
saved = 1
ELSE
Application.Terminate
END IF
ELSE
IF Sender.Handle = iClose.Handle THEN
filename = ""
StatusBar.Panel(4).CAPTION = ""
Rich.Clear
saved = 1
ELSE
Application.Terminate
END IF
END IF
END SUB
SUB Changed
saved = 0
charcount0 = LEN(Rich.Text - CHR$(9) - CHR$(13) - CHR$(10) - " ")
StatusBar.Panel(1).CAPTION = STR$(charcount0) + " chars"
END SUB
SUB Splash
SplashForm.Visible = 0
SplashTimer.Enabled = 0
FormE.Visible = 1
END SUB
SUB FormEShow
SENDMESSAGE Rich.Handle, &HC5, 1048576, 0
Setwindowlong(FormE.Handle,-8,0)
Setwindowlong(Application.Handle,-8,FormE.Handle)
beginT = TIMER
END SUB
SUB PasteClipboard
DEFINT hour, min, elapsedT, savetimer
hour = VAL(LEFT$(TIME$,2))
min = VAL(MID$(TIME$,4,2))
IF hour >= 12 AND hour < 24 THEN
hour = hour - 12
IF hour = 0 THEN hour = 12
ampm$ = " PM"
ELSEIF hour = 0 THEN
hour = 12
ampm$ = " AM"
ELSE
ampm$ = " AM"
END IF
IF min < 10 THEN
StatusBar.Panel(3).CAPTION = STR$(hour) + ":0" + STR$(min) + RIGHT$(TIME$,3) + ampm$
ELSE
StatusBar.Panel(3).CAPTION = STR$(hour) + ":" + STR$(min) + RIGHT$(TIME$,3) + ampm$
END IF
elapsedT = TIMER - beginT
IF elapsedT < 60 THEN
secs = elapsedT
mins = 0
hrs = 0
ELSEIF elapsedT >= 60 AND elapsedT <= 3600 THEN
hrs = 0
mins = FIX(elapsedT/60)
secs = elapsedT MOD 60
ELSE
hrs = FIX(elapsedT/3600)
remainder = elapsedT MOD 3600
IF remainder < 60 THEN
secs = remainder
mins = 0
ELSE
mins = FIX(remainder/60)
secs = remainder MOD 60
END IF
END IF
INC savetimer
IF savetimer >= 600 THEN
savetimer = 0
IF iSaveAuto.Checked = 1 AND filename <> "" THEN
Rich.SaveToFile(fileName)
IF iSaveBack.Checked = 1 THEN
Rich.SaveToFile(REPLACE$(fileName,".bak",INSTR(fileName,".")))
END IF
END IF
END IF
StatusBar.Panel(0).CAPTION = STR$(hrs) + ":" + STR$(mins) + ":" + STR$(secs)
IF iCapture.Checked = 1 THEN
IF LEFT$(Clipboard.Text,10) <> previous THEN
Rich.PasteFromClipboard
Rich.Addstrings CHR$(10)
previous = LEFT$(Clipboard.Text,10)
END IF
END IF
IF iTop.Checked = 1 THEN
SetWindowPos(FormE.Handle,-1,0,0,0,0,&H1 OR &H2)
ELSE
SetWindowPos(FormE.Handle,-2,0,0,0,0,&H1 OR &H2)
END IF
END SUB
FOR I = 0 TO Printer.PrintersCount-1
ComboBox.AddItems(Printer.Printers(I))
NEXT
ComboBox.ItemIndex = Printer.PrinterIndex
SplashForm.SHOWMODAL
|
|