Correct Size and Operation Question.

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Hellbent
Posts: 1195
Joined: 23 Sep 2017, 13:34

Correct Size and Operation Question.

Post by Hellbent » 21 Jan 2021, 03:47

I am a few days in to working on a new version of a graphics drawing program I made about 2 years ago.
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=62550

I am currently doing work on creating the main interface and have made it build out the layout of the window based on YOUR screen size. Problem is that MY screen size isn't YOUR screen size so I can't really be sure that it is spacing the layout of the window correctly without at least one person with a screen resolution other than ( 1366 * 740 ) to test it for me... Sucks to be me right now.

Anyways, when you run this you should see a center screen that has about 70ish pixels on the Left and Top side and about 10px on the Right and bottom side (The padding on the right and bottom aren't really important as long as there is some it's all good).

You should also see two slider looking things running along the top and down the left side. Scroll both to their max and you should see a small square outline in every corner. The squares should be exactly in the 4 corners, if there is any space it is a issue.

I think that about covers it. If you test for me please let me know your window resolution.

Thanks!!

Note: The window currently sizes itself based on your primary monitor, if you have a second monitor that is larger than your primary one the padding on the Right and bottom side will be larger, but that is expected, I might (aka never) make it resize everything every time you snap the window to the top.
Likewise, if your second monitor is smaller than your first, the padding will disappear and part of the top slider will be outside the screen. Once again that is to be expected.

Code: Select all

#SingleInstance, Force
SetBatchLines, -1

Main.Startup()

return
GuiClose:
GuiContextMenu:
*ESC:: 
	ExitApp


Class Main	{
	StartUp(){
		
		;~ This.pToken := GDIP_STARTUP()
		MainWindow.SetUp()
		InnerWindow1.SetUp()
		InnerWindow2.SetUp()
		This.Bitmap := New BitmapWindow() ; for testing only
		
	}
	
}

Class NewProjectWindow	{
	SetUp(){
		
	}
	
}

Class BitmapWindow	{
	__New(){
		This._CreateWindow()
	}
	_CreateWindow(){
		; just temp for testing
		Gui, 4: +Parent3 -DPIScale
		Gui, 4: Color, teal
		Gui, 4: Add, Button, x100 y100  -Theme hwndhwnd, Not a Real Button 
		Gui, 4: Show, x300 y200 w500 h300, bitmap window 
		bd := This.Click.Bind(This)
		GuiControl, 4: +G, % hwnd, % bd
	}
	Click(){
		SoundBeep, 500
		ToolTip, Just kidding
		sleep, 1000
		ToolTip,
	}
}

Class InnerWindow2	{
	SetUp(){  ; This is the layer that the bitmaps are drawn on.
		This._CreateInnerWindow2()
		
	}
	_CreateInnerWindow2(){
			;Set the gui name
		This.Name := 3
		
		This.WindowSize := {}
		This.WindowSize.X1 := 0
		This.WindowSize.Y1 := 0
		
		This.WindowSize.X2 := 3000
		This.WindowSize.Y2 := 3000
		
		This.WindowSize.W := This.WindowSize.X2 - This.WindowSize.X1
		This.WindowSize.H := This.WindowSize.Y2 - This.WindowSize.Y1
		
			;Create the gui window
		Gui , % This.Name ": New" , % "+Parent2 -Caption -DPIScale "
			;Set the background color for the main window
		Gui , % This.Name ": Color" , 30373F
			;Show the window 
		Gui , % This.Name ": Show" , % "x" This.WindowSize.X1 " y" This.WindowSize.Y1 " w" This.WindowSize.W " h" This.WindowSize.H
		
		
		Gui , % This.Name ":Add" , Text, x0 y2900 w100 h100 Border
		Gui , % This.Name ":Add" , Text, x2900 y0 w100 h100 Border
		Gui , % This.Name ":Add" , Text, x2900 y2900 w100 h100 Border
		Gui , % This.Name ":Add" , Text, x0 y0 w100 h100 Border
		
	}
}

Class InnerWindow1	{
	Setup(){
		This._CreateInnerWindow1()
	}
	_CreateInnerWindow1(){
			;Set the gui name
		This.Name := 2
			;Get the work area for the main monitor [ Has keys { x1, y1, x2, y2, w, h } ]
		This.WindowSize := Screen.GetScreenWorkArea()
			;Adjust values for the inner window
		This.WindowSize.X1 := 70 
		This.WindowSize.X2 := This.WindowSize.W - 10
		This.WindowSize.Y1 := 70
		This.WindowSize.Y2 := This.WindowSize.H - 30
		This.WindowSize.W := This.WindowSize.X2 - This.WindowSize.X1
		This.WindowSize.H := This.WindowSize.Y2 - This.WindowSize.Y1
			;Create the gui window
		Gui , % This.Name ": New" , % "+Parent1 -Caption -DPIScale "
			;Set the background color for the main window
		Gui , % This.Name ": Color" , 004444
			;Show the window 
		Gui , % This.Name ": Show" , % "x" This.WindowSize.X1 " y" This.WindowSize.Y1 " w" This.WindowSize.W " h" This.WindowSize.H
	}
}

