C++ 如何在不改变y、宽度、高度的情况下设置按钮的X坐标
我知道我可以使用MoveWindow来移动它,但我只想移动x轴上的按钮。谢谢。我想出来了。您可以使用GetWindowRect获取按钮的屏幕位置,然后使用ScreenToClient获取按钮在表单中的位置。例如:C++ 如何在不改变y、宽度、高度的情况下设置按钮的X坐标,c++,winapi,C++,Winapi,我知道我可以使用MoveWindow来移动它,但我只想移动x轴上的按钮。谢谢。我想出来了。您可以使用GetWindowRect获取按钮的屏幕位置,然后使用ScreenToClient获取按钮在表单中的位置。例如: RECT buttonScreenRect; GetWindowRect(hwnd, &buttonScreenRect); POINT buttonClientPoint; buttonClientPoint.x = buttonScreenRect.left; butto
RECT buttonScreenRect;
GetWindowRect(hwnd, &buttonScreenRect);
POINT buttonClientPoint;
buttonClientPoint.x = buttonScreenRect.left;
buttonClientPoint.y = buttonScreenRect.top;
ScreenToClient(hwnd, &buttonClientPoint);
MoveWindow(hwnd, 50, buttonClientPoint.y, buttonScreenRect.right - buttonScreenRect.left, buttonScreenRect.bottom - buttonScreenRect.top);
希望有帮助 你应该更新你的问题以反映你真正想问的问题。任何人都不可能知道您真正的问题是如何从您最初的问题将屏幕坐标转换为客户坐标。