1

在 GMS3 中,无模式对话框似乎发生了显着变化,尤其是定位此类对话框窗口的方法。使用对话框位置规范(使用 DLGBuildPosition 和 DLGPosition 函数生成)来指定初始对话框位置似乎不再有效。通过相关的 DocumentWindow 对象(例如 WindowSetPosition 或 WindowSetFrameBounds)上的方法直接定位对话框似乎可行,但坐标系似乎定义不一致,并且未连接到文档窗口使用的工作区坐标系。

下面的示例脚本说明了这两种类型的窗口之间的坐标系之间的对比。鉴于这种断开连接,是否有任何方法可以相对于给定工作区中的文档窗口定位无模式对话窗口?

下面是一些示例代码,说明了为文档窗口内容区域和框架返回的相当正常和预期的坐标:

// $BACKGROUND$

// In GMS3, the DM app bounds give the size of the workspace area,
// i.e. the area in which document windows are positioned and presented.
// The bounds are in local DM workspace coordinates and do not yield the
// position in either DM app window or screen/display coordinates.
Number appT, appL, appB, appR;
ApplicationGetBounds(appT, appL, appB, appR);
String infoText = "Workspace frame: [";
infoText += appT + ", ";
infoText += appL + ", ";
infoText += appB + ", ";
infoText += appR + "]";
OKDialog(infoText);

Number windowCount = CountDocumentWindows();
Result("\nWindow count: " + windowCount + "\n");
for (Number iWin = 0; iWin < windowCount; iWin++)
{
    DocumentWindow window = GetDocumentWindow(iWin);

    Result ("\n\nTitle: " + window.WindowGetTitle());

    // In GMS3, document window bounds are specified and returned in
    // local DM workspace coordinates and do not yield the position
    // in either DM app window or screen/display coordinates.
    Number winT, winL, winB, winR, winW, winH;

    window.WindowGetContentPosition(winL, winT);
    Result("\nContent position: " + winL + ", " + winT);
    window.WindowGetContentSize(winW, winH);
    Result("\nContent size: " + winW + ", " + winH);
    window.WindowGetContentBounds(winT, winL, winB, winR);
    Result("\nContent bounds: " + winT + ", " + winL + ", " + winB + ", " + winR);

    window.WindowGetFramePosition(winL, winT);
    Result("\nFrame position: " + winL + ", " + winT);
    window.WindowGetFrameSize(winW, winH);
    Result("\nFrame size: " + winW + ", " + winH);
    window.WindowGetFrameBounds(winT, winL, winB, winR);
    Result("\nFrame bounds: " + winT + ", " + winL + ", " + winB + ", " + winR);

    window.WindowSetFramePosition(winL + 50, winT + 50);
    Sleep(3);
    window.WindowSetFrameBounds(winT, winL, winB, winR);
    Sleep(3);
}

为了比较,以下脚本显示了为无模式对话窗口返回的类似值:

// $BACKGROUND$
TagGroup uiItemsSpec;
TagGroup dialogSpec = DLGCreateDialog("Dialog title", uiItemsSpec);

// In GMS3, the DM app bounds give the size of the workspace area,
// i.e. the area in which document windows are positioned and presented.
// The bounds are in local DM workspace coordinates and do not yield the
// position in either DM app window or screen/display coordinates.
Number appT, appL, appB, appR;
ApplicationGetBounds(appT, appL, appB, appR);
String infoText = "Workspace frame: [";
infoText += appT + ", ";
infoText += appL + ", ";
infoText += appB + ", ";
infoText += appR + "]";
OKDialog(infoText);

// In GMS3, specification of an initial modeless dialog frame with a TagGroup
// returned by DLGBuildPosition and passsed to DLGPosition, no longer works.
// Instead, the window frame must be set directly via WindowSetFrameBounds.
Number winT = 100;
Number winL = 50;
Number winB = 300;
Number winR = 700;
// TagGroup positionSpec = DLGBuildPosition(winT, winL, winB, winR);
// positionSpec.TagGroupSetTagAsTagGroup("X", DLGBuildRelativePosition("Inside", 1));
// positionSpec.TagGroupSetTagAsTagGroup("Y", DLGBuildRelativePosition("Inside", 1));
// positionSpec.TagGroupSetTagAsTagGroup("Height", DLGBuildMatchSize());
// positionSpec.TagGroupSetTagAsTagGroup("Width", DLGBuildMatchSize());
// dialogSpec.DLGPosition(positionSpec);

// Create and add an info text field
TagGroup infoLabelSpec = DLGCreateLabel("Initial modeless dialog position", 48);
infoLabelSpec.DLGSide("Left");
infoLabelSpec.DLGExternalPadding(0, 0);
uiItemsSpec.DLGAddElement(infoLabelSpec);

Object dialog = Alloc(UIFrame).Init(dialogSpec);
dialog.Display("Positioned modeless dialog");
Sleep(3);

DocumentWindow window = dialog.GetFrameWindow();
infoText = "Frame bounds set to [";
infoText += winT + ", " + winL + ", ";
infoText += winB + ", " + winR + "]";
infoLabelSpec.DLGTitle(infoText);
window.WindowSetFrameBounds(winT, winL, winB, winR);
Sleep(3)

// In GMS3, modeless dialog title text is not stored as the window title,
// WindowGetTitle always returns an empty string.
Result ("\nTitle: " + window.WindowGetTitle());

// In GMS3, the coordinate system for modeless dialog window
// positioning appears to be unclear and inconsistent.
Number winW, winH;

// For the window content area, only the content bounds are easily understood.
// They specify the content rectangle in content area coordinates.
window.WindowGetContentPosition(winL, winT);
Result("\nContent position: " + winL + ", " + winT);
window.WindowGetContentSize(winW, winH);
Result("\nContent size: " + winW + ", " + winH);
window.WindowGetContentBounds(winT, winL, winB, winR);
Result("\nContent bounds: " + winT + ", " + winL + ", " + winB + ", " + winR);

// For the window frame, the frame bounds and size appear to be in screen coordinates.
// The frame position is in DM app window  content area coordinates.
window.WindowGetFramePosition(winL, winT);
Result("\nFrame position: " + winL + ", " + winT);
window.WindowGetFrameSize(winW, winH);
Result("\nFrame size: " + winW + ", " + winH);
window.WindowGetFrameBounds(winT, winL, winB, winR);
Result("\nFrame bounds: " + winT + ", " + winL + ", " + winB + ", " + winR + "\n");

infoLabelSpec.DLGTitle("Frame position set to (0, 0)");
window.WindowSetFramePosition(0, 0);
Sleep(3);

infoText = "Frame bounds set to [";
infoText += winT + ", " + winL + ", ";
infoText += winB + ", " + winR + "]";
infoLabelSpec.DLGTitle(infoText);
window.WindowSetFrameBounds(winT, winL, winB, winR);
4

0 回答 0