A web slider with CSS & IE evenHandler

Published on by Yousfi Benameur

 
In this link we spoke about the IE eventhandler from vfp form
http://yousfi.over-blog.com/2015/02/vfp-and-internet-explorer-eventhandler.html
The first below code creates a prg class named yeventHandler.prg to trapp events on internet explorer browser.you can extend its capabilities to all the procedures described in the class codethis class is dragged from the vfp object browser.

we create a slider on vfp form as fullscreen  but cannot close it (out of ALT+F4 keys or javascript function.)
then we associate a eventhandler class to do it in particular.

*Page style updated on 21 september 2015 11:31 (to avoid problem of editor) 


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


 *Begin code
Set Defa To Addbs(Justpath(Sys(16,1)))

Set Safe Off

Local m.yevh
TEXT to m.yevh noshow
*class---code dragged from vfp object browser and renaming

Define Class HtmlDocumentEvents As Session OlePublic
Implements HTMLElementEvents In MSHTML.TLB &&"C:\WINDOWS\SYSTEM32\MSHTML.TLB"

Procedure HTMLElementEvents_onhelp() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onclick() As LOGICAL
* add user code here
*this.ylog("documentked !"+chr(13)+"called from:"+program())
oDOc.focus()
Endproc

Procedure HTMLElementEvents_ondblclick() As LOGICAL
* add user code here
*this.ylog("documentlicked !"+chr(13)+"called from:"+program())
oDOc.focus()
Endproc

Procedure HTMLElementEvents_onkeypress() As LOGICAL
* add user code here
Declare Integer GetAsyncKeyState In user32 Integer vKey
x=""
For i=1 To 255
If GetAsyncKeyState(i)#0
x="Key "+(Trans(i)+" "+Chr(i)+" pressed")+Chr(13) &&last pressed only
If i=27
If Messagebox("Want really to quit ?",4+64+4096,"Fom visual foxro")=6
_Screen.ActiveForm.Release
Endi
Endi
Endi
Endfor
*this.ylog(x+chr(13)+"called:"+program())

oDOc.focus()
Endproc

Procedure HTMLElementEvents_onkeydown() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onkeyup() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onmouseout() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onmouseover() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onmousemove() As VOID
* add user code here
Endproc
Procedure HTMLElementEvents_onmousedown() As VOID
* add user code here
Endproc
Procedure HTMLElementEvents_onmouseup() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onselectstart() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onfilterchange() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_ondragstart() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onbeforeupdate() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onafterupdate() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onerrorupdate() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onrowexit() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onrowenter() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_ondatasetchanged() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_ondataavailable() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_ondatasetcomplete() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onlosecapture() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onpropertychange() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onscroll() As VOID

* add user code here
Endproc

Procedure HTMLElementEvents_onfocus() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onblur() As VOID

* add user code here
Endproc

Procedure HTMLElementEvents_onresize() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_ondrag() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_ondragend() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_ondragenter() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_ondragover() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_ondragleave() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_ondrop() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onbeforecut() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_oncut() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onbeforecopy() As LOGICAL
* add user code here
This.ylog("Ctrl+Csed----want to copy selection"+Chr(13)+"called from:"+Program() )
oDOc.focus()
Endproc

Procedure HTMLElementEvents_oncopy() As LOGICAL
* add user code here

Endproc

Procedure HTMLElementEvents_onbeforepaste() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onpaste() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_oncontextmenu() As LOGICAL
* add user code here
messagebox("Sorry the rightclic is disabled by me ! ",16+4096,"From visual foxpro",1000)
Return .F.
Endproc

Procedure HTMLElementEvents_onrowsdelete() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onrowsinserted() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_oncellchange() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onreadystatechange() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onbeforeeditfocus() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onlayoutcomplete() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onpage() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onbeforedeactivate() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onbeforeactivate() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onmove() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_oncontrolselect() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onmovestart() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onmoveend() As VOID

* add user code here
Endproc

Procedure HTMLElementEvents_onresizestart() As LOGICAL
* add user code here
Endproc

Procedure HTMLElementEvents_onresizeend() As VOID
* add user code here
*this.ylog("documentzed !"+chr(13)+"called from:"+program())
oDOc.focus()
Endproc

Procedure HTMLElementEvents_onmouseenter() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onmouseleave() As VOID
* add user code here
Endproc

Procedure HTMLElementEvents_onmousewheel() As LOGICAL
* add user code here

Endproc

Procedure HTMLElementEvents_onactivate() As VOID
* add user code here

Endproc

Procedure HTMLElementEvents_ondeactivate() As VOID
* add user code here

Endproc

Procedure HTMLElementEvents_onfocusin() As VOID
* add user code here

Endproc

Procedure HTMLElementEvents_onfocusout() As VOID
* add user code here
Endproc

Enddefine

ENDTEXT
Strtofile(m.yevh, "yeventhandler.prg")



