Internet Explorer used as rich editor

Published on by Yousfi Benameur


this code uses the internet explorer browser (can also use application) as a richtext application.
the important point is that IE whose is the top of rich objects browser , can be editable.

it have two modes for document object.
-designMode="on"  IE editable:can modify,add ,save...as all classic editor operations
-designMode="off"  readonly as all we see in web pages.

on : Document can be edited.
off: inherit     Default. Document cannot be edited.

Remarks
Starting with Internet Explorer 11, the returned property values are lower case rather than capitalized.
 cannot execute script when the value of the designMode property is set to on.(vfp9 crahes here).
can use the designMode property to put Windows Internet Explorer into a mode so that you can edit the current document.
While the browser is in design mode, objects enter a UI-activated state when the user presses ENTER, clicks
 an object that has focus, or double-clicks the object. Objects that are UI-activated have their own window in the document. can modify the UI only when the object is in a UI-activated state.

i build some basic functions in a menu on a top level form ,of course can extend to more IE capabilities.can make icons instead texts...as well as this same tool (with another method) in http://yousfi.over-blog.com/2015/02/a-vfp-html-richtext-editor.html
this last used  editable element with the contentEditable property

can use this tool to copy selected objects on web page and paste,open a file and transform it,save, print,find...

Warning: dont open an URL in designMode="on" ", vfp9 crashes (maybe for security reasons...)

https://msdn.microsoft.com/en-us/library/ms533720%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/aa753630%28v=vs.85%29.aspx

this code is tested on Win10 pro,VFP9SP2 and IE11 emulation

Note: if you want to build a project and compile an exe, regenerate the menu in the project to be compiled as mpx/mpr.i tested that and it works fine.
-the saveAS menu option works only with target single html and text file...
*see codez *3* for the update. 

 

 

Click on code to select [then copy] -click outside to deselect

*1*
set safe off
set talk off
clea all

publi  m.yrep
m.yrep=addbs(justpath(sys(16,1)))
set defa to (yrep)


&&write the menu yed.mpr on the same folder as the main prg.
local m.myvar
text to m.myvar noshow

DEFINE POPUP raccourci SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF raccourci PROMPT "select all" ;
PICTRES _med_slcta
DEFINE BAR 2 OF raccourci PROMPT "copy" ;
PICTRES _med_copy
DEFINE BAR 3 OF raccourci PROMPT "cut" ;
PICTRES _med_cut
DEFINE BAR 4 OF raccourci PROMPT "paste" ;
PICTRES _med_paste
DEFINE BAR 5 OF raccourci PROMPT "unddo" ;
PICTRES _med_undo
DEFINE BAR 6 OF raccourci PROMPT "Redo" ;
PICTRES _med_redo
DEFINE BAR 7 OF raccourci PROMPT "Bold"
DEFINE BAR 8 OF raccourci PROMPT "Italic"
DEFINE BAR 9 OF raccourci PROMPT "Underline"
DEFINE BAR 10 OF raccourci PROMPT "delete"
DEFINE BAR 11 OF raccourci PROMPT "Forecolor"
DEFINE BAR 12 OF raccourci PROMPT "Backcolor"
DEFINE BAR 13 OF raccourci PROMPT "Fonts"
DEFINE BAR 14 OF raccourci PROMPT "Explorer"  ;
PICTURE home(1)+"graphics\icons\win95\explorer.ico"
DEFINE BAR 15 OF raccourci PROMPT "Alignment"
ON SELECTION BAR 1 OF raccourci ;
DO _4j90n3b3s ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 2 OF raccourci ;
DO _4j90n3b3u ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 3 OF raccourci ;
DO _4j90n3b3v ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 4 OF raccourci ;
DO _4j90n3b3x ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 5 OF raccourci ;
DO _4j90n3b3z ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 6 OF raccourci ;
DO _4j90n3b4k ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 7 OF raccourci ;
DO _4j90n3b4l ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 8 OF raccourci ;
DO _4j90n3b4m ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 9 OF raccourci ;
DO _4j90n3b4n ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 10 OF raccourci ;
DO _4j90n3b4o ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 11 OF raccourci ;
DO _4j90n3b4p ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 12 OF raccourci ;
DO _4j90n3b4q ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 13 OF raccourci ;
DO _4j90n3b4r ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 14 OF raccourci run/n explorer.exe &yrep
ON BAR 15 OF raccourci ACTIVATE POPUP alignment

DEFINE POPUP alignment SHORTCUT RELATIVE
DEFINE BAR 1 OF alignment PROMPT "Left" ;
PICTURE home(1)+"graphics\bitmaps\tlbr_w95\lft.bmp"
DEFINE BAR 2 OF alignment PROMPT "Right" ;
PICTURE home(1)+"graphics\bitmaps\tlbr_w95\rt.bmp"
DEFINE BAR 3 OF alignment PROMPT "Center" ;
PICTURE home(1)+"graphics\bitmaps\tlbr_w95\ctr.bmp"
ON SELECTION BAR 1 OF alignment ;
DO _4j90n3b4t ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 2 OF alignment ;
DO _4j90n3b4u ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")
ON SELECTION BAR 3 OF alignment ;
DO _4j90n3b4w ;
IN LOCFILE("YED" ,"MPX;MPR|FXP;PRG" ,"WHERE is YED?")

ACTIVATE POPUP raccourci
*
PROCEDURE _4j90n3b3s
*slcta
#DEFINE OLECMDID_SELECTALL 17
#DEFINE OLECMDEXECOPT_DODEFAULT 0

with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_SELECTALL , OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _4j90n3b3u
*copy

#DEFINE OLECMDID_COPY 12
#DEFINE OLECMDEXECOPT_DODEFAULT 0

with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_COPY , OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _4j90n3b3v
*cut

#DEFINE OLECMDID_CUT 11
#DEFINE OLECMDEXECOPT_DODEFAULT 0

with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_CUT , OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _4j90n3b3x
*paste
#DEFINE OLECMDID_PASTE 13
#DEFINE OLECMDEXECOPT_DODEFAULT 0

with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_PASTE, OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _4j90n3b3z
*unddo
#DEFINE OLECMDID_UNDO 15
#define OLECMDEXECOPT_DONTPROMPTUSER 2
_screen.activeform.olecontrol1.ExecWB (OLECMDID_UNDO, OLECMDEXECOPT_DONTPROMPTUSER)

*
PROCEDURE _4j90n3b4k
*Redo

#DEFINE OLECMDID_REDO 16
#define OLECMDEXECOPT_DONTPROMPTUSER 2
_screen.activeform.olecontrol1.ExecWB (OLECMDID_REDO, OLECMDEXECOPT_DONTPROMPTUSER)


*
PROCEDURE _4j90n3b4l
_screen.activeform.olecontrol1.document.execCommand("bold")


*
PROCEDURE _4j90n3b4m
_screen.activeform.olecontrol1.document.execCommand("italic")


*
PROCEDURE _4j90n3b4n
_screen.activeform.olecontrol1.document.execCommand("underLine")


*
PROCEDURE _4j90n3b4o
_screen.activeform.olecontrol1.document.execCommand("delete")


*
PROCEDURE _4j90n3b4p
* Changeforecolor of the selected text
    local m.xforecolor
	m.xforecolor=getcolor()
	if m.xforecolor#-1
	_screen.activeform.olecontrol1.document.execCommand("Forecolor",.f.,m.xforecolor)
	endi


*
PROCEDURE _4j90n3b4q
* Change backcolor of the selected text
	local m.xbackcolor
	m.xbackcolor=getcolor()
	if m.xbackcolor#-1
	_screen.activeform.olecontrol1.document.execCommand("Backcolor",.f.,m.xbackcolor)
	endi

*
PROCEDURE _4j90n3b4r
local xfont,xfontname,xfontsize,xfontstyle
	xfont=getfont("Arial",12)
	if  empty(xfont)
	return .f.
	endi

	xfontname=getwordnum(xfont,1,",")
	xfontsize=getwordnum(xfont,2,",")
	xfontsize=int(val(getwordnum(xfont,2,",")))   && Required. Integer or String that specifies the font size. This must be a value between 1 and 7, inclusive.
	xfontStyle=getwordnum(xfont,3,",")
	_screen.activeform.olecontrol1.document.execCommand("FontName",.f., xfontname)

	local xpoint as integer
	do case
	case xfontsize<=9
	xpoint=1
	case between(xfontsize,10,11)
	xpoint=2
	case between(xfontsize,12,18)
	xpoint=3
	case between(xfontsize,19,23)
	xpoint=4
	case between(xfontsize,24,31)  &&29
	xpoint=5
	case between(xfontsize,32,45)
	xpoint=6
	case xfontsize>=46
	xpoint=7
	endcase

	_screen.activeform.olecontrol1.document.execCommand("FontSize",.f., m.xPOINT)     &&attention fontsize converted ~ to  points ( 1 to 7)
	if "B" $ xfontstyle
	_screen.activeform.olecontrol1.document.execCommand("Bold",.t.)
	endi

	if "I" $ xfontstyle
	_screen.activeform.olecontrol1.document.execCommand("Italic",.t.)
	endi


*
PROCEDURE _4j90n3b4t
_screen.activeform.olecontrol1.document.execCommand("justifyLeft")


*
PROCEDURE _4j90n3b4u
_screen.activeform.olecontrol1.document.execCommand("justifyRight")


*
PROCEDURE _4j90n3b4w
_screen.activeform.olecontrol1.document.execCommand("justifyCenter")

endtext
strtofile(m.myvar,m.yrep+"yed.mpr")
*modi comm yed.mpr

publi yform
yform=newObject("yRtIE")
yform.show
read events
retu
*

DEFINE CLASS yRtIE AS form
Height = 551
Width = 902
ShowWindow = 2
ShowTips = .T.
AutoCenter = .T.
Caption = "A simple richtext editor tool with Internet Explorer"
BackColor = RGB(192,192,192)
zoom = 100
ynew = .F.
Name = "Form1"

ADD OBJECT olecontrol1 AS olecontrol WITH ;
oleclass="shell.explorer.2", ;
Top = 35, ;
Left = 0, ;
Height = 514, ;
Width = 902, ;
Anchor = 15, ;
Name = "Olecontrol1"

ADD OBJECT command1 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 336, ;
Height = 27, ;
Width = 48, ;
Anchor = 768, ;
Caption = "Menu", ;
Name = "Command1"

ADD OBJECT command5 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 762, ;
Height = 25, ;
Width = 56, ;
FontSize = 8, ;
Anchor = 768, ;
Caption = "Save as", ;
Name = "Command5"

ADD OBJECT command6 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 659, ;
Height = 25, ;
Width = 80, ;
FontSize = 8, ;
Anchor = 768, ;
Caption = "Preview/Print", ;
SpecialEffect = 2, ;
Name = "Command6"

ADD OBJECT command7 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 445, ;
Height = 27, ;
Width = 42, ;
Anchor = 768, ;
Caption = "Find", ;
Name = "Command7"

ADD OBJECT check1 AS checkbox WITH ;
Top = 2, ;
Left = 18, ;
Height = 25, ;
Width = 141, ;
FontBold = .T., ;
FontName = "Segoe Script", ;
FontSize = 11, ;
Anchor = 768, ;
Alignment = 0, ;
Caption = "DesignMode on", ;
Value = 1, ;
Style = 1, ;
Name = "Check1"

ADD OBJECT image1 AS image WITH ;
Anchor = 768, ;
Stretch = 2, ;
BackStyle = 0, ;
BorderStyle = 0, ;
Height = 29, ;
Left = 832, ;
MousePointer = 15, ;
Top = 0, ;
Width = 37, ;
ToolTipText = "Summary help", ;
Name = "Image1"

ADD OBJECT combo1 AS combobox WITH ;
FontBold = .T., ;
FontName = "Segoe Script", ;
FontSize = 8, ;
Anchor = 768, ;
Height = 25, ;
Left = 499, ;
MousePointer = 15, ;
Top = 2, ;
Width = 82, ;
Name = "Combo1"

ADD OBJECT combo2 AS combobox WITH ;
FontBold = .T., ;
FontName = "Segoe Script", ;
FontSize = 8, ;
Anchor = 768, ;
Height = 25, ;
Left = 588, ;
MousePointer = 15, ;
Top = 2, ;
Width = 61, ;
Name = "Combo2"

ADD OBJECT command8 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 167, ;
Height = 27, ;
Width = 86, ;
Anchor = 768, ;
Caption = "Open file", ;
Name = "Command8"

ADD OBJECT command2 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 265, ;
Height = 27, ;
Width = 43, ;
Anchor = 768, ;
Caption = "New", ;
Name = "Command2"

PROCEDURE Destroy
clea events
ENDPROC

PROCEDURE init
_screen.windowstate=1
with this
.autocenter=.t.
.setall("specialEffect",2,"commandbutton")
.setall("mousepointer",15,"commandbutton")
.setall("fontname","Segoe Script","commandbutton")
.setall("fontbold",.t.,"commandbutton")
.refresh
endwith		
ENDPROC


PROCEDURE olecontrol1.Init
local m.myvar
text to m.myvar noshow
<body oncontextmenu="return false;">
</body>
endtext

local m.lcdest
m.lcdest=addbs(sys(2023))+"ytemp.html"
thisform.ynew=m.lcdest
strtofile(m.myvar,m.lcdest)
*modi comm (lcdest)

with this
.silent=.t.
.navigate(m.lcdest)
.document.designMode="on"
.refresh
endwith
*<!DOCTYPE html>
ENDPROC

PROCEDURE command1.Click
do (m.yrep+"yed.mpr")
ENDPROC

PROCEDURE command5.Click
local m.x,m.y
*m.x=thisform.olecontrol1.document.body.innerhtml
*m.y=PUTFILE("choose a file to save this", "" , ".html|htm|txt")   &&|mht?
*set safe off
*strtofile(m.x,m.y)


#DEFINE OLECMDID_SAVEAS 4
#DEFINE OLECMDEXECOPT_DODEFAULT 0
thisform.olecontrol1.ExecWB(OLECMDID_SAVEAS , OLECMDEXECOPT_DODEFAULT,m.y)
ENDPROC

PROCEDURE command6.Click
*Constants for ExecWb first parameter
#DEFINE OLECMDID_PRINT 6
#DEFINE OLECMDID_PRINTPREVIEW 7

*Constants for ExecWB second parameter
#DEFINE OLECMDEXECOPT_DODEFAULT 0
#DEFINE OLECMDEXECOPT_PROMPTUSER 1
#DEFINE LECMDEXECOPT_DONTPROMPTUSER 2

