我知道有一个函数可以接受客户端rect,它会将它转换为一个窗口rect。我只是找不到/记住它!

有谁知道它是什么?

它会做类似的事情:

const CRect client(0, 0, 200, 200);
const CRect window = ClientRectToWindowRect(client);
SetWindowPos(...)
有帮助吗?

解决方案

您可能正在考虑 AdjustWindowRectEx( ) 。请记住,这是在创建窗口时使用的 - 不能保证它会为现有窗口生成一组精确的窗口尺寸;为此,请使用 GetWindowRect()

其他提示

如果要将客户端坐标映射到窗口坐标,请使用 ClientToWindow API。

如果要将客户端坐标映射到屏幕坐标,请使用 ClientToScreen API。

对于控制重新定位使用:

RECT client;
::SetRect(&client, 0, 0, 200, 200);
::MapWindowPoints(hwndControl, ::GetParent(hwndControl), (POINT*)&client, 2);
::SetWindowPos(...)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top