Post by MarkHas anyone come up with a way to insert a string into an edtior datalinked to a memofield?
Currently, I created a popup menu with a right click on an editor. They
can pick a "todays date" option and it inserts the date at the top of
cNote = form.rowset.fields["note"].value
cNote = dtoc(date())+" "+cNote
form.rowset.fields["note"].value:= cNote
However, I would like to allow them to click on a location in the memo
field and insert the string at that location. Just not sure how I can
identify the location based on where the cursor is now in the Editor
that is linked to the memo field.
Thanks for any ideas on this,
The example code below may give you some ideas. Watch for line wrap.
******** Start of example code *********
if not file('alib.dbf')
copy table c:\duflp\library.dbf to alib.dbf
endif
** END HEADER -- do not remove this line
//
// Generated on 2008/11/25
//
parameter bModal
local f
f = new _editor2Form()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class _editor2Form of FORM
set procedure to "C:\Program
Files\dBASE\PLUS\dBLClasses\DataButtons.cc" additive
with (this)
onOpen = class::FORM_ONOPEN
height = 19.4091
left = 4.2857
top = 11.1364
width = 75.8571
text = ""
endwith
this.ALIB1 = new QUERY()
this.ALIB1.parent = this
with (this.ALIB1)
left = 3.1429
top = -0.3636
sql = 'select * from "alib.dbf"'
active = true
endwith
this.EDITOR1 = new EDITOR(this)
with (this.EDITOR1)
height = 7.7273
left = 7.2857
top = 3.5909
width = 47.4286
dataLink = form.alib1.rowset.fields["description"]
endwith
this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
visible = false
height = 1.0
left = 2.4286
top = 11.9545
width = 151.1429
value = ""
maxLength = 2000
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_ONCLICK
height = 1.0909
left = 2.7143
top = 15.0455
width = 15.2857
text = "Insert text"
speedBar = true
endwith
this.ENTRYFIELD2 = new ENTRYFIELD(this)
with (this.ENTRYFIELD2)
height = 1.0
left = 22.7143
top = 15.1364
width = 41.5714
value = "TEXT TO INSERT"
maxLength = 100
endwith
this.BARDATAVCR1 = new BARDATAVCR(this)
with (this.BARDATAVCR1)
left = 21.5714
top = 1.2273
width = 18.2857
height = 1.4545
endwith
this.rowset = this.alib1.rowset
function PUSHBUTTON1_onClick
form.freeze()
form.entryfield1.value = form.editor1.value
form.editor1.wrap = false
form.editor1.keyboard("{shift-end}{shift-end}")
form.editor1.copy()
form.entryfield1.setfocus()
form.entryfield1.paste()
form.editor1.wrap = true
form.editor1.keyboard("{home}")
if len(form.entryfield1.value) > 0
form.editor1.value =
stuff(form.editor1.value,len(trim(form.editor1.value))-len(trim(form.entryfield1.value))+1,0,form.entryfield2.value)
endif
form.entryfield1.value = ""
form.unfreeze()
return
function form_onOpen
clear
return
//freeze and unfreeze copied and pasted from fornstuf.prg in the dUFLP
FUNCTION Freeze
/*
Freeze -- freezes the current window, so you can
modify the display without the form
flashing. This is rather handy, combined
with UnFreeze (below), and perhaps
repaint().
Credit: This code was lifted from the code in Command.wfm,
which is unattributed ...
*/
if type( "LockWindowUpdate" ) # "FP"
extern CLOGICAL LockWindowUpdate( CHANDLE ) User32
endif
if this.hWnd > 0
LockWindowUpdate( this.hWnd )
endif
return
FUNCTION UnFreeze
/*
UnFreeze -- Un-Freezes the current window, so you can
modify the display without the form
flashing. This is rather handy, combined
with Freeze (above), and perhaps
repaint().
Credit: This code was lifted from the code in Command.wfm,
which is unattributed ...
*/
if type( "LockWindowUpdate" ) # "FP"
extern CLOGICAL LockWindowUpdate( CHANDLE ) User32
endif
LockWindowUpdate( 0 )
endclass
********** End of example code *******