How to resolve the algorithm GUI/Maximum window dimensions step by step in the M2000 Interpreter programming language
How to resolve the algorithm GUI/Maximum window dimensions step by step in the M2000 Interpreter programming language
Table of Contents
Problem Statement
The task is to determine the maximum height and width of a window that can fit within the physical display area of the screen without scrolling. This is effectively the screen size (not the total desktop area, which could be bigger than the screen display area) in pixels minus any adjustments for window decorations and menubars. The idea is to determine the physical display parameters for the maximum height and width of the usable display area in pixels (without scrolling). The values calculated should represent the usable desktop area of a window maximized to fit the the screen.
For multiple monitors, the values calculated should represent the size of the usable display area on the monitor which is related to the task (i.e.: the monitor which would display a window if such instructions were given). For a tiling window manager, the values calculated should represent the maximum height and width of the display area of the maximum size a window can be created (without scrolling). This would typically be a full screen window (minus any areas occupied by desktop bars), unless the window manager has restrictions that prevents the creation of a full screen window, in which case the values represent the usable area of the desktop that occupies the maximum permissible window size (without scrolling).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm GUI/Maximum window dimensions step by step in the M2000 Interpreter programming language
Source code in the m2000 programming language
Module CheckAllMonitors {
mode 16 ' font size
i=-1
Flush
Do {
i++
Window mode, i
Print Window=i
Wait 100
Form ; ' expand Background to fill monitor (form without arguments cut that frame)
if window=i Then {
Background {
Cls 0, 0
data i, scale.x, scale.y, motion.x, motion.y
}
} else exit
} Always
Dim Scrx(i), ScrY(i), ScrLeft(i), ScrTop(i)
While Not Empty {
Read i
Read Scrx(i), ScrY(i), ScrLeft(i), ScrTop(i)
}
\\ check if we have same left top point
For i=0 to Len(Scrx())-1 {
Print "Monitor:", i, "left top (";ScrLeft(i);",";ScrTop(i);") size: (";Scrx(i);",";ScrY(i);")"
}
A=ScrLeft(0)
B=ScrTop(0)
LeftMargin=A
TopMargin=B
RightMargin=Scrx(0)+A
BottomMargin=Scry(0)+B
MaxArea=Scrx(0)*Scry(0)
ChooseMonitor=0
Out=True
If Len(Scrx())>1 then {
For i=1 to Len(Scrx())-1 {
LeftMargin=Min.Data(A, ScrLeft(i))
TopMargin=Min.Data(B, ScrTop(i))
RightMargin=Max.Data(RightMargin, Scrx(i)+Scrleft(i))
BottomMargin=Max.Data(BottomMargin, Scry(i)+ScrTop(i))
Out=Out and (A=ScrLeft(i) and B=ScrTop(i))
if MaxArea
}
}
If Len(Scrx())=1 then {
Print "One Monitor"
} else Print If$(Out ->"Clone Monitors", "Multiple Monitors ")
Print "Left Top Corner:", LeftMargin, TopMargin
Print "Width, Height", RightMargin-LeftMargin, BottomMargin-TopMargin
Declare Form1 Form
\\ After 100ms Form1 expand to all monitors
After 100 {
Method Form1,"Move", LeftMargin, TopMargin, RightMargin-LeftMargin, BottomMargin-TopMargin
}
\\ After 2000-100ms Form1 move to montior ChooseMonitor, and has same width and height
After 2000 {
Try {
Method Form1,"Move", ScrLeft(ChooseMonitor),ScrTop(ChooseMonitor), Scrx(ChooseMonitor), Scry(ChooseMonitor)
}
}
\\ after 4000 ms from other threads, form1 close
After 4000 {
Try {
Method Form1, "CloseNow"
}
}
Method Form1, "Show", 1
Declare Form1 Nothing
Threads Erase
}
CheckAllMonitors
You may also check:How to resolve the algorithm Sierpinski pentagon step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the Ursala programming language
You may also check:How to resolve the algorithm Create a two-dimensional array at runtime step by step in the Quackery programming language
You may also check:How to resolve the algorithm Zebra puzzle step by step in the Standard ML programming language
You may also check:How to resolve the algorithm System time step by step in the IDL programming language