Problem with GUI and ActiveX sizing

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Problem with GUI and ActiveX sizing

03 Nov 2020, 10:02

hi guys, this script I found gathers images from the folder and shows them in the script. Everything works fine except the sizing. It looks like everything should be OK, but the script still shows me AcitveX control almost half of the Gui size, while I want to see it in the whole Gui. I cannot find where the problem is. Maybe you have any ideas?

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
Attachments
phtevenError.png
phtevenError.png (272.27 KiB) Viewed 545 times
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Problem with GUI and ActiveX sizing

03 Nov 2020, 11:07

I have no idea how classes work and so will claim ignorance here, but my question is whether you need to pass this to newImage.
User avatar
F4Jonatas
Posts: 45
Joined: 22 Oct 2015, 06:35
Contact:

Re: Problem with GUI and ActiveX sizing

03 Nov 2020, 11:32

Tell us the version of your ahk and pc!?

For me it worked the way you expected...


--------------------------------------------------------------------------
I made small changes. But I think that may be it.
Tell me if it helped you!

Code: Select all

#NoEnv
#SingleInstance Force
#Warn, all, stdout
#ErrorStdOut
#Persistent


SetBatchLines, -1
SetWorkingDir, % A_ScriptDir


imageExt  := "jpg,bmp,gif,png"
guiName := 1
width := 800
height := 500
main      := new imageDisplay( guiName, width, height ) ; creates a gui w800 h500
imageList := Array()

Gui %guiName%: Color, 0x333333
Gui %guiName%: Show,  w%width% h%height%

Loop, % "C:\Users\" A_UserName "\Pictures\*.*",, 1
{	If A_LoopFileExt not in %imageExt%
		continue

	main.newImage( A_LoopFileFullPath, A_Index, "Name" )
	imageList.push( A_LoopFileFullPath )
	fileappend, % 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 - 20
		imgList.getElementsByTagName("div")[0].style.width 						:= width - 20
		imgList.close()

		this.var 				:= imgList
	}

	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
Last edited by F4Jonatas on 03 Nov 2020, 11:47, edited 2 times in total.
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: Problem with GUI and ActiveX sizing

03 Nov 2020, 11:37

AHK version: 1.1.26.01
PC: Win10 64Bit

Edit: Checked on my other computer, which has 100% as text and apps size, and it works well. The main one has 150% as text and apps size, so maybe that's the issue..
User avatar
F4Jonatas
Posts: 45
Joined: 22 Oct 2015, 06:35
Contact:

Re: Problem with GUI and ActiveX sizing

03 Nov 2020, 11:56

Therefore, there may be some pre-configuration of iexplorer.
Let's clear these doubts: rotate the scritp and hold the control and rotate the mouse in the middle, to change the page zoom
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: Problem with GUI and ActiveX sizing

04 Nov 2020, 02:40

F4Jonatas wrote:
03 Nov 2020, 11:56
Therefore, there may be some pre-configuration of iexplorer.
Let's clear these doubts: rotate the scritp and hold the control and rotate the mouse in the middle, to change the page zoom
the previous version, you have added, do not solve the problem, the sizing is still a problem. But YES, if I hold the window and rotate mouse middle, it changes it sizes, and I can enlarge it to fit well. Is it possible do a trick with a script in such scenario?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Lpanatt, macromint, peter_ahk, Spawnova and 266 guests