Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to execute html from my app
Message
From
05/04/2019 12:10:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/04/2019 11:31:57
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01667980
Message ID:
01667983
Views:
52
Now I am at a lost. Here is a sample using HTML inside a VFP form:
Local lcHTML
lcHTML = Forcepath('Sample.html', Sys(2023))
If !Directory(ForcePath('images',Sys(2023)))
  Md (ForcePath('images',Sys(2023)))
endif
If !File(m.lcHTML)
	Strtofile( GetSampleHTML(), m.lcHTML)
Endif

Public o
o = Createobject('MyHTMLViewer', m.lcHTML)
o.Show

Define Class MyHTMLViewer As Form
	Caption = "HTML sample"
	Height = 768
	Width = 1024

	Add Object htmlviewer As OleControl With ;
		anchor = 15, Left=216, Top=43, Height=685, Width = 793, OleClass = 'Shell.Explorer'

	Procedure Init
		Lparameters tcHTML
		With Thisform.htmlviewer
			.Navigate2(m.tcHTML)
		Endwith
	Endproc

	Procedure htmlviewer.Refresh
		Nodefault
	Endproc

	Procedure htmlviewer.BeforeNavigate2
		Lparameters pdisp, url, Flags, targetframename, postdata, headers, Cancel
		If Atc('#',m.url) > 0
			Local lcVals, lcCurrentValue
			*  oFrm = This.Object.Document.myForm
			lcVals = m.url + Chr(13)+Chr(10)
			If This.Object.Document.Forms.Length > 0
				For Each oFrm In This.Object.Document.Forms
					lcVals = lcVals + oFrm.Name + Chr(13)
					If oFrm.elements.Length > 0
						For Each oElem In oFrm.elements
							If !Empty(oElem.Name)
								If oElem.Type = "select-multiple"
									lcList=''
									For ix=0 To oElem.Length-1
										If oElem.Item(ix).Selected
											lcList = lcList + Iif(Empty(lcList),'',',')+oElem.Item(ix).Value
										Endif
									Endfor
									m.lcCurrentValue = m.lcList
								Else
									m.lcCurrentValue = oElem.Value
								Endif
								lcVals = lcVals + Textmerge("<< oElem.Name >>: << m.lcCurrentValue >> << Chr(13) + Chr(10) >>")
								oElem = .Null.
							Endif
						Endfor
					Endif
					oFrm = .Null.
				Endfor
			Endif
			Cancel = .T.  && prevents actual navigation
			Messagebox(m.lcVals)
		Endif
	Endproc
Enddefine


Procedure GetSampleHTML
	Local lcCarouselImages, lcMyHtml
	Set Textmerge To Memvar m.lcCarouselImages On Noshow
	For ix=1 To Adir(laImages, _samples+'data\graphics\*.*')
	Copy File (_samples+'data\graphics\'+laImages[m.ix,1]) to ForcePath(laImages[m.ix,1],Addbs(Sys(2023))+'images')
	\<a class="carousel-item" href="#<< chrtran(JustFname(laImages[m.ix,1]),'.','_') >>">
    \\<img src="images/<< JustFname(laImages[m.ix,1]) >>"/></a>
	Endfor
	Set Textmerge To
	Set Textmerge Off

	TEXT to m.lcMyHtml textmerge noshow
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <!--Import Google Icon Font-->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <!--Import materialize.css-->
    <!-- Compiled and minified CSS -->
    <link type="text/css" rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"
          media="screen,projection"/>
    <!--Let browser know website is optimized for mobile-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Materialize Sandbox</title>
 </head>
<body>

<div>
    <div class="row">
    <form action="" method="POST" name="MyForm">
        <div class="col s6">
            <input type="text" class="datepicker" placeholder="Start date" name="fromDate">
        </div>
        <div class="col s6">
            <input type="text" class="timepicker" placeholder="Time" name="fromTime">
        </div>
        <div class="col s6">
            <input type="text" class="datepicker" placeholder="End date" name="toDate">
        </div>
        <div class="col s6">
            <input type="text" class="timepicker" placeholder="Time" name="toTime">
        </div>
        <a href="#runItem"
           class="btn-floating btn-small green darken-1 waves-effect waves-light tooltipped"
           data-position="top" data-tooltip="Run report">
           <i class="material-icons">play_arrow</i>
        </a>

    </form>
    <div class="carousel">
        << m.lcCarouselImages >>
    </div>
    </div>
</div>
<!--JavaScript at end of body for optimized loading-->
<!-- Compiled and minified JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript"
        src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
<script>
    $(document).ready(function () {
        $('.tooltipped').tooltip();
        $('.carousel').carousel();
        $('.datepicker').datepicker({format: 'mm/dd/yyyy'});
        $('.timepicker').timepicker({twelveHour: false});
    });
</script>
</html>
	ENDTEXT
	Return m.lcMyHtml
Endproc
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform