c++ - 让两个窗口毫不拖延地粘在一起

标签 c++ windows winapi window position

我已经使用 CreateWindowEx() 创建了两个窗口,现在我想将它们并排放置,这样无论何时移动一个窗口,另一个窗口都会相对移动。

什么是正确的实现方式?

目前,我正在使用这段代码:

case WM_MOVING: // When the main window is being moved
    GetWindowRect(hWnd, &rWnd); // Get the current position of the main window
    MoveWindow(hwStats, rWnd.right - 1, rWnd.top, 140, 450, 1); // Move the other window relative to the main window
    return 1; // WM_MOVING is handled by the application
    break; // Done.

这个问题是,每当我移动窗口时,另一个窗口就会被拖到后面几个像素。
现在,它看起来还不错,但如果它看起来更结实一点我真的更喜欢。

最佳答案

为了解决这个问题,我需要将 caseWM_MOVING 更改为 WM_MOVE,并将函数 MoveWindow() 更改为 SetWindowPos().

感谢 Martin James,他向我介绍了“Windows API 对接”。这很有帮助。

关于c++ - 让两个窗口毫不拖延地粘在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14537990/

相关文章:

windows - 在哪里可以找到详尽的 DCOM 文档?

c++ - 通过EM_FORMATRANGE缩放丰富编辑控件的呈现输出时的舍入错误

c++ - 预留座位问题

c++ - mfc中子窗口的onPaint在父窗口重绘

windows - 设置文件的创建日期

windows - x :Uid generator for Windows 8 projects

c++ - 如何读取 infile 中的指令,然后使用 infile 中的参数将函数形状写入 outfile

c++ - 使用 malloc 与 new

c++ - WinAPI ReportEvent - 未安装组件

c# - 调用 Windows API 函数设置自动增益控制