简体   繁体   English

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

[英]SetWindowLong is not working on some computers

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. 我正在尝试在特定显示器上以全屏模式启动Chrome。 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. 这在我测试过的大多数系统上都可以正常运行,但是我们遇到了一组运行Windows 7 Pro 32bit的计算机,这些计算机可以正确移动和调整大小,但是它们的边框和按钮仍然完好无损。

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窗口都是在单个chrome进程中生成的,并且它们的生命周期是可变的,但是我们已经能够使用单独的数据目录来解决此问题,该目录将每个chrome实例保持在其自己的父进程中以这种方式启动。 Chrome seems to be the only application we have problems launching full screen and only on one set of computers. Chrome似乎是我们在全屏启动时只能在一组计算机上遇到的唯一应用程序。 When running calc.exe for instance it maximizes and removes the borders without any problems on all systems we have tested. 例如,当运行calc.exe时,它将最大化并删除边界,在我们测试过的所有系统上都没有任何问题。 I have confirmed that the version of chrome running on each system is the same. 我已经确认在每个系统上运行的chrome版本是相同的。 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. 我正在尝试使用SetWindowLong在全屏模式下运行应用程序,并且在我尝试使用的最新计算机之前,它一直都很好用。 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). 这在我的笔记本电脑(Windows 7 Ultimate)和我已经在其上测试过的几个工作盒(Windows 7 POS Embedded)上都可以正常工作,但在另一台正在工作的计算机(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! SetWindowLong调用正在返回期望值,该值向我表明它应该正在工作,并且SetWindowPos的调用工作正常,因为它正确调整了窗口的大小,但是边框和按钮仍然存在! It's functioning as if there was no call to SetWindowLong at all. 好像根本没有调用SetWindowLong一样起作用。 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. 编辑:这是所有1AM红眼荣耀的代码。 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);

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. 我们使用LogMeIn进行远程计算机管理,似乎他们的视频镜像驱动程序在某些计算机上引起了问题。 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). 同样,如果XP的副本过旧(甚至是SP3,甚至其他),此操作也会失败。 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. 保持启用更新的另一个原因。

Is the Windows 7 Professional system 64 bit? Windows 7 Professional系统是64位吗? According to the documentation for SetWindowLong 根据SetWindowLong的文档

This function has been superseded by the SetWindowLongPtr function. 此函数已由SetWindowLongPtr函数取代。 To write code that is compatible with both 32-bit and 64-bit versions of Windows, use the SetWindowLongPtr function. 若要编写与Windows 32位和64位版本兼容的代码,请使用SetWindowLongPtr函数。

Try modifying your code to call the SetWindowLongPtr function on 64 bit systems and see what happens. 尝试修改您的代码以在64位系统上调用SetWindowLongPtr函数,然后看看会发生什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM