SetWindowPos/MoveWindow 仍然存在问题
我正在使用 SetWindowPos
和 MoveWindow
来调整窗口大小和居中。它工作正常,但在 Windows Media Player 或控制面板等多个窗口中,当您关闭窗口并再次打开它时,不会反映新的大小调整/移动。当我手动调整大小时,更改会在下次打开窗口时反映出来。即使我调用 UpdateWindow
,更改也不会反映。我需要发送一些东西来保存更改吗? RedrawWindow
有帮助吗?谢谢?
I am using SetWindowPos
and MoveWindow
to resize and center windows. It works fine, but on several windows like Windows Media Player or Control Panel, when you close the window and open it again, the new resizing/moving is not reflected. When I resize manually, the changes are reflected the next time I open the window. Even if I call UpdateWindow
, the changes don't reflect. Is there something I need to send the window so the changes get saved? Would RedrawWindow
help? Thanks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用
GetWindowPlacement
和SetWindowPlacement
函数用于检索和更改窗口的恢复、最小化和最大化位置。这可确保应用程序正确保存窗口大小,以便可以在下次启动时恢复它们。由于您使用的是 C#,因此您需要从 Windows API P/Invoke 这些函数:
You should be using the
GetWindowPlacement
andSetWindowPlacement
functions instead to retrieve and alter the restored, minimized, and maximized positions of a window. This ensures that the window sizes are properly saved by the application so that they can be restored on the next launch.Since you're using C#, you'll need to P/Invoke these functions from the Windows API: