The IVideoWindow_put_Visible runs the NtUserShowWindow which may trigger the VideoWindow_NotifyOwnerMessage with a WM_PAINT message and afterwards try to send a WM_ERASEBKND. This will cause the VideoWindow_NotifyOwnerMessage to be stuck waiting on the lock. This causes a deadlock because the IVideoWindow_put_Visible is never able to return, as it is waiting for the WM_ERASEBKND message to go through in the send_erase function, which can only go through once the WM_PAINT has returned.