RosettaCodeData/Task/GUI-Maximum-window-dimensions/M2000-Interpreter/gui-maximum-window-dimensio...

74 lines
2.5 KiB
Plaintext

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<Scrx(i)*Scry(i) then MaxArea=Scrx(i)*Scry(i) : ChooseMonitor=i
}
}
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