Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shell.explorer.2 create document from variable
Message
From
28/06/2018 14:56:19
 
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Web
Miscellaneous
Thread ID:
01660900
Message ID:
01660941
Views:
303
*you can use navigate() method to access to the document object with any url even "about:blank"
*with "about:blank" can set 1 second or two to trap the document object (in principe its a loop on readystate event but with "about:blank its quasi instantaneous...)
*then you can use document methods as (open, write and close to modify the document and show the rendered string  interactively).
*you can use html strings as you said in memo files and restore them as their real rendered tags on the browser).
*to access to controls or any document child you can use the meethod: thisform.olecontrol1.document.getElementById,..getElementsbyclassName,... byname...... google to see help in web
*i used here a cursor fill from a vfp demo tables.

sys(2002)
PUBLIC oform
oform=NEWOBJECT("yHtmlViewer")
oform.Show
read events
RETURN

DEFINE CLASS yHtmlViewer AS form
	Height = 455
	Width = 816
	ShowWindow = 2
	AutoCenter = .T.
	Caption = ""
	Name = "form1"

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

	ADD OBJECT ylab1 AS label WITH ;
		AutoSize = .T., ;
		FontName = "Webdings", ;
		FontSize = 24, ;
		Anchor = 768, ;
		BackStyle = 0, ;
		Caption = "3", ;
		Height = 35, ;
		Left = 368, ;
		Top = 421, ;
		Width = 34, ;
		mousepointer=15,;
		ForeColor = RGB(128,0,64), ;
		Name = "yLab1"

	ADD OBJECT ylab2 AS label WITH ;
		AutoSize = .T., ;
		FontName = "Webdings", ;
		FontSize = 24, ;
		Anchor = 768, ;
		BackStyle = 0, ;
		Caption = "4", ;
		Height = 35, ;
		Left = 418, ;
		Top = 421, ;
		Width = 34, ;
                mousepointer=15,;
		ForeColor = RGB(128,0,64), ;
		Name = "yLab2"

	PROCEDURE ybuild
		lparameters xrec
		sele ycurs
		go xrec
		local m.xdesc
		m.xdesc=desc
		local gnbre,nr,xico   &&add some random bitmaps in headers just for folks
		gnbre=adir(gabase,home(1)+"graphics\bitmaps\tlbr_w95\*.bmp")

		m.nr=INT((gnbre) * RAND() +1)
		m.xico=home(1)+"graphics\bitmaps\tlbr_w95\"+gabase(m.nr,1) 
m.xdesc=[<body oncontextmenu='return false;' ><p style="font-size:48px;color:red;style="float:left;">]+trans(xrec)+[<img src="file:///]+m.xico+[" width='48'  height='48' style='float:right;' > </p><br><br><br><br>]+m.xdesc+chr(13)

		thisform.olecontrol1.navigate("about:blank")
		inke(1)  &&transitionning (to dont write more code waiting readystate...)
		with thisform.olecontrol1.document  &&here can access to the document object.
		.open()
		.write(m.xdesc)
		.close()
		endwith
	ENDPROC

	PROCEDURE Init
		thisform.ylab1.click()
	ENDPROC

	PROCEDURE Load
		crea cursor ycurs (Desc m)
		appe from  "c:\program files (x86)\microsoft visual foxpro 9\samples\solution\europa\winevents.dbf"  
		*brow
		locate
	ENDPROC

	PROCEDURE Destroy
		clea events
	ENDPROC

	PROCEDURE olecontrol1.Refresh
		nodefault
	ENDPROC

	PROCEDURE ylab1.Click
		sele ycurs
		try
		skip-1
		thisform.ybuild(recno())
		catch
		locate
		thisform.ybuild(recno())
		endtry
	ENDPROC

	PROCEDURE ylab2.Click
		sele ycurs
		try
		skip
		thisform.ybuild(recno())
		catch
		locate
		thisform.ybuild(recno())
		endtry
	ENDPROC

ENDDEFINE
*
*-- EndDefine: yHtmlViewer
update:
two general method can use :
1.
text to m.myvar [textmerge ) noshow
.......all html codes and even scripts here
endtext
2.can use strtofile to build a disc web file
3.navigate to this web file with the browser.

the second method as i pointed is to use navigate("about:blank") and write to the document the source of the web file want to build(no disc web file recquired here).
Previous
Reply
Map
View

Click here to load this message in the networking platform