简体   繁体   English

从Windows样式中删除WS_BORDER和WS_CAPTION不起作用

[英]Removing WS_BORDER and WS_CAPTION from windows styles doesn't work

I created a small app in C# that removes border and caption from window, then it sets size to the user's resolution and centers it. 我用C#创建了一个小应用程序,该程序从窗口中删除边框和标题,然后将大小设置为用户的分辨率并将其居中。 It's a utility for me to use when I want to play games in windowed mode without being annoyed by the borders. 当我想在窗口模式下玩游戏而不会被边框烦恼时,可以使用该实用程序。 Everything works fine with most games, but I tried to use it on a recently released game Alpha Protocol and it doesn't work. 大多数游戏都可以正常运行,但是我尝试在最近发布的游戏Alpha Protocol中使用它,但它不起作用。 I could almost say that the game reverts my changes, but I'm not sure how to tell if that's true or not. 我几乎可以说游戏会还原我的更改,但是我不确定如何判断那是真的。 I'm using imported API functions MoveWindow, SetWindowLong and SetWindowPos. 我正在使用导入的API函数MoveWindow,SetWindowLong和SetWindowPos。

Snippet: 片段:

Win32.MoveWindow(hWnd, 0, 0, Convert.ToInt32(sizeXText.Text), Convert.ToInt32(sizeYText.Text), true);
Win32.SetWindowLong(hWnd, GWL_STYLE, Win32.GetWindowLong(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_BORDER);
Win32.SetWindowPos(hWnd, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DRAWFRAME);

Every time SetWindowPos is called it sends a message: WM_WINDOWPOSCHANGING to the window with a writable copy of the SetWindowPos parameters. 每次调用SetWindowPos时,它将发送一条消息: WM_WINDOWPOSCHANGING到带有SetWindowPos参数的可写副本的窗口。 This gives the window the chance to validate and change the parameters. 这使窗口有机会验证和更改参数。 Many window's automatically react to repositioning and sizing to "smartly" manage their non-client decorations - which I guess is what is happening here. 许多窗口会自动对重新定位和调整大小做出反应,以“巧妙地”管理其非客户端装饰-我想这是这里正在发生的事情。 The OnWindowPosChanging code is re-setting the non client decorations just before the DRAWFRAME is handled. 在处理DRAWFRAME之前,OnWindowPosChanging代码正在重新设置非客户端装饰。

您应该使用Spy ++来调查游戏的窗口结构。

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

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