Click to See Complete Forum and Search --> : C++ dd9 fullscreen clipper


Mitsukai
December 10th, 2005, 03:31 PM
i have made a fullscreen clipper and works perfectly accept one thing.
when i minimize the surface is lost(duh).
but when i open the window again it takes a while before its restored. then whenits restored its lost again and then i have to open the menu to call the WM_PAINT msg for it to draw again.

this is how i restore/draw the surfaces.
const long CJDDraw::Clear(void)
{
#ifdef CJ_BUILDSAFE
if(p_IDDS == NULL)
return(p_hResult = DDERR_NOTINITIALIZED);
#endif

return(p_hResult = p_IDDS->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &CJDDBltFx));
}

const long CJDDraw::Draw(const unsigned long ulFlags = DDBLT_WAIT)
{
#ifdef CJ_BUILDSAFE
if(p_IDDS == NULL || p_IDDSP == NULL)
return(p_hResult = DDERR_NOTINITIALIZED);
#endif

return(p_hResult = p_IDDSP->Blt(&p_Screen, p_IDDS, &p_Screen, ulFlags, NULL));
}

virtual const long CJDDraw::Restore(void)
{
if(p_IDDS == NULL || p_IDDSP == NULL)
return(p_hResult = DDERR_NOTINITIALIZED);

p_hResult = p_IDDSP->Restore();
if(p_hResult != DD_OK)
return(p_hResult);

p_hResult = p_IDDS->Restore();
if(p_hResult != DD_OK)
return(p_hResult);

return(Clear());
}

void CJApp::DoEvents(void)
{
MSG Msg = {0};
while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}

static long __stdcall WndProc(HWND hWnd, unsigned int Msg, unsigned int wParam, long lParam)
{
switch(Msg)
{
case WM_PAINT:
while(CJDDraw.Draw() == DDERR_SURFACELOST)
{
CJDDraw.Restore();
CJApp.DoEvents();
}
break;
}

return(DefWindowProc(hWnd, Msg, wParam, lParam));
}