Win32 directx hardware surfaces

I’m trying to restore my hardware surfaces when someone alt-tabs (or
whatever) away from my game and then back again.
This is the code I’m trying to use, which is more or less exactly from the
example in the docs.

The problem is it gets trapped in the lock surface loop, and never manages
to lock the surface.

Any help would be greatly appreciated.

while ( SDL_BlitSurface(image_dat, NULL, display, dspRect) == -2 )

	while ( SDL_LockSurface(image_dat) < 0 )
	load(); // Loads the surface's data again

Get your FREE download of MSN Explorer at