繁体   English   中英

如何在 dm 脚本中获取可用的屏幕尺寸

[英]How to get the available screen size in dm script

我有一个包含很多字段的对话框,所以对话框变得非常大。 当我切换到具有较低屏幕分辨率(较小屏幕)的计算机时,我最终不会显示所有内容。 特别是“确定”按钮无法访问,这使我的脚本不再可用。

我现在的解决方案是检查屏幕尺寸并估计我可以显示多少输入。 其他输入将 go 在其他选项卡中。 但是我如何获得屏幕尺寸? (请注意,只有在没有其他可能性的情况下才应使用选项卡解决方案。由于各种原因,我并不总是希望显示选项卡。)


我尝试使用GetMaximalDocumentWindowRect() 当我使用1作为第一个参数时,我得到 window 的当前大小。 如果没有其他解决方案,我会坚持下去。 但是当 window 没有占据全屏时,我得到的可用空间比我可以使用的要小很多。

当我对GetMaximalDocumentWindowRect()使用0时,我得到(-16384/-16384) (左/上)和(16383/16383) (右/下),它们是(15 位 (???) 签名的最大值integer 和)显然不是我的屏幕尺寸。

还有对话框 function GetFrameBounds() ,但这仅返回当前对话框的尺寸。 WindowGetFrameBounds() function 用于 windows,但我没有找到获取应用程序 window 的方法。 此外,这也只给了我我并不真正想要的应用程序的当前大小。


另一种解决方案是使用可滚动内容。 但是我在文档中没有找到任何关于可滚动的内容。 如果有可能我更喜欢这种方式而不是创建选项卡。

以下脚本输出应用程序的一般屏幕信息。 使用的命令不在官方文档中,我不知道它们是否在所有 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)

例如,获取由停靠的 windows 限制在所有四个侧面但忽略帧的区域:
OPTION = 1+16+32+64+128 = 241

由于任何文档都可以部分或完全位于可见工作区区域之外,因此使用不带INSIDE_APPLICATION标志的此命令可为文档 windows 提供完整的可用“虚拟”空间。

您可以使用以下脚本:

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")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM