如何检查系统的可见分辨率
我不完全确定如何表达这个问题,所以我只是解释一下我的问题。
我的 VB 6 程序将屏幕的位置保存在注册表中,以便当它再次加载时可以有一个默认位置。这按预期工作,但我遇到了问题。我的电脑设置有 2 个显示器。我将窗口拖动到第二个屏幕,然后第二天拔掉第二个显示器的插头。每次我加载程序时,它都会出现在扩展坞中,但表单本身却没有。
我认为它隐藏在第二个显示器的空间中(或者第二个显示器应该是) 现在,首先我连接了第二个显示器以将其夺回,但它没有显示。显示器设置是这样的:主显示器 (1) 位于新显示器 (2) 的左侧。我必须将 (2) 拖到 (1) 的左侧,此时它出现,并且我能够将其拖回主窗口,一切正常。我提到这一点是因为我认为每个显示器编号的分辨率都是相对于其自身的。多显示器是一个巨大的坐标平面吗?
我想知道的是,当我从注册表(Form.left 和 Form.top)获取位置号时,有没有办法将其与系统可用的位置号进行检查?这不是一个大问题,但我知道我最终会让客户打电话来询问:“它正在加载,但我找不到它!”如果可能的话,希望避免这些电话。
谢谢大家
I am not entirely sure how to word this questions so I am just going to explain my problem.
My VB 6 program saves the location of the screen in the registry so that when it loads up again it can have a default location. This works as expected, but I encountered a problem. I had a computer setup with 2 monitors. I dragged the window to the second screen, then the next day when I unplugged the second monitor. Every time I would load the program it would appear in the dock, but the form itself was not.
I figured it was hiding on the second monitor's space (or were the second monitor should be) Now at first I connected a second monitor to grab it back, but it did not show up. The monitor setup was such that the main monitor (1) was to the left of the new monitor (2). I had to drag (2) over to the left of (1) at which point it showed up, and I was able do drag it back to the main window and everything worked fine. I mention this because I figured each monitor number's resolution was relative to itself. Is the multimonitor one giant coordinate plane?
What I want to know is when I grab the location numbers from the registry (Form.left and Form.top) is there a way to check it against what is available to the system? This is not a huge issue, but I know I am going to get clients calling in eventually asking, "Its loading, but I cant find it!" and would like to avoid those calls if possible.
Thank you all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不了解VB,但您可以调用本机Win32 API来处理该问题。
GetSystemMetrics(SM_CMONITORS) 返回监视器的数量,或者如果您需要区分“真实”监视器和伪显示监视器,则可以使用 EnumDisplayMonitors() 枚举它们。
使用 MonitorFromPoint() 或 MonitorFromRect() 或 MonitorFromWindow() 识别指定点处的监视器,然后使用 GetMonitorInfo() 返回有关该监视器的信息,包括其虚拟屏幕坐标。然后,您可以将窗口放置在您选择的显示器上。
我不知道如何可靠地检测第二个显示器是否丢失或已关闭。我怀疑您可以为此使用设置 API(!)——SetupDiEnumDeviceInfo() 可用于枚举监视器设备,SetupDiGetDeviceRegistryProperty() 可用于检索有关每个设备的信息,例如其当前的电源状态。
Don't know about VB, but you can call native Win32 APIs to deal with the problem.
GetSystemMetrics(SM_CMONITORS) returns the number of monitors, or you can enumerate them with EnumDisplayMonitors() if you need to distinguish between "real" monitors and pseudo-display monitors.
Use MonitorFromPoint() or MonitorFromRect() or MonitorFromWindow() to identify the monitor at a specified point, and then use GetMonitorInfo() to return information about that monitor, including its virtual-screen coordinates. You can then position the window on the monitor of your choice.
I don't know how to reliably detect whether the second monitor is missing or powered off. You could use the setup API (!) for this, I suspect -- SetupDiEnumDeviceInfo() can be used to enumerate the monitor devices and SetupDiGetDeviceRegistryProperty() can be used to retrieve information about each, like its current power state.
这并不是您问题的真正答案,但它可以帮助您将来处理类似的问题,或者帮助您的客户解决遇到的问题。
如果右键单击任务栏按钮(或在 Windows 7 上,右键单击窗口的 Aero Peek 预览),您将看到一个“移动”选项。单击该按钮,然后按其中一个箭头键,无论是哪一个。之后,窗口将处于可移动模式,您只需移动鼠标即可,瞧,它又回到屏幕上,就像您拖动标题栏一样。
Not really an answer to your question, but it could help in dealing with similar problems in the future, or your customers if they bump into it.
If you right-click the taskbar button (or on Windows 7, right-click the Aero Peek preview of the window), you'll see a Move option. Click that, and then press one of your arrow keys, doesn't matter which. After that, the window will be in movable mode, and you can just move your mouse and voila, it is back on your screen and acting as if you were dragging the title bar.