Class MainWindow	{
	SetUp(){
		This.Controls := {}
		This._CreateMainWindow()
		This._AddControls()
	}
	_CreateMainWindow(){
			;Set the gui name
		This.Name := 1
			;Get the work area for the main monitor [ Has keys { x1, y1, x2, y2, w, h } ]
		This.WindowSize := Screen.GetScreenWorkArea()

			;Create the gui window
		Gui , % This.Name ": New" , % " -DPIScale +Resize MaxSize" This.WindowSize.W "x" This.WindowSize.H " MinSize500x500 "
			;Set the background color for the main window
		Gui , % This.Name ": Color" , 22272C
			;Show the window 
		Gui , % This.Name ": Show" , % "w" This.WindowSize.W " h" This.WindowSize.H , HB BITMAP MAKER v0.2.0.3
			;Maximize the window to fill the full screen
		Gui , % This.Name ": Maximize" 
	}
	_AddControls(){
		
		local hwnd, bd
		
		This.Controls.Slider1 := { X: 60 , Y: 70 , W: 10 , H: This.WindowSize.H - 100 }
		Gui , % This.Name ":Add" , Text , % "x" This.Controls.Slider1.X " y" This.Controls.Slider1.Y " w" This.Controls.Slider1.W " h" This.Controls.Slider1.H " Border hwndhwnd"  
		This.Controls.Slider1.Hwnd := hwnd
		bd := This._AdjustSlider1.Bind( This )
		GuiControl, % This.Name ": +G" , % This.Controls.Slider1.Hwnd , % bd
		
		This.Controls.Slider1Button := { X: This.Controls.Slider1.X + 1 , Y: This.Controls.Slider1.Y + 1 , W: 8 , H: 30 }
		Gui , % This.Name ":Add" , Progress , % "x" This.Controls.Slider1Button.X " y" This.Controls.Slider1Button.Y " w" This.Controls.Slider1Button.W " h" This.Controls.Slider1Button.H " Background00C5D1 hwndhwnd" 
		This.Controls.Slider1Button.Hwnd := hwnd
		
		This.Controls.Slider2 := { X: 70 , Y: 60 , W: This.WindowSize.W - 80 , H: 10 }
		Gui , % This.Name ":Add" , Text , % "x" This.Controls.Slider2.X " y" This.Controls.Slider2.Y " w" This.Controls.Slider2.W " h" This.Controls.Slider2.H " Border hwndhwnd"  
		This.Controls.Slider2.Hwnd := hwnd
		bd := This._AdjustSlider2.Bind( This )
		GuiControl, % This.Name ": +G" , % This.Controls.Slider2.Hwnd , % bd
		
		This.Controls.Slider2Button := { X: This.Controls.Slider2.X + 1 , Y: This.Controls.Slider2.Y + 1 , W: 30 , H: 8 }
		Gui , % This.Name ":Add" , Progress , % "x" This.Controls.Slider2.X + 1 " y" This.Controls.Slider2.Y + 1 " w" 30 " h" 8 " Background00C5D1 hwndhwnd" 
		This.Controls.Slider2Button.Hwnd := hwnd
	}
	
	_AdjustSlider1(){
		
		Local x, y, lastY, interval
		CoordMode, Mouse, Client
		While(GetKeyState("LButton")){
			Sleep, 60
			MouseGetPos, x, y
			if( LastY = y )
				continue
			LastY := y
			if( y <= This.Controls.Slider1Button.Y + This.Controls.Slider1Button.H / 2 )
				y := This.Controls.Slider1Button.Y + This.Controls.Slider1Button.H / 2 , InnerWindow2.WindowSize.Y1 := 0
			else if( y >= This.Controls.Slider1.Y + This.Controls.Slider1.H - This.Controls.Slider1Button.H / 2 )
				y := This.Controls.Slider1.Y + This.Controls.Slider1.H - This.Controls.Slider1Button.H / 2 , InnerWindow2.WindowSize.Y1 := ( InnerWindow2.WindowSize.H - InnerWindow1.WindowSize.H ) * -1
			else 
				interval := ( 3000 - InnerWindow1.WindowSize.H) / ( ( This.Controls.Slider1.Y + This.Controls.Slider1.H - This.Controls.Slider1Button.H / 2 ) - ( This.Controls.Slider1Button.Y + This.Controls.Slider1Button.H / 2 ) ) 
				, InnerWindow2.WindowSize.Y1 := floor( ( Y - This.Controls.Slider1.Y - This.Controls.Slider1Button.H / 2 )  * interval ) * -1 
			GuiControl, % This.Name ": MoveDraw" , % This.Controls.Slider1Button.Hwnd , % "x" This.Controls.Slider1Button.X  " y" Y - This.Controls.Slider1Button.H / 2
			Gui,  % InnerWindow2.Name ":Show", % "x" InnerWindow2.WindowSize.X1 " y" InnerWindow2.WindowSize.Y1
		}
	}
	
	_AdjustSlider2(){
		Local x, y, lastX, interval
		
		CoordMode, Mouse, Client
		
		While(GetKeyState("LButton")){
			Sleep, 60
			MouseGetPos, x, y
			if( LastX = x )
				continue
			LastX := x
			if( x <= This.Controls.Slider2Button.X + This.Controls.Slider2Button.W / 2 ){
				x := This.Controls.Slider2Button.X + This.Controls.Slider2Button.W / 2 , InnerWindow2.WindowSize.X1 := 0
			}else if( x >= This.Controls.Slider2.X + This.Controls.Slider2.W - This.Controls.Slider2Button.W / 2 ){
				x := This.Controls.Slider2.X + This.Controls.Slider2.W - This.Controls.Slider2Button.W / 2 , InnerWindow2.WindowSize.X1 := ( InnerWindow2.WindowSize.W - InnerWindow1.WindowSize.W ) * -1
			}else 
				interval := ( 3000 - InnerWindow1.WindowSize.W) / ( ( This.Controls.Slider2.X + This.Controls.Slider2.W - This.Controls.Slider2Button.W / 2 ) - ( This.Controls.Slider2Button.X + This.Controls.Slider2Button.W / 2 ) ) 
				, InnerWindow2.WindowSize.X1 := floor( ( X - This.Controls.Slider2.X - This.Controls.Slider2Button.W / 2 )  * interval ) * -1 
			GuiControl, % This.Name ": MoveDraw" , % This.Controls.Slider2Button.Hwnd , % "x" X - This.Controls.Slider2Button.W / 2 " y" This.Controls.Slider2Button.Y
			Gui,  % InnerWindow2.Name ":Show", % "x" InnerWindow2.WindowSize.X1 " y" InnerWindow2.WindowSize.Y1
		}
	}
}