*thisform.olecontrol1.Execwb(OLECMDID_PRINT  ,LECMDEXECOPT_DONTPROMPTUSER )   &&to print directly
thisform.olecontrol1.Execwb(OLECMDID_PRINTPREVIEW  ,OLECMDEXECOPT_DODEFAULT)   &&preview
ENDPROC

PROCEDURE command7.Click
thisform.olecontrol1.setfocus
oshell=newObject("wscript.shell")
oshell.sendkeys("^{f}")
oshell=null
ENDPROC

PROCEDURE check1.InteractiveChange
this.caption=iif(this.value=1,"design mode on","design mode off")
thisform.olecontrol1.document.designmode=iif(this.value=1,"on","off")
ENDPROC

PROCEDURE image1.Click
text to m.xtext noshow
this code uses the internet explorer browser (can also use application) as a richtext application.
the important point is that IE can be editable.

it have two modes for document object.
-designMode="on" && IE editable:can modify,add ,save...as all classic editor operations
-designMode="off"  &&readonly as all we see in web pages.

on : Document can be edited.
off: inherit   -Default. Document cannot be edited.

Remarks
Starting with Internet Explorer 11, the returned property values are lower case rather than capitalized.
You cannot execute script when the value of the designMode property is set to on.
can use the designMode property to put Windows Internet Explorer into a mode so that you can edit the current document.
While the browser is in design mode, objects enter a UI-activated state when the user presses ENTER, clicks
an object that has focus, or double-clicks the object. Objects that are UI-activated have their own window
in the document. You can modify the UI only when the object is in a UI-activated state.

i build some basic functions in a container , can extend to more IE capabilities.can make icons instead texts..
can use this tool to copy selected objects on web page and paste,open a file and transform it,save, print,find...
-note that open an URL makes vfp9 crashing !!(security ?)
Refrences:
https://msdn.microsoft.com/en-us/library/ms533720%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/aa753630%28v=vs.85%29.aspx
 endtext

DECLARE INTEGER MessageBox IN user32 As MessageBoxAPI;
	INTEGER hwnd,;
	STRING  lpText,;
	STRING  lpCaption,;
	INTEGER wType

*buttons
#define MB_OK 0x00000000
*Icons
#define MB_ICONINFORMATION 0x00000040
*To indicate the default button, specify one of the following values.
#define  MB_DEFBUTTON1 0x00000000
*To indicate the modality of the dialog box, specify one of the following values.
#define MB_APPLMODAL 0x00000000
MessageBoxAPI(_vfp.hwnd,m.xtext,"A simple richtext editor with IE",MB_APPLMODAL+MB_OK +MB_ICONINFORMATION +MB_DEFBUTTON1 )
ENDPROC

PROCEDURE image1.Init
local m.myvar
text to m.myvar noshow
R0lGODlhQABAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQAPAAAACwAAAAAQABAAIcAAAAAADMAAGYAAJkAAMwAAP8AKwAAKzMAK2YAK5kAK8wAK/8AVQAAVTMAVWYAVZkAVcwAVf8AgAAAgDMAgGYAgJkAgMwAgP8AqgAAqjMAqmYAqpkAqswAqv8A1QAA1TMA1WYA1ZkA1cwA1f8A/wAA/zMA/2YA/5kA/8wA//8zAAAzADMzAGYzAJkzAMwzAP8zKwAzKzMzK2YzK5kzK8wzK/8zVQAzVTMzVWYzVZkzVcwzVf8zgAAzgDMzgGYzgJkzgMwzgP8zqgAzqjMzqmYzqpkzqswzqv8z1QAz1TMz1WYz1Zkz1cwz1f8z/wAz/zMz/2Yz/5kz/8wz//9mAABmADNmAGZmAJlmAMxmAP9mKwBmKzNmK2ZmK5lmK8xmK/9mVQBmVTNmVWZmVZlmVcxmVf9mgABmgDNmgGZmgJlmgMxmgP9mqgBmqjNmqmZmqplmqsxmqv9m1QBm1TNm1WZm1Zlm1cxm1f9m/wBm/zNm/2Zm/5lm/8xm//+ZAACZADOZAGaZAJmZAMyZAP+ZKwCZKzOZK2aZK5mZK8yZK/+ZVQCZVTOZVWaZVZmZVcyZVf+ZgACZgDOZgGaZgJmZgMyZgP+ZqgCZqjOZqmaZqpmZqsyZqv+Z1QCZ1TOZ1WaZ1ZmZ1cyZ1f+Z/wCZ/zOZ/2aZ/5mZ/8yZ///MAADMADPMAGbMAJnMAMzMAP/MKwDMKzPMK2bMK5nMK8zMK//MVQDMV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4CkjJvcIy6GYWIEooprfVEklNtjghJEzsuGzBTJ3Mkmegew0GqU6zKroJnHJtBpRsI7hIwYO7sJ6z3K1PVdOgpMS6s20ILEjIz7HyBCDMPiAOd46s4F6Izk2NUtvfg5flEy2wmyBAzLkbSsjec2ttLGIKpKkr2myIRNDGPiMzGSxeiKVljrkzOtmlfTABI2d+AgTicX9xhOM17tg8u1aPi1IKTbwoVQPwOoCvOSdF18y8Q1j1+ZXguyp/0NSmzoNZifX9yDDyA0xLF3jXM4puM6b9pbTFMDIqCsbL2FggoMYknB440qRpklcO00NkwysEUsizD14ZmvgyuvsEjPH5LiITc28ZTJM5Y2pq+TP6qK18mOLIMXWit+ApMwkmMA9t+UR9z4wYVid4ddzaQ5nzkfLhBGDDMEAzym2AafMabZA0xaGT48/PmTWGEEjhhgnWy7+z8III0kkwgQTDMY2EgNUFMSs/oAEGpJYGuqidyd2uO4YXhMDGm6wOc5FIgw3EFp69IO7uKDBd6wbn+tkdK1NcUpsuzhDGMRwBvZVrYDfeMtH6IEGuUWvU9dqxzzqhA92KGkdiopX2qTY840O2ow+yACYPJAhjElQBBMvoUc98jEPH1LvKwqqmjeOphN9UEQSaHAiq+ixDGgsQyD6oEedMPYkKImIHXABUHjqBDusHMUbwlAMQ6boQ9HIqxwy1GNC9NFHD9nGiIIkiDvk0UYyBUMTiaSTy5Byrkg2hJBYEUYm2mbJ6rADGcHIVCcdMgyOILKT9FAGMXRHEZCNMiFlhAY05CjHV9rylh8JCAA7
endtext
this.pictureVal=strconv(m.myvar,14)
ENDPROC

PROCEDURE combo1.Init
with this
.additem(" GoTop")
.additem(" GoBottom")
.listindex=1
.value=1
.style=2
endwith
ENDPROC

PROCEDURE combo1.Click
local oshell
oshell=newObject("wscript.shell")
local m.stat
m.stat=0
with  this.parent.check1
if .value=1   && on
m.stat=1
.value=0      && off
.interactiveChange()
endi
endwith
thisform.olecontrol1.setfocus
do case
case this.value=1
oshell.sendkeys("{home}")
case this.value=2
oshell.sendkeys("{end}")
endcase

ENDPROC

PROCEDURE combo2.Click
local oshell
oshell=newObject("wscript.shell")
thisform.olecontrol1.setfocus

	   #define OLECMDID_OPTICAL_ZOOM 63
	   #define OLECMDEXECOPT_DODEFAULT 0
do case
			case this.value=1
		thisform.zoom=thisform.zoom+10
		thisform.olecontrol1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, thisform.zoom, Null)
		wait window (trans(thisform.zoom)+" %") timeout 1

		case this.value=2
		#DEFINE OLECMDEXECOPT_DONTPROMPTUSER 2
		thisform.zoom=thisform.zoom-10
		thisform.olecontrol1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, thisform.zoom, Null)
		wait window (trans(thisform.zoom)+" %") timeout 1

		case this.value=3  &&100% zoom
		thisform.zoom=100
		thisform.olecontrol1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, thisform.zoom, Null)
		wait window (trans(thisform.zoom)+" %") timeout 1
		endcase
ENDPROC

PROCEDURE combo2.Init
with this
.additem("Zoom +")
.additem("Zoom -")
.additem("Zoom 100%")
.listindex=1
.style=2
.value=1
endwith
ENDPROC

PROCEDURE command8.Click
thisform.olecontrol1.setfocus
oshell=newObject("wscript.shell")
oshell.sendkeys("^{o}")
oshell=null
ENDPROC

PROCEDURE command2.Click
with thisform.olecontrol1
.navigate(thisform.ynew)
.document.designMode="on"
.refresh
endwith
ENDPROC

ENDDEFINE
*
*-- EndDefine: yRtIE


 

Click on code to select [then copy] -click outside to deselect

*2*
Command identifiers specify an action to take on the given object with ExecCommand. 
Can Use  the following identifiers defined in:https://msdn.microsoft.com/en-us/library/ms533049%28v=vs.85%29.aspx
or in: https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
The IE with designMode="on" have these goals:"
    -Standard editing functionality such as caret positioning, keyboard navigation, drag-and-drop, and content  selection.
    -Copy, cut, delete, and paste operations.
    -Multi-level undo and redo.
    -The ability to toggle selected text between bold, italic, and/or underlined.
    -The ability to alter typeface, font size, forecolor (text), and backcolor (background).
    -The ability to remove formatting.
    -The ability to increase or decrease indentation.
    -The ability to justify text (left, center, right).
    -The ability to create ordered and unordered lists.
    -The ability to create a hyperlink or bookmark.
    -The ability to insert a horizontal line.
    -The ability to insert an image.(rightclick)
    -The ability to insert a variety of intrinsic controls. These include buttons, text boxes, radio buttons,    check boxes, submit controls, and drop-down and list boxes.
rightClick to fire the contextuel menu (edition,image,..)    
    
In same register,and to extend capabilities of this code, see this previous link :
http://yousfi.over-blog.com/2015/02/a-vfp-html-richtext-editor.html

 

 

Internet Explorer used as rich editor
Internet Explorer used as rich editor
Internet Explorer used as rich editor

Click on code to select [then copy] -click outside to deselect

*3* update of the code above with some complements in menu ymenu.mpr (created dynamically).
*created on 23 of march 2018

if !_vfp.startmode=0
on shutdown quit
endi

set safe off
set talk off
clea all

publi  m.yrep
m.yrep=addbs(justpath(sys(16,1)))
set defa to (yrep)

set path to (yrep)
&&create the menu ymenu.mpr on the same folder as the main prg.
local m.myvar
text to m.myvar noshow
DEFINE POPUP raccourci SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF raccourci PROMPT "yQuestion"
DEFINE BAR 2 OF raccourci PROMPT "select all" ;
	PICTRES _med_slcta
DEFINE BAR 3 OF raccourci PROMPT "copy" ;
	PICTRES _med_copy
DEFINE BAR 4 OF raccourci PROMPT "cut" ;
	PICTRES _med_cut
DEFINE BAR 5 OF raccourci PROMPT "paste" ;
	PICTRES _med_paste
DEFINE BAR 6 OF raccourci PROMPT "unddo" ;
	PICTRES _med_undo
DEFINE BAR 7 OF raccourci PROMPT "Redo" ;
	PICTRES _med_redo
DEFINE BAR 8 OF raccourci PROMPT "Bold"
DEFINE BAR 9 OF raccourci PROMPT "Italic"
DEFINE BAR 10 OF raccourci PROMPT "Underline"
DEFINE BAR 11 OF raccourci PROMPT "delete"
DEFINE BAR 12 OF raccourci PROMPT "Forecolor"
DEFINE BAR 13 OF raccourci PROMPT "Backcolor"
DEFINE BAR 14 OF raccourci PROMPT "fontsize"
DEFINE BAR 15 OF raccourci PROMPT "Fonts"
DEFINE BAR 16 OF raccourci PROMPT "Explorer" PICTURE  home(1)+"graphics\icons\win95\explorer.ico"
DEFINE BAR 17 OF raccourci PROMPT "Alignment"
DEFINE BAR 18 OF raccourci PROMPT "Preview in navigator"
DEFINE BAR 19 OF raccourci PROMPT "add line"
DEFINE BAR 20 OF raccourci PROMPT "add Date"
DEFINE BAR 21 OF raccourci PROMPT "Save AS"
DEFINE BAR 22 OF raccourci PROMPT "lineHeight"
DEFINE BAR 23 OF raccourci PROMPT "set 4 marges to 25px"
DEFINE BAR 24 OF raccourci PROMPT "insert image"
DEFINE BAR 25 OF raccourci PROMPT "SPELLCHECKER on/off"

ON BAR 1 OF raccourci ACTIVATE POPUP yquestion
ON SELECTION BAR 2 OF raccourci ;
	DO _52y1csiah
ON SELECTION BAR 3 OF raccourci ;
	DO _52y1csiai
ON SELECTION BAR 4 OF raccourci ;
	DO _52y1csiaj
ON SELECTION BAR 5 OF raccourci ;
	DO _52y1csiak
ON SELECTION BAR 6 OF raccourci ;
	DO _52y1csial
ON SELECTION BAR 7 OF raccourci ;
	DO _52y1csiam
ON SELECTION BAR 8 OF raccourci ;
	DO _52y1csian
ON SELECTION BAR 9 OF raccourci ;
	DO _52y1csiao
ON SELECTION BAR 10 OF raccourci ;
	DO _52y1csiap
ON SELECTION BAR 11 OF raccourci ;
	DO _52y1csiaq
ON SELECTION BAR 12 OF raccourci ;
	DO _52y1csiar
ON SELECTION BAR 13 OF raccourci ;
	DO _52y1csias
ON SELECTION BAR 14 OF raccourci ;
	DO _52y1csiat
ON SELECTION BAR 15 OF raccourci ;
	DO _52y1csiau
ON SELECTION BAR 16 OF raccourci run/n explorer.exe
ON BAR 17 OF raccourci ACTIVATE POPUP alignment
ON SELECTION BAR 18 OF raccourci ;
	DO _52y1csiav
ON SELECTION BAR 19 OF raccourci ;
	DO _52y1csiaw
ON SELECTION BAR 20 OF raccourci ;
	DO _52y1csiax
ON SELECTION BAR 21 OF raccourci ;
	DO _52y1csiay
ON BAR 22 OF raccourci ACTIVATE POPUP lineheight
ON SELECTION BAR 23 OF raccourci _screen.activeform.olecontrol1.document.body.style.margin = "25px"
ON SELECTION BAR 24 OF raccourci    _screen.activeform.olecontrol1.document.execCommand("InsertImage",.t.)
ON SELECTION BAR 25 OF RACCOURCI   _screen.activeform.olecontrol1.document.body.spellcheck=!_screen.activeform.olecontrol1.document.body.spellcheck

DEFINE POPUP yquestion SHORTCUT RELATIVE
DEFINE BAR 1 OF yquestion PROMPT "open"
DEFINE BAR 2 OF yquestion PROMPT "save"
ON SELECTION BAR 1 OF yquestion ;
	DO _52y1csiaz
ON SELECTION BAR 2 OF yquestion ;
	DO _52y1csib0

DEFINE POPUP alignment SHORTCUT RELATIVE
DEFINE BAR 1 OF alignment PROMPT "Left" ;
	PICTURE home(1)+"graphics\bitmaps\tlbr_w95\lft.bmp"
DEFINE BAR 2 OF alignment PROMPT "Right" ;
	PICTURE home(1)+"graphics\bitmaps\tlbr_w95\rt.bmp"
DEFINE BAR 3 OF alignment PROMPT "Center" ;
	PICTURE home(1)+"graphics\bitmaps\tlbr_w95\ctr.bmp"
ON SELECTION BAR 1 OF alignment ;
	DO _52y1csib1
ON SELECTION BAR 2 OF alignment ;
	DO _52y1csib2
ON SELECTION BAR 3 OF alignment ;
	DO _52y1csib3

DEFINE POPUP lineheight SHORTCUT RELATIVE
DEFINE BAR 1 OF lineheight PROMPT "0.7"
DEFINE BAR 2 OF lineheight PROMPT "0.8"
DEFINE BAR 3 OF lineheight PROMPT "0.9"
DEFINE BAR 4 OF lineheight PROMPT "1"
DEFINE BAR 5 OF lineheight PROMPT "1.1"
ON SELECTION BAR 1 OF lineheight  _screen.activeform.olecontrol1.document.body.style.lineHeight="0.7"
ON SELECTION BAR 2 OF lineheight  _screen.activeform.olecontrol1.document.body.style.lineHeight="0.8"
ON SELECTION BAR 3 OF lineheight  _screen.activeform.olecontrol1.document.body.style.lineHeight="0.9"
ON SELECTION BAR 4 OF lineheight  _screen.activeform.olecontrol1.document.body.style.lineHeight="1"
ON SELECTION BAR 5 OF lineheight  _screen.activeform.olecontrol1.document.body.style.lineHeight="1.1"

ACTIVATE POPUP raccourci

*
PROCEDURE _52y1csiah
*slcta
#DEFINE OLECMDID_SELECTALL 17
#DEFINE OLECMDEXECOPT_DODEFAULT 0

with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_SELECTALL , OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _52y1csiai
*copy

#DEFINE OLECMDID_COPY 12
#DEFINE OLECMDEXECOPT_DODEFAULT 0

with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_COPY , OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _52y1csiaj
*cut
#DEFINE OLECMDID_CUT 11
#DEFINE OLECMDEXECOPT_DODEFAULT 0
with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_CUT , OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _52y1csiak
*paste
#DEFINE OLECMDID_PASTE 13
#DEFINE OLECMDEXECOPT_DODEFAULT 0

with _screen.activeform.olecontrol1
.setfocus
.ExecWB(OLECMDID_PASTE, OLECMDEXECOPT_DODEFAULT)
endwith

*
PROCEDURE _52y1csial
*unddo
#DEFINE OLECMDID_UNDO 15
#define OLECMDEXECOPT_DONTPROMPTUSER 2
_screen.activeform.olecontrol1.ExecWB (OLECMDID_UNDO, OLECMDEXECOPT_DONTPROMPTUSER)



*
PROCEDURE _52y1csiam
*Redo

#DEFINE OLECMDID_REDO 16
#define OLECMDEXECOPT_DONTPROMPTUSER 2
_screen.activeform.olecontrol1.ExecWB (OLECMDID_REDO, OLECMDEXECOPT_DONTPROMPTUSER)

*
PROCEDURE _52y1csian
_screen.activeform.olecontrol1.document.execCommand("bold")

*
PROCEDURE _52y1csiao
_screen.activeform.olecontrol1.document.execCommand("italic")

*
PROCEDURE _52y1csiap
_screen.activeform.olecontrol1.document.execCommand("underLine")

*
PROCEDURE _52y1csiaq
_screen.activeform.olecontrol1.document.execCommand("delete")

*
PROCEDURE _52y1csiar
* Changeforecolor of the selected text
        local m.xforecolor
        m.xforecolor=getcolor()
        if m.xforecolor#-1
        _screen.activeform.olecontrol1.document.execCommand("Forecolor",.f.,m.xforecolor)
        endi

*
PROCEDURE _52y1csias
* Change backcolor of the selected text
        local m.xbackcolor
        m.xbackcolor=getcolor()
        if m.xbackcolor#-1
        _screen.activeform.olecontrol1.document.execCommand("Backcolor",.f.,m.xbackcolor)
        endi

*
PROCEDURE _52y1csiat
local m.xfontsize
m.xfontsize=int(val(inputbox("fontsize 8-72","","36")))

local xpoint as integer
        do case
        case xfontsize<=9
        xpoint=1
        case between(xfontsize,10,11)
        xpoint=2
        case between(xfontsize,12,18)
        xpoint=3
        case between(xfontsize,19,23)
        xpoint=4
        case between(xfontsize,24,31)  &&29
        xpoint=5
        case between(xfontsize,32,45)
        xpoint=6
        case xfontsize>=46
        xpoint=7
        endcase

        _screen.activeform.olecontrol1.document.execCommand("FontSize",.f., m.xPOINT)

*
PROCEDURE _52y1csiau
local xfont,xfontname,xfontsize,xfontstyle
        xfont=getfont("Arial",12)
        if  empty(xfont)
        return .f.
        endi

        xfontname=getwordnum(xfont,1,",")
        xfontsize=getwordnum(xfont,2,",")
        xfontsize=int(val(getwordnum(xfont,2,",")))   && Required. Integer or String that specifies the font size. This must be a value between 1 and 7, inclusive.
        xfontStyle=getwordnum(xfont,3,",")
        _screen.activeform.olecontrol1.document.execCommand("FontName",.f., xfontname)

        local xpoint as integer
        do case
        case xfontsize<=9
        xpoint=1
        case between(xfontsize,10,11)
        xpoint=2
        case between(xfontsize,12,18)
        xpoint=3
        case between(xfontsize,19,23)
        xpoint=4
        case between(xfontsize,24,31)  &&29
        xpoint=5
        case between(xfontsize,32,45)
        xpoint=6
        case xfontsize>=46
        xpoint=7
        endcase

        _screen.activeform.olecontrol1.document.execCommand("FontSize",.f., m.xPOINT)     &&attention fontsize converted ~ to  points ( 1 to 7)
        if "B" $ xfontstyle
        _screen.activeform.olecontrol1.document.execCommand("Bold",.t.)
        endi

        if "I" $ xfontstyle
        _screen.activeform.olecontrol1.document.execCommand("Italic",.t.)
        endi

*
PROCEDURE _52y1csiav
local m.x,m.lcdest
m.x="<pre><code>"+_screen.activeform.olecontrol1.document.body.innerhtml+"</code></pre>"
m.lcdest=addbs(sys(2023))+"ytemp.html"
strtofile(m.x,m.lcdest,4)

