我有一个包含很多字段的对话框,所以对话框变得非常大。当我换到屏幕分辨率较低的电脑上时(屏幕较小),结果不是所有的东西都能显示出来。特别是 "确定 "按钮无法到达,这使得我的脚本无法使用。
我现在的解决方法是检查屏幕大小,并估计我可以显示多少个输入。其他的输入将放在其他的标签页中。但我如何获得屏幕大小? (注意,只有在没有其他可能的情况下,才应该使用标签页的解决方案。由于各种原因,我并不总是想显示标签页)。)
我试着用 GetMaximalDocumentWindowRect()
. 当我使用 1
的第一个参数,我得到窗口的当前大小。如果没有其他解决方案,我将坚持使用这个方法。但是当窗口不占用全屏时,我得到的可用空间比我可以使用的空间小很多。
当我使用 0
对于 GetMaximalDocumentWindowRect()
我得到 (-16384/-16384)
为(左上)和 (16383/16383)
为(rightbottom),它们是(15bit(??)有符号整数的最大值,)显然不是我的屏幕尺寸。
还有对话框功能 GetFrameBounds()
但这只返回当前对话框的尺寸。在 WindowGetFrameBounds()
函数用于窗口,但我没有找到获取应用程序窗口的方法。此外,这也只给我应用程序的当前大小,我并不真正想要。
另一个解决方案是使用可滚动内容。但是我在文档中没有找到任何关于可滚动的内容。如果有可能的话,我宁愿选择这种方式而不是创建标签。
下面的脚本输出了应用程序的一般屏幕信息。使用的命令不在官方文档中,我不知道它们是否在所有GMS版本中都有效。
ClearResults()
number nScreens = CountScreens()
Result("System info on screens and application window.\n")
Result("**********************************************\n")
Result("\n Number of Screens: " + nScreens )
for( number i=0; i<nScreens; i++ )
{
string name = ScreenGetName(i)
Result("\n\n\t Screen #"+i+": "+name)
number st,sl,sb,sr
ScreenGetBounds(i,st,sl,sb,sr)
Result("\n\t\t Bounds: ["+st+";"+sl+";"+sb+";"+sr+"]")
number wt,wl,wb,wr
ScreenGetWorkArea(i,wt,wl,wb,wr)
Result("\n\t\t Work area: ["+wt+";"+wl+";"+wb+";"+wr+"]")
}
Result("\n\n GMS Application window:\n")
number ap_global_x,ap_global_y
ApplicationGetOrigin(ap_global_x,ap_global_y)
result("\n\t Origin(global coordinates): "+ap_global_x+"/"+ap_global_y)
number ap_t, ap_l, ap_b, ap_r
ApplicationGetBounds(ap_t, ap_l, ap_b, ap_r)
Result("\n\t Main area (application coordiantes): ["+ap_t+";"+ap_l+";"+ap_b+";"+ap_r+"]")
要想知道工作区的哪些区域可以实际用于图片,你可以使用 GetMaximalDocumentWindowRect()
命令。
该
options
参数是一个数字,以其二进制形式指定各种标志。
INSIDE_APPLICATION = 0x00000001 // 1
EXCLUDE_FRAME = 0x00000002 // 2
EXCLUDE_DOCKED_FLOATING_WINDOWS = 0x000000F0 // 240 (Sum 16+32+64+128)
如:获取四面都被停靠的窗口限制的区域,但忽略框架。
OPTION = 1+16+32+64+128 = 241
因为任何文档都可以部分或完全在docked窗口之外。有形 工作空间区域,使用此命令时,如果不使用 INSIDE_APPLICATION
标志为文档窗口提供了全部可用的 "虚拟 "空间。
你可以使用以下脚本。
void Output( number OPTION , number DRAW)
{
Number T,L,B,R // coordinates
GetMaximalDocumentWindowRect(OPTION,t,l,b,r)
string z = "000000000000"
Result("\n ("+left( z, 10-len(Binary(OPTION))) + Binary(OPTION)+")")
Result("\t Coordintates: ["+Format(t,"%6d")+","+Format(l,"%6d")+","+Format(b,"%6d")+","+Format(r,"%6d")+"]")
if (DRAW)
NewScriptWindow("Test area ("+OPTION+")",t,l,b,r)
}
number DRAWIT = !TwoButtonDialog( "Output current maximum size to results.", "OK", "Also draw windows")
Output(1+2,DRAWIT) ; result("\t Maximum window, exclude frame")
Output(1+2+240,DRAWIT) ; result("\t Maximum window, limited by docked, exclude frame")