Code: Select all
imageExt := "jpg,bmp,gif,png"
main := new imageDisplay(1, 800, 500) ; creates a gui w800 h500
imageList := Object()
Gui, Color, 0x333333
Gui, Show, autosize
Loop, C:\Users\Pictures\*.*,, 1
{ If A_LoopFileExt not in %imageExt%
continue
main.newImage( A_LoopFileFullPath, A_Index, "Name" )
imageList[ A_Index ] := A_LoopFileFullPath
}
Return
Class imageDisplay
{
__New( guiNumber, width, height, imageWidth=190, imageHeight=190, eventName="evnt_" )
{
static imgList
this.width := width
this.height := height
this.imageWidth := imageWidth
this.imageHeight := imageHeight
Gui, %guiNumber%: Add, ActiveX, w%width% h%height% vimgList, MSHTML:
html =
(
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
img:hover { background-color: #444444; }
</style>
</head>
<body>
<div id="imgCont">
</div>
</body>
</html>
)
imglist.write( html )
ComObjConnect(imgList, eventName )
imglist.getElementsByTagName("body")[0].style.backgroundColor := "333333"
imglist.getElementsByTagName("div")[0].style.overflow := "auto"
imgList.getElementsByTagName("div")[0].style.height := height - 10
imgList.getElementsByTagName("div")[0].style.width := width - 10
imgList.close()
this.var := imgList
return this
}
newImage( imageDir, imageID, imageText )
{
element := this.var.createElement( "img" )
element.src := imageDir
element.Id := imageID
element.style.width := this.imageWidth
element.style.height := this.imageHeight
element.style.padding := this.imageSpace ? this.imageSpace : "5px"
this.var.getElementById( "imgCont" ).appendChild( element )
}
}
evnt_OndblClick( p* )
{
global activeImage
elm := p[1].parentWindow.event.srcElement.Id
activeImage := p[1].getElementById(elm).Id
SetTimer, OnClick, -1
}
evnt_OnClick( p* )
{
global prevImage, backgroundColor
prevImage.style.backgroundColor := backgroundColor
elm := p[1].parentWindow.event.srcElement.Id
If elm is not digit
Return
image := p[1].getElementById(elm)
image.style.backgroundColor := "FFFFFF"
prevImage := image
}
OnClick:
imageDir := imageList[ activeImage ]
MsgBox, % imageDir
Return