tags:

views:

116

answers:

1

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.

A: 

The only reference to any kind of "abort" functionality I see is this:

If any of the windows in the multiple-window- position structure have the SWP_HIDEWINDOW or SWP_SHOWWINDOW flag set, none of the windows are repositioned.

This is coming from here.

Arkadiy
bit of a hack, but it would work.
decasteljau