【问题标题】:How to get the available screen size in dm script如何在 dm 脚本中获取可用的屏幕尺寸
【发布时间】:2020-05-19 08:20:17
【问题描述】:

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

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


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

当我将0 用于GetMaximalDocumentWindowRect() 时,我得到(-16384/-16384) 用于(左/上)和(16383/16383) 用于(右/下),它们是(15 位(???)有符号整数的最大值并且)显然不是我的屏幕尺寸。

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


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

【问题讨论】:

  • 恐怕脚本对话框没有可滚动的内容。

标签: screen-size dm-script


【解决方案1】:

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

由于任何文档都可以部分或完全在可见工作区区域之外,使用不带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")

【讨论】:

    猜你喜欢
    • 2015-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-13
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    相关资源
    最近更新 更多