Class Screen	{
	GetScreenWorkArea(){
		local PrimeMonitor , ScreenWorkArea , ScreenWorkAreaLeft , ScreenWorkAreaTop , ScreenWorkAreaRight , ScreenWorkAreaBottom , WindowSize
		SysGet, PrimeMonitor, MonitorPrimary
		SysGet, ScreenWorkArea, MonitorWorkArea , PrimeMonitor
		return WindowSize := { X1: ScreenWorkAreaLeft , Y1: ScreenWorkAreaTop , X2: ScreenWorkAreaRight , Y2: ScreenWorkAreaBottom , W: ScreenWorkAreaRight - ScreenWorkAreaLeft , H: ScreenWorkAreaBottom - ScreenWorkAreaTop }
	}
}


.
20210121033547.png
20210121033547.png (30.81 KiB) Viewed 103 times

A bit off topic here, but does anyone know why the caption (border) of the "bitmap" window become un-aligned after scrolling it out of the screen?
It does it by the exact amount of the space between the left side of the bitmap window and the slider (inner window edge). It's not really important because the bitmap windows will have their captions removed, but it's still a bit odd that you can't move the window (the click and move trigger gets shifted) but you can still click the button? Odd.

User avatar
mikeyww
Posts: 5424
Joined: 09 Sep 2014, 18:38

Re: Correct Size and Operation Question.

Post by mikeyww » 21 Jan 2021, 05:58

Here's mine.
HBbitmapMaker.png
HBbitmapMaker.png (93.1 KiB) Viewed 76 times

User avatar
Hellbent
Posts: 1195
Joined: 23 Sep 2017, 13:34

Re: Correct Size and Operation Question.

Post by Hellbent » 11 Feb 2021, 13:57

mikeyww wrote:
21 Jan 2021, 05:58
Here's mine.
Thank you for your time.

Post Reply

Return to “Ask For Help”