Mr. Griff gave the reasons for the problem. Sometimes it is rather difficult to work around so I use the following little class to help :
class LockWinUpdate
{
public:
LockWinUpdate( CWnd *pw )
{
m_pWnd = pw;
m_pWnd->LockWindowUpdate();
}
virtual ~LockWinUpdate()
{
m_pWnd->UnlockWindowUpdate();
}
protected:
CWnd * m_pWnd { nullptr };
};
To use this, create an instance where updates should be locked and set the scoping of the object such that the object is deleted when you want updates to be unlocked. Something like this :
{
LockWinUpdate lockem( this );
}