I am doing a series of window resizing using the DeferWindowPos functionality. Suppose I already opened the DeferWindowPos handle, and called DeferWindowPos a few time, and now I want to cancel everything: not call EndDeferWindowPos. I tried CloseHandle( hDWP ), but it does not work (crash). If I simply return from my function, I assume it will leak an handle. It is possible to terminate the DeferWindowPos without calling EndDeferWindowPos?
// Initialize
HDWP hDWP = BeginDeferWindowPos( ... )
for( ... )
{
// Calculate new rectangle
CRect dcNew;
...
// Oh,now I want to return from my function, I want to cancel everything
// Accumulate
hDWP = DeferWindowPos( hDWP, hWnd, 0,
rcNew.left,
rcNew.top,
rcNew.Width(),
rcNew.Height(),
SWP_NOZORDER );
}
// Finally
BOOL bResult = EndDeferWindowPos( hDWP );
If this is not possible, I will simply accumulate them in a temporary vector, and call the Defer stuff at the end, when I am certain I want to do them all.