SetWindowLong 在某些计算机上不起作用

发布于 2024-12-13 13:52:35 字数 1804 浏览 2 评论 0原文

编辑:更多信息 我已将其范围缩小到某些计算机上的某些应用程序。我正在尝试在某个显示器上以全屏模式启动 chrome。这在我测试过的大多数系统上都能完美运行,但是我们遇到了一组运行 Windows 7 Pro 32 位的计算机,这些计算机正在正确移动和调整大小,但它们的边框和按钮仍然完好无损。

我意识到 chrome 窗口都是在单个 chrome 进程下生成的,并且它们的生命周期是不稳定的,但我们已经能够使用单独的数据目录来解决这个问题,该目录使每个 chrome 实例在其自己的父进程中以这种方式启动。 Chrome 似乎是唯一一个在全屏启动时遇到问题且仅在一组计算机上出现问题的应用程序。例如,当运行 calc.exe 时,它​​会最大化并删除边框,在我们测试过的所有系统上都没有任何问题。我已经确认每个系统上运行的chrome版本是相同的。如果有人对这个问题有更深入的了解,或者进一步解决该问题的方法,我将非常感激。


我正在尝试使用 SetWindowLong 以全屏模式运行应用程序,直到我在最新的计算机上尝试它为止,它都工作得很好。我基本上使用这个问题中引用的代码: Removing window border?

这在我的两个设备上都可以正常工作笔记本电脑(Windows 7 Ultimate)和几个我已经测试过的工作盒(Windows 7 POS Embedded),但它无法在工作中的另一台计算机(Windows 7 Professional)上运行。 SetWindowLong 调用返回预期值,这表明它应该工作,并且对 SetWindowPos 的调用工作正常,因为它正确调整了窗口大小,但边框和按钮仍然存在!它的运行方式就好像根本没有调用 SetWindowLong 一样。我非常感谢一些帮助,因为我现在没有想法。

编辑:这是凌晨 1 点红眼荣耀的代码。几乎是链接问题的直接副本。

int lStyle = GetWindowLong(process.MainWindowHandle, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
_logger.Debug(String.Format("Style: {0}", lStyle)); // 369295360

var swlResult = SetWindowLong(process.MainWindowHandle, GWL_STYLE, lStyle);
_logger.Debug(String.Format("SetWindowLong: {0}", swlResult)); // 382664704

int lExStyle = GetWindowLong(process.MainWindowHandle, GWL_EXSTYLE);

lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
SetWindowLong(process.MainWindowHandle, GWL_EXSTYLE, lExStyle);

Screen screen = GetDisplay(display);

return SetWindowPos(
    process.MainWindowHandle,
    HWND_TOPMOST,
    screen.WorkingArea.Left,
    screen.WorkingArea.Top,
    screen.WorkingArea.Width,
    screen.WorkingArea.Height,
    SetWindowPosFlags.SWP_FRAMECHANGED);

Edit: More Information
I've narrowed it down to certain applications on certain computers. I am trying to launch chrome in a full screen mode on a certain monitor. This works perfectly on most systems I have tested however we have run into a set of computers running Windows 7 Pro 32bit which are being moved and resized correctly, but their border and buttons are still intact.

I realize that chrome windows all spawn under a single chrome process and that their lifecycle is volatile, but we have been able to work around this using a separate data directory which keeps each chrome instance launched that way in it's own parent process. Chrome seems to be the only application we have problems launching full screen and only on one set of computers. When running calc.exe for instance it maximizes and removes the borders without any problems on all systems we have tested. I have confirmed that the version of chrome running on each system is the same. I would really appreciate it if anyone had more insight into either this problem, or ways of further troubleshooting the issue.


I'm trying to run an application in a full screen mode using SetWindowLong and it's worked great up until the latest computer I tried it on. I am basically using the code referenced in this question: Removing window border?

This works fine on both of my laptops (Windows 7 Ultimate) and a couple work boxes that I have tested it on (Windows 7 POS Embedded) but it's not working on another computer at work (Windows 7 Professional). The SetWindowLong call is returning the expected value which indicates to me that it should be working, and the call to SetWindowPos works fine as it's resizing the window correctly, but the border and buttons are still there! It's functioning as if there was no call to SetWindowLong at all. I would greatly appreciate some help as I'm out of ideas at this point.

Edit: Here is the code in all it's 1AM red eyed glory. Pretty much a direct copy of the linked question.

int lStyle = GetWindowLong(process.MainWindowHandle, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
_logger.Debug(String.Format("Style: {0}", lStyle)); // 369295360

var swlResult = SetWindowLong(process.MainWindowHandle, GWL_STYLE, lStyle);
_logger.Debug(String.Format("SetWindowLong: {0}", swlResult)); // 382664704

int lExStyle = GetWindowLong(process.MainWindowHandle, GWL_EXSTYLE);

lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
SetWindowLong(process.MainWindowHandle, GWL_EXSTYLE, lExStyle);

Screen screen = GetDisplay(display);

return SetWindowPos(
    process.MainWindowHandle,
    HWND_TOPMOST,
    screen.WorkingArea.Left,
    screen.WorkingArea.Top,
    screen.WorkingArea.Width,
    screen.WorkingArea.Height,
    SetWindowPosFlags.SWP_FRAMECHANGED);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小兔几 2024-12-20 13:52:35

发现问题了。我们正在使用 LogMeIn 进行远程计算机管理,似乎他们的视频镜像驱动程序在某些机器上引起了问题。卸载镜像驱动程序并重新启动会使一切按预期工作。

对于过时的 XP 副本(甚至 SP3,也许还有其他版本),此操作也会失败。我已在十几台工作站上确认安装推荐的更新可以解决此问题。每个都需要平均更新,所以很难说哪一个做到了这一点,但显然其中一个做到了。保持更新启用的另一个原因。

Found the problem. We are using LogMeIn for remote computer management, and it seems like their video mirror driver is causing problems on certain machines. Uninstalling their mirror driver, and restarting causes everything to work as expected.

It is also the case that this fails with out-of-date copies of XP (even SP3, and perhaps others). I have confirmed on over a dozen workstations that installing recommended updates resolves this issue. There were an average of updates needed on each, so it's hard to say which one did the trick, but apparently one of them did. Yet another reason to keep updates enabled.

锦上情书 2024-12-20 13:52:35

Windows 7 Professional系统是64位的吗?根据 SetWindowLong< 的文档/a>

该函数已被 SetWindowLongPtr 函数取代。要编写与 32 位和 64 位版本的 Windows 兼容的代码,请使用 SetWindowLongPtr 函数。

尝试修改您的代码以调用 在 64 位系统上运行 SetWindowLongPtr 函数,看看会发生什么。

Is the Windows 7 Professional system 64 bit? According to the documentation for SetWindowLong

This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Windows, use the SetWindowLongPtr function.

Try modifying your code to call the SetWindowLongPtr function on 64 bit systems and see what happens.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文