local oo
oo=newobject("hyperlink")
oo.navigateTo(m.lcdest)
oo=null

*
PROCEDURE _52y1csiaw
*add a line
try
with _screen.activeform.olecontrol1.document
x=.createElement("HR")
x.id="yl"+sys(2015)
.body.appendChild(x)
*inke(2)
*.getElementById(x.id).style.color="rgb(255,0,0)"
endwith
catch
endtry

*
PROCEDURE _52y1csiax
*!*	<p id="demo"></p>
*!*	<script>
*!*	document.getElementById("demo").innerHTML = Date();
*!*	</script>
declare integer Sleep in kernel32 integer
with _screen.activeform.olecontrol1.document
x=.createElement("p")
x.id="ydate_"+sys(2015)
.body.appendChild(x)
.getElementById(x.id).innerHTML =ttoc( DateTime())
.getElementById(x.id).style.color='ff0000'
endwith

*
PROCEDURE _52y1csiay
*_screen.activeform.olecontrol1.Document.execCommand('SaveAs',0,m.yrep+"\mypage.html ")  &&no dialog dont work

local oo,x
oo=_screen.activeform.olecontrol1.document
with oo
x=.documentElement.outerHtml
inke(1)
.open("text/html","replace")
.write(m.x)
.close()
.execCommand("saveas", .f., m.yrep+"yquestions.html")
endwith

*
PROCEDURE _52y1csiaz
try

with _screen.activeform.olecontrol1
.silent=.t.
.navigate(m.yrep+"yquestions.html")
endwith
catch
messagebox("yQuestions.html dont exits!",16+4096,"Error")
endtry

*
PROCEDURE _52y1csib0

*!*	#DEFINE OLECMDID_SAVEAS 4
*!*	#DEFINE OLECMDEXECOPT_DONTPROMPTUSER 2


*!*	local oshell
*!*	oShell=Createobject("Wscript.Shell")
*!*	_screen.activeform.olecontrol1.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DONTPROMPTUSER,m.yrep+"yQUestions.html","")
*!*	inke(1)
*!*	oShell.SendKeys("{ENTER}")
*!*	oShell=null

*_screen.activeform.olecontrol1.Document.execCommand('SaveAs',.f.,m.yrep+"yquestions.html ")  &&no dialog dont work


local oo,x
oo=_screen.activeform.olecontrol1.document
with oo
x=.documentElement.outerHtml
inke(1)
.open("text/html","replace")
.write(m.x)
.close()
.execCommand("saveas", .f., m.yrep+"yquestions.html")
endwith

*
PROCEDURE _52y1csib1
_screen.activeform.olecontrol1.document.execCommand("justifyLeft")

*
PROCEDURE _52y1csib2
_screen.activeform.olecontrol1.document.execCommand("justifyRight")

*
PROCEDURE _52y1csib3
_screen.activeform.olecontrol1.document.execCommand("justifyCenter")

endtext
strtofile(m.myvar,m.yrep+"ymenu.mpr")
*modi comm ymenu.mpr

publi yform
yform=newObject("yRtIE")
yform.show
read events
retu
*

DEFINE CLASS yRtIE AS form
Height = 551
Width = 902
ShowWindow = 2
ShowTips = .T.
AutoCenter = .T.
Caption = "A simple richtext editor tool with Internet Explorer"
BackColor = RGB(192,192,192)
zoom = 100
ynew = .F.
Name = "Form1"

ADD OBJECT olecontrol1 AS olecontrol WITH ;
oleclass="shell.explorer.2", ;
Top = 35, ;
Left = 0, ;
Height = 514, ;
Width = 902, ;
Anchor = 15, ;
Name = "Olecontrol1"

ADD OBJECT command1 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 336, ;
Height = 27, ;
Width = 48, ;
Anchor = 768, ;
Caption = "Menu", ;
Name = "Command1"

ADD OBJECT command5 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 762, ;
Height = 25, ;
Width = 56, ;
FontSize = 8, ;
Anchor = 768, ;
Caption = "Save as", ;
Name = "Command5"

ADD OBJECT command6 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 659, ;
Height = 25, ;
Width = 80, ;
FontSize = 8, ;
Anchor = 768, ;
Caption = "Preview/Print", ;
SpecialEffect = 2, ;
Name = "Command6"

ADD OBJECT command7 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 445, ;
Height = 27, ;
Width = 42, ;
Anchor = 768, ;
Caption = "Find", ;
Name = "Command7"

ADD OBJECT check1 AS checkbox WITH ;
Top = 2, ;
Left = 18, ;
Height = 25, ;
Width = 141, ;
FontBold = .T., ;
FontName = "Segoe Script", ;
FontSize = 11, ;
Anchor = 768, ;
Alignment = 0, ;
Caption = "DesignMode on", ;
Value = 1, ;
Style = 1, ;
Name = "Check1"

ADD OBJECT image1 AS image WITH ;
Anchor = 768, ;
Stretch = 2, ;
BackStyle = 0, ;
BorderStyle = 0, ;
Height = 29, ;
Left = 832, ;
MousePointer = 15, ;
Top = 0, ;
Width = 37, ;
ToolTipText = "Summary help", ;
Name = "Image1"

ADD OBJECT combo1 AS combobox WITH ;
FontBold = .T., ;
FontName = "Segoe Script", ;
FontSize = 8, ;
Anchor = 768, ;
Height = 25, ;
Left = 499, ;
MousePointer = 15, ;
Top = 2, ;
Width = 82, ;
Name = "Combo1"

ADD OBJECT combo2 AS combobox WITH ;
FontBold = .T., ;
FontName = "Segoe Script", ;
FontSize = 8, ;
Anchor = 768, ;
Height = 25, ;
Left = 588, ;
MousePointer = 15, ;
Top = 2, ;
Width = 61, ;
Name = "Combo2"

ADD OBJECT command8 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 167, ;
Height = 27, ;
Width = 86, ;
Anchor = 768, ;
Caption = "Open file", ;
Name = "Command8"

ADD OBJECT command2 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 1, ;
Left = 265, ;
Height = 27, ;
Width = 43, ;
Anchor = 768, ;
Caption = "New", ;
Name = "Command2"

PROCEDURE Destroy
clea events
ENDPROC

PROCEDURE init
_screen.windowstate=1
with this
.autocenter=.t.
.setall("specialEffect",2,"commandbutton")
.setall("mousepointer",15,"commandbutton")
.setall("fontname","Segoe Script","commandbutton")
.setall("fontbold",.t.,"commandbutton")
.refresh
endwith		
ENDPROC

PROCEDURE olecontrol1.Init
local m.myvar
text to m.myvar noshow
<body oncontextmenu="return false;">
</body>
endtext

local m.lcdest
m.lcdest=addbs(sys(2023))+"ytemp.html"
thisform.ynew=m.lcdest
strtofile(m.myvar,m.lcdest)
*modi comm (lcdest)

with this
.silent=.t.
.navigate(m.lcdest)
.document.designMode="on"
.refresh
endwith
*<!DOCTYPE html>
ENDPROC

PROCEDURE command1.Click
if file(m.yrep+"ymenu.mpr")
do (m.yrep+"ymenu.mpr")
endi
ENDPROC