*This code creates a form with the browser as olecontrol.

*point to any images folder and go.
*the images gathered are limited to 42 maximum and with image size>=350x250 ones.(Can change)
*i made it as a fullscreen and you can give the focus by click for ex. and issue ESC (whose is trapped by evenhandler) to quit (you dont have any another way to quit with the fullscreen set).

*The page of the author of this slider(css):http://codepen.io/codeodin/full/LcneK/

Publi yform
yform=Newobject("yslider42")
yform.Show
Read Events
Retu
*
Define Class yslider42 As Form
    Top = 74
	Left = 165
	Height = 424
	Width = 681
	ShowWindow = 2
	Caption = "yWeb_slider42 images- ESC to quit"
	Name = "Form1"

	Add Object olecontrol1 As OleControl With ;
		oleclass="shell.explorer.2", ;
		Top = 0, ;
		Left = 0, ;
		Height = 433, ;
		Width = 685, ;
		Anchor = 15, ;
		Name = "Olecontrol1"

	Procedure zbuild
	Sele ycurs
	Local m.oo,m.xx
	m.oo=""
	Scan For !Deleted()
		TEXT to m.xx textmerge noshow
<a href="#">
<img class="thumb" src="<<allt(yimage)>>" width="60" height="60">
<img class="big" src="<<allt(yimage)>>" width="950" height="400">
</a>
		ENDTEXT

		m.oo=m.oo+m.xx+Chr(13)
	Endscan
	Local m.myvar
	TEXT to m.myvar textmerge noshow
<style>
/*GENERAL*/

* {
margin: 0px;
padding: 0px;
}

body {
background: url(bkg.png);
background-color: #000000;
}

/*SLIDER*/
.container {
position: relative;
height: 660px;
width: 1000px;
overflow: hidden;
margin: 0 auto;
}

.big {
position: absolute;
top:900px;
left:20px;

-webkit-transition: top 1s ease;
-moz-transition: top 1s ease;
-o-transition: top 1s ease;
-ms-transition: top 1s ease;
transition: top 1s ease;
}
a {
float: left;
margin: 5px;
}

a:hover .thumb {
-webkit-box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
-moz-box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
}

a:hover .big {
top: 260px;
}

</style>

<body oncontextmenu="return false;">
<div class="container" >
<<m.oo>>
<center>
<div style="top:450;width:950 ;height:400; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 36pt; color: #fff;">
<br><br><br><BR><br><BR><br>
Hover over any thumbnail.<br>
Press ESC to quit
</div>
</center>
</div>
</body>
	ENDTEXT
	Local m.lcdest
	m.lcdest=Addbs(Sys(2023))+"yslider3.html"
	Strtofile(m.myvar, m.lcdest)
	With Thisform.olecontrol1
		.silent=.T.
		.Navigate(m.lcdest)
	Endwith
	Inkey(3)

	Publi oDOc
	oDOc=Thisform.olecontrol1.Document
	&&set the events hook
	oEv = Newobject("HTMLDocumentEvents","yeventhandler.prg")
	Eventhandler(oDOc,oEv)
	Endproc

	Procedure Destroy
	Dele File Addbs(Sys(2023))+"zfeatured.png"
	Dele File Addbs(Sys(2023))+"yslider3.html"
	Close Data All
	Set Defa To Addbs(Justpath(Sys(16,1)))
	Set Safe On
	Clea Events
	Endproc

	Procedure Init

	Close Data All



	Local m.yrep
	m.yrep=Getdir()
	If Empty(m.yrep)
		Return .F.
	Endi
	m.yrep=Addbs(m.yrep)
	gnbre=Adir(gabase,m.yrep+"*.*")
	Create Cursor ycurs (yimage c(150))
	Local m.zz
	For i=1 To gnbre
		m.zz=Newobject("image")
		m.zz.Picture=m.yrep+gabase(i,1)
		If m.zz.Width>300   And  m.zz.Height>250   &&choose some big images at least 300pxx250px
			If Inlist(Lower(Justext(gabase(i,1))),"png","jpg","bmp","gif")
				Insert Into ycurs Values(m.yrep+gabase(i,1) )
			Endi
		Endi
		m.oo=Null
	Endfor
	Sele ycurs
	Try
		Dele All For Recno()>42 &&capacity max 42 first photos only
	Catch
	Endtry

	With Thisform
		.TitleBar=0
		.Left=-10
		.Top=-10
		.Width=Sysmetric(1)+10
		.Height=Sysmetric(2)+40
	Endwith
	Thisform.zbuild()
	Endproc

Enddefine
*
*end code



A  web slider with CSS &amp; IE evenHandler
A  web slider with CSS &amp; IE evenHandler
A  web slider with CSS &amp; IE evenHandler
A  web slider with CSS &amp; IE evenHandler
A  web slider with CSS &amp; IE evenHandler
To be informed of the latest articles, subscribe:
Comment on this post