Original Post
Hi,
I''ve a little problem. The function bellow is called in a while, but it work one time and the second time (in the while) the application shut down suddently,
i''ve indicated you where is the bug... i don''t know why the creating function don''t work two times...
the call is like:
for (y = 0; y < j; y++)
{
for (x=0;x);
i++;
}
}
zone is a structure
thank you very much.
ps:
The is a lot of message box, but it''s to know where the function stop
LPDIRECTDRAWSURFACE7 bitmap_surface(LPCTSTR file_name)
{
HDC hdc;
HBITMAP bit;
LPDIRECTDRAWSURFACE7 surf;
bit=(HBITMAP) LoadImage(NULL,file_name,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
if (!bit)
return NULL;
BITMAP bitmap;
GetObject( bit, sizeof(BITMAP), &bitmap);
int surf_width = bitmap.bmWidth;
int surf_height = bitmap.bmHeight;
DDSURFACEDESC2 DDSD2Desc;
memset (&DDSD2Desc, 0, sizeof (DDSURFACEDESC2));
DDSD2Desc.dwSize = sizeof (DDSURFACEDESC2);
DDSD2Desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
DDSD2Desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
DDSD2Desc.dwHeight = surf_height;
DDSD2Desc.dwWidth = surf_width;
MessageBox(hWindow,"creation of the surface","prob",MB_OK);
HResult = lpDD7Interface->CreateSurface (&DDSD2Desc,
&surf,
NULL); // here the application bug the second time
MessageBox(hWindow,"surface created","prob",MB_OK);
if (HResult!=DD_OK)
{
MessageBox(hWindow,"surface BMP","prob",MB_OK);
Jeux_Quit();
return(0);
}else{
MessageBox(hWindow,"surface BMP","prob",MB_OK);
surf->GetDC(&hdc);
HDC bit_dc = CreateCompatibleDC(hdc);
SelectObject(bit_dc,bit);
BitBlt(hdc, 0,0, surf_width, surf_height,bit_dc,0,0,SRCCOPY);
surf->ReleaseDC(hdc);
DeleteDC(bit_dc);
DeleteObject(bit);
return surf;
}
}
thanks again