Handle moving with CSplitterWindowImpl and invalidate child panes

151 Views Asked by At

I need to invalidate two panes when splitter is moving in WTL. Currently one of them invalidating when splitter is moving and other is invalidating when splitter moving stopped. How can I handle splitter moving?

1

There are 1 best solutions below

0
On

You typically don't need to invalidate explicitly because splitter moves child windows and they receive regular messages like WM_SIZE causing UI updates. The question itself suggests that something is incorrect with child windows.

You certainly can overwrite splitter's UpdateWindow to handle end of splitter repositioning, but you don't normally need to do it. Splitter itself invalidates itself applies SetWindowPos to panes in its helper UpdateSplitterLayout method, which you can step through with debugger to make sure this code is being executed.

LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    // [...]
            if(m_bFullDrag)
            {
                if(pT->SetSplitterPos(xyNewSplitPos, true))
                    pT->UpdateWindow();

bool SetSplitterPos(int xyPos = -1, bool bUpdate = true)
{
    // [...]
        UpdateSplitterLayout();

void UpdateSplitterLayout()
{
    // [...]
        for(int nPane = 0; nPane < m_nPanesCount; nPane++)
        {
            // [...]
                    ::SetWindowPos(m_hWndPane[nPane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);

You might want to ensure m_bFullDrag is set to TRUE to force repaints while moving is in progress.