PROCEDURE command5.Click
local m.x,m.y
*m.x=thisform.olecontrol1.document.body.innerhtml
*m.y=PUTFILE("choose a file to save this", "" , ".html|htm|txt")   &&|mht?
*set safe off
*strtofile(m.x,m.y)

#DEFINE OLECMDID_SAVEAS 4
#DEFINE OLECMDEXECOPT_DODEFAULT 0
thisform.olecontrol1.ExecWB(OLECMDID_SAVEAS , OLECMDEXECOPT_DODEFAULT,m.y)
ENDPROC

PROCEDURE command6.Click
*Constants for ExecWb first parameter
#DEFINE OLECMDID_PRINT 6
#DEFINE OLECMDID_PRINTPREVIEW 7

*Constants for ExecWB second parameter
#DEFINE OLECMDEXECOPT_DODEFAULT 0
#DEFINE OLECMDEXECOPT_PROMPTUSER 1
#DEFINE LECMDEXECOPT_DONTPROMPTUSER 2

*thisform.olecontrol1.Execwb(OLECMDID_PRINT  ,LECMDEXECOPT_DONTPROMPTUSER )   &&to print directly
thisform.olecontrol1.Execwb(OLECMDID_PRINTPREVIEW  ,OLECMDEXECOPT_DODEFAULT)   &&preview
ENDPROC

PROCEDURE command7.Click
thisform.olecontrol1.setfocus
oshell=newObject("wscript.shell")
oshell.sendkeys("^{f}")
oshell=null
ENDPROC

PROCEDURE check1.InteractiveChange
this.caption=iif(this.value=1,"design mode on","design mode off")
thisform.olecontrol1.document.designmode=iif(this.value=1,"on","off")
ENDPROC

PROCEDURE image1.Click
text to m.xtext noshow
this code uses the internet explorer browser (can also use application) as a richtext application.
the important point is that IE can be editable.

it have two modes for document object.
-designMode="on" && IE editable:can modify,add ,save...as all classic editor operations
-designMode="off"  &&readonly as all we see in web pages.

on : Document can be edited.
off: inherit   -Default. Document cannot be edited.

Remarks
Starting with Internet Explorer 11, the returned property values are lower case rather than capitalized.
You cannot execute script when the value of the designMode property is set to on.
can use the designMode property to put Windows Internet Explorer into a mode so that you can edit the current document.
While the browser is in design mode, objects enter a UI-activated state when the user presses ENTER, clicks
an object that has focus, or double-clicks the object. Objects that are UI-activated have their own window
in the document. You can modify the UI only when the object is in a UI-activated state.

i build some basic functions in a container , can extend to more IE capabilities.can make icons instead texts..
can use this tool to copy selected objects on web page and paste,open a file and transform it,save, print,find...
-note that open an URL makes vfp9 crashing !!(security ?)
Refrences:
https://msdn.microsoft.com/en-us/library/ms533720%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/aa753630%28v=vs.85%29.aspx
 endtext

DECLARE INTEGER MessageBox IN user32 As MessageBoxAPI;
	INTEGER hwnd,;
	STRING  lpText,;
	STRING  lpCaption,;
	INTEGER wType

*buttons
#define MB_OK 0x00000000
*Icons
#define MB_ICONINFORMATION 0x00000040
*To indicate the default button, specify one of the following values.
#define  MB_DEFBUTTON1 0x00000000
*To indicate the modality of the dialog box, specify one of the following values.
#define MB_APPLMODAL 0x00000000
MessageBoxAPI(_vfp.hwnd,m.xtext,"A simple richtext editor with IE",MB_APPLMODAL+MB_OK +MB_ICONINFORMATION +MB_DEFBUTTON1 )
ENDPROC

PROCEDURE image1.Init
local m.myvar
text to m.myvar noshow
R0lGODlhQABAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQAPAAAACwAAAAAQABAAIcAAAAAADMAAGYAAJkAAMwAAP8AKwAAKzMAK2YAK5kAK8wAK/8AVQAAVTMAVWYAVZkAVcwAVf8AgAAAgDMAgGYAgJkAgMwAgP8AqgAAqjMAqmYAqpkA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48/PmTWGEEjhhgnWy7+z8III0kkwgQTDMY2EgNUFMSs/oAEGpJYGuqidyd2uO4YXhMDGm6wOc5FIgw3EFp69IO7uKDBd6wbn+tkdK1NcUpsuzhDGMRwBvZVrYDfeMtH6IEGuUWvU9dqxzzqhA92KGkdiopX2qTY840O2ow+yACYPJAhjElQBBMvoUc98jEPH1LvKwqqmjeOphN9UEQSaHAiq+ixDGgsQyD6oEedMPYkKImIHXABUHjqBDusHMUbwlAMQ6boQ9HIqxwy1GNC9NFHD9nGiIIkiDvk0UYyBUMTiaSTy5Byrkg2hJBYEUYm2mbJ6rADGcHIVCcdMgyOILKT9FAGMXRHEZCNMiFlhAY05CjHV9rylh8JCAA7
endtext
this.pictureVal=strconv(m.myvar,14)
ENDPROC

PROCEDURE combo1.Init
with this
.additem(" GoTop")
.additem(" GoBottom")
.listindex=1
.value=1
.style=2
endwith
ENDPROC

PROCEDURE combo1.Click
local oshell
oshell=newObject("wscript.shell")
local m.stat
m.stat=0
with  this.parent.check1
if .value=1   && on
m.stat=1
.value=0      && off
.interactiveChange()
endi
endwith
thisform.olecontrol1.setfocus
do case
case this.value=1
oshell.sendkeys("{home}")
case this.value=2
oshell.sendkeys("{end}")
endcase

ENDPROC

PROCEDURE combo2.Click
local oshell
oshell=newObject("wscript.shell")
thisform.olecontrol1.setfocus

	   #define OLECMDID_OPTICAL_ZOOM 63
	   #define OLECMDEXECOPT_DODEFAULT 0
do case
			case this.value=1
		thisform.zoom=thisform.zoom+10
		thisform.olecontrol1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, thisform.zoom, Null)
		wait window (trans(thisform.zoom)+" %") timeout 1

		case this.value=2
		#DEFINE OLECMDEXECOPT_DONTPROMPTUSER 2
		thisform.zoom=thisform.zoom-10
		thisform.olecontrol1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, thisform.zoom, Null)
		wait window (trans(thisform.zoom)+" %") timeout 1

		case this.value=3  &&100% zoom
		thisform.zoom=100
		thisform.olecontrol1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, thisform.zoom, Null)
		wait window (trans(thisform.zoom)+" %") timeout 1
		endcase
ENDPROC

PROCEDURE combo2.Init
with this
.additem("Zoom +")
.additem("Zoom -")
.additem("Zoom 100%")
.listindex=1
.style=2
.value=1
endwith
ENDPROC

PROCEDURE command8.Click
thisform.olecontrol1.setfocus
oshell=newObject("wscript.shell")
oshell.sendkeys("^{o}")
oshell=null
ENDPROC

PROCEDURE command2.Click
with thisform.olecontrol1
.navigate(thisform.ynew)
.document.designMode="on"
.refresh
endwith
ENDPROC

ENDDEFINE
*
*-- EndDefine: yRtIE



the spellchecker must be enabled in windows settings. (https://answers.microsoft.com/en-us/ie/forum/ie11-iewindows_10/spelling-correction-and-checking-in-internet/a1321c59-3623-49a2-8fce-388ecc2cb057)
the spellchecker must be enabled in windows settings. (https://answers.microsoft.com/en-us/ie/forum/ie11-iewindows_10/spelling-correction-and-checking-in-internet/a1321c59-3623-49a2-8fce-388ecc2cb057)

the spellchecker must be enabled in windows settings. (https://answers.microsoft.com/en-us/ie/forum/ie11-iewindows_10/spelling-correction-and-checking-in-internet/a1321c59-3623-49a2-8fce-388ecc2cb057)

Click on code to select [then copy] -click outside to deselect

*4* created on tuesdy 01 of may 2018
*this code is a simple dayly reminder to install with windows scheduler.it can be start at PC start,after period of inactivity....
*any user have 4-5 tasks to do daily and this code uses IE browser to set/modify these tasks easily.it use the designmode=off/on property only to make IE editable or natif.
*a text file is also under hand to set other non urgent tasks to do by user.
*add 2 images (title and right image) as your custom taste (or download them from below).
*build a proj (add a config.fpw to the prg) and compile an exe (~32ko) and set on the window scheduler (must have a compte+login) to run as you want.

if !_vfp.startmode=0
on shutdown quit
endi

publi m.yrep
m.yrep=addbs(justpath(sys(16,1)))
set defa to (yrep)

PUBLIC oform
oform=NEWOBJECT("yMemoDay")
oform.Show
read events
RETURN
*
DEFINE CLASS yMemoDay AS form
	BorderStyle = 0
	Height = 586
	Width = 1260
	ShowWindow = 2
	AutoCenter = .T.
	Caption = ("yMemoDay"+spac(10)+ttoc(dateTime()))
	icon="schedule.ico"
	ycl = 0
	yzoom = 1
	Name = "Form1"

	ADD OBJECT olecontrol1 AS olecontrol WITH ;
	    oleclass="shell.explorer.2",;
		Top = 0, ;
		Left = 0, ;
		Height = 540, ;
		Width = 1260, ;
		Anchor = 15, ;
		Name = "Olecontrol1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 552, ;
		Left = 432, ;
		Height = 27, ;
		Width = 144, ;
		FontSize = 14, ;
		Anchor = 768, ;
		Caption = "Edit  On/Off", ;
		MousePointer = 15, ;
		SpecialEffect = 2, ;
		BackColor = RGB(255,0,0), ;
		Name = "Command1"

	ADD OBJECT image1 AS image WITH ;
		Picture =home(1)+"graphics\bitmaps\outline\plus.bmp", ;
		Stretch = 2, ;
		BackStyle = 0, ;
		Height = 32, ;
		Left = 132, ;
		MousePointer = 15, ;
		Top = 552, ;
		Width = 32, ;
		Name = "Image1"

	ADD OBJECT image2 AS image WITH ;
		Picture =home(1)+"graphics\bitmaps\outline\minus.bmp", ;
		Stretch = 2, ;
		BackStyle = 0, ;
		Height = 32, ;
		Left = 186, ;
		MousePointer = 15, ;
		Top = 552, ;
		Width = 32, ;
		Name = "Image2"

	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 552, ;
		Left = 648, ;
		Height = 25, ;
		Width = 97, ;
		FontBold = .T., ;
		Caption = "Save..", ;
		MousePointer = 15, ;
		BackColor = RGB(0,255,0), ;
		Name = "Command2"

	ADD OBJECT label1 AS label WITH ;
		FontBold = .T., ;
		FontName = "Impact", ;
		FontSize = 24, ;
		Alignment = 2, ;
		BackStyle = 0, ;
		Caption = "", ;
		Height = 49, ;
		Left = 780, ;
		Top = 540, ;
		Width = 468, ;
		ForeColor = RGB(255,0,0), ;
		Name = "Label1"

	ADD OBJECT image3 AS image WITH ;
		Picture =home(1)+"graphics\icons\win95\openfold.ico", ;
		Height = 32, ;
		Left = 12, ;
		MousePointer = 15, ;
		Top = 551, ;
		Width = 32, ;
		Name = "Image3"

	PROCEDURE Init
		if !file("ymemoDay.htm")
		local m.x
		text to m.x textmerge noshow
		<style>
		h1{margin-left:50px;color:maroon;}
		 ul {list-style-type: circle;}
		.ydiv {
		    color: navy;
		    font-size:36px;
		    font-bold:bold;
		    line-height:1.3;
		    font-family:Impact;
		    text-indent: 0px;
		    text-align: left;
		    }
		
		</style>
		<META HTTP-EQUIV="Content-Type"     CONTENT="text/html; charset=windows-1252">
		<meta http-equiv="x-ua-compatible" content="ie=edge" />
		</HEAD>
		<BODY scroll="no" style="-ms-zoom: 1.2;" oncontextmenu="return false;">
		<table>
		<tr><td width="800"><CENTER><img src="ymemoday.png"></center></td>
		<td><IMG  src="bug.png" width="100" height="100" style="float: right;"> </td>

		</tr></table>
		<div class="ydiv" id="yb">
		<ul><li>
		*1
		</li></ul>
		</div>
		endtext
		strtofile(m.x,m.yrep+"ymemoDay.htm")
		endi
		thisform.olecontrol1.navigate(m.yrep+"ymemoDay.htm")
	ENDPROC

	PROCEDURE Destroy
		m.yrep=null
		release m.yrep
		clea events
	ENDPROC

	PROCEDURE olecontrol1.Init
		this.silent=.t.
	ENDPROC

	PROCEDURE command1.Click
		thisform.ycl=iif(thisform.ycl=0,1,0)
		this.backcolor=iif(thisform.ycl=1,rgb(0,255,0),255)

		if thisform.ycl=1
		thisform.olecontrol1.document.designmode="on"
		else
		thisform.olecontrol1.document.designmode="off"
		endi
	ENDPROC

	PROCEDURE image1.Click
		with thisform.olecontrol1.document.body.style
		.zoom=thisform.yzoom+0.1
		thisform.yzoom=thisform.yzoom+0.1
		endwith
	ENDPROC

	PROCEDURE image2.Click
		with thisform.olecontrol1.document.body.style
		.zoom=thisform.yzoom-0.1
		thisform.yzoom=thisform.yzoom-0.1
		endwith
	ENDPROC

	PROCEDURE command2.Click
		set defa to (yrep)
		thisform.olecontrol1.Document.designmode="off"
		*thisform.olecontrol1.Document.execCommand('SaveAs',.f.,m.yrep+"ymemoDay.htm")
		local m.oo,m.x
		m.oo=thisform.olecontrol1.document
		with m.oo
		m.x=.documentElement.outerHtml
		inke(1)
		strtofile(m.x,m.yrep+"ymemoDay.htm")
		messagebox("Saved",0+32+4096,'',1300)
		endwith
	ENDPROC

	PROCEDURE label1.Init
		set date french
		set date long
		local m.x
		m.x=strtran(ttoc(dateTime()),";","")
		this.caption= substr(m.x,1,len(m.x)-3)
	ENDPROC

	PROCEDURE image3.Click
		if file("others.txt")
		run/n notepad others.txt
		endi
	ENDPROC

ENDDEFINE
*
*-- EndDefine: yMemoDay


can download the 2 last images to use in code or make yours.
can download the 2 last images to use in code or make yours.
can download the 2 last images to use in code or make yours.

can download the 2 last images to use in code or make yours.

To be informed of the latest articles, subscribe:
Comment on this post