windows 窗口的大小可以调整为超过屏幕大小/屏幕外吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6123410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:55:58  来源:igfitidea点击:

Can a window be resized past the screen size/offscreen?

windowswinapiwindowsizemax

提问by Mike Kwan

My purpose is to size a window to a width/height greater than the size of my physical screen programmatically under Win32. How can I do this?

我的目的是在 Win32 下以编程方式将窗口的宽度/高度调整为大于物理屏幕的大小。我怎样才能做到这一点?

On my systems it seems the maximum size of a given window is bound by the size of my screen whether programmatically or whether sizing manually by dragging the sizing cursor.

在我的系统上,给定窗口的最大大小似乎受我的屏幕大小的限制,无论是通过编程方式还是通过拖动大小光标手动调整大小。

I have tried programmatically with SetWindowPos() and MoveWindow() and both cap the size of the target window. Oddly I know some people do not have this 'cap' so I wonder whether this is perhaps due to some OS setting (registry). Does anyone know something about this? Or perhaps some way to workaround it?

我已经用 SetWindowPos() 和 MoveWindow() 以编程方式尝试过,并且都限制了目标窗口的大小。奇怪的是,我知道有些人没有这个“上限”,所以我想知道这是否可能是由于某些操作系统设置(注册表)。有没有人知道这件事?或者也许有办法解决它?

// Edit: new developments

// 编辑:新的发展

I am testing on Windows XP and Windows 7. The graphics cards I'm using are a NVIDIA Quadro NVS 290 (256MB) and a Geforce 9800GT (1GB). After further investigation it looks like Windows is intercepting the message and fiddling with the parameters. For example, if you call SetWindowPos to make a target 2000x2000 it will only receive a WM_SIZE for the capped x/y.

我正在 Windows XP 和 Windows 7 上进行测试。我使用的显卡是 NVIDIA Quadro NVS 290 (256MB) 和 Geforce 9800GT (1GB)。经过进一步调查,看起来 Windows 正在拦截消息并摆弄参数。例如,如果您调用 SetWindowPos 来制作 2000x2000 的目标,它只会收到一个用于上限 x/y 的 WM_SIZE。

回答by Hans Passant

Implement a message handler for WM_GETMINMAXINFO to stop Windows from applying the sane default behavior:

为 WM_GETMINMAXINFO 实现消息处理程序以阻止 Windows 应用正常的默认行为:

case WM_GETMINMAXINFO: {
    DefWindowProc(hWnd, message, wParam, lParam);
    MINMAXINFO* pmmi = (MINMAXINFO*)lParam;
    pmmi->ptMaxTrackSize.x = 2000;
    pmmi->ptMaxTrackSize.y = 2000;
    return 0;
}

回答by Robert Otto

Windows with a thick frame (to allow user resize) are restricted from growing larger than the desktop.

具有厚边框(以允许用户调整大小)的 Windows 被限制不能超过桌面。

Try SetWindowLong() clearing the THICKFRAME (0x40000) flag.

尝试 SetWindowLong() 清除 THICKFRAME (0x40000) 标志。

The following should allow programatic sizing, but the user will lose the ability to resize. If you add the Thickframe back after sizing, the user can resize, but when he does so the window will immediately shrink back to the desktop limited size.

以下应该允许程序调整大小,但用户将失去调整大小的能力。如果在调整大小后重新添加厚框,用户可以调整大小,但是当他这样做时,窗口将立即缩小到桌面限制的大小。

The following is from some csharp code that also removes all borders, caption, etc:

以下来自一些 csharp 代码,该代码还删除了所有边框、标题等:

WS style = (WS)GetWindowLong(ptr, GWL_STYLE); style = style & ~WS.BORDER & ~WS.ThickFrame & ~WS.SYSMENU & ~WS.CAPTION | WS.POPUP; SetWindowLong(ptr, GWL_STYLE, (int)style);

WS 样式 = (WS)GetWindowLong(ptr, GWL_STYLE); style = style & ~WS.BORDER & ~WS.ThickFrame & ~WS.SYSMENU & ~WS.CAPTION | WS.POPUP; SetWindowLong(ptr, GWL_STYLE, (int)style);



A good tool to play with window settings is uuSpy. It's like Microsoft Spy++, but allows you to modify settings like THICKFRAME.

一个使用窗口设置的好工具是 uuSpy。它类似于 Microsoft Spy++,但允许您修改 THICKFRAME 等设置。

回答by Adrian McCarthy

Yes, windows can be larger than the screen (or even the sum of all your monitors). Windows can also be positioned off-screen (which some applications do as a hack to hide while remaining active).

是的,窗口可以大于屏幕(甚至是所有显示器的总和)。Windows 也可以放置在屏幕外(某些应用程序这样做是为了隐藏而保持活动状态)。

Perhaps the Windows 7 desktop manager is kicking in and trying to "dock" those windows to the edges of your screen for you.

也许 Windows 7 桌面管理器正在尝试为您将这些窗口“停靠”到屏幕边缘。

You might try using the slightly lower-level API SetWindowPos, which gives you control over notifications, z-order, and other stuff.

您可以尝试使用级别稍低的 API SetWindowPos,它可以让您控制通知、z-order 和其他内容。

回答by tom-q

You can get a window to be larger in resolution (and even way way larger) than your screen, using the 'Infinte Screen" software: http://ynea.futureware.at/cgi-bin/infinite_screen.pl

使用“无限屏幕”软件,您可以获得比屏幕更大的分辨率(甚至更大)的窗口:http: //ynea.futureware.at/cgi-bin/infinite_screen.pl

Here's how to use it:

以下是如何使用它:

  1. Download it, run it.

  2. In the Oversize tab, choose the Windows you want to enlarge.

  3. Give it the Width and Height you want. Done!

  1. 下载,运行。

  2. 在“超大尺寸”选项卡中,选择要放大的窗口。

  3. 给它你想要的宽度和高度。完毕!

Just in case you need a large screenshot (that's how I ended up here): If you want to get a screenshot of the window, you've got a screenshot option in the same Oversize tab. (Because screenshots are normally no bigger than the screen size, even if the window is larger). Another (and better) way to screenshot the window is using Greenshot, as you can save them in .tiff and directly watching the window.

以防万一您需要大屏幕截图(这就是我在这里结束的方式):如果您想获取窗口的屏幕截图,您在同一个 Oversize 选项卡中有一个屏幕截图选项。(因为截图通常不会大于屏幕尺寸,即使窗口更大)。另一种(更好)的窗口截图方法是使用 Greenshot,因为您可以将它们保存在 .tiff 中并直接观察窗口。