user1219742
user1219742

Reputation:

Making two windows stick to eachother without a delay

I've created two windows with CreateWindowEx(), and now I'd like to stick them side-by-side, so that whenever one is moved, the other one moves relative to the other.

What's the right way of implementing this?

At the moment, I'm using this piece of code:

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.

The problem with this, is that whenever I move the window, the other window is dragged a few pixels behind.
Now, it doesn't look too bad, but I'd really prefer if it looked a bit more solid.

Upvotes: 1

Views: 658

Answers (1)

user1219742
user1219742

Reputation:

To fix this problem, I needed to change the case from WM_MOVING to WM_MOVE, and the function MoveWindow() to SetWindowPos().

Thank you to Martin James, who told me about "Windows API Docking". That was very helpful.

Upvotes: 1

Related Questions