Hey, ok hes whats going down, this dll of mine has the following function:
Now the problem is when this is refernenced from vb the dll works until the LoadImage function (about 10 lines). Can anyone fix this error at all maybe ish, basically i need to load an image from a directory to a HBITMAP structre. The app performs an illgel operation after the MessageBox lineCode:int __stdcall SystemLoadBitmap(IDirectDraw7 * dd, char *szFilename, IDirectDrawSurface7 * ddsSurface, int x, int y, int width, int height)
{
HDC hdcImage;
HDC hdc;
BITMAP bm;
DDSURFACEDESC2 ddsd;
HRESULT hr;
HBITMAP hbm;
MessageBox(NULL, szFilename, "System.dll", MB_OK);
hbm = (HBITMAP) LoadImage( NULL, szFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if (hbm)
{
ddsSurface->Restore();
hdcImage = CreateCompatibleDC(NULL);
if (!hdcImage)
return -1;
SelectObject(hdcImage, hbm);
GetObject(hbm, sizeof(bm), &bm);
width = width == 0 ? bm.bmWidth : width;
height = height == 0 ? bm.bmHeight : height;
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
ddsSurface->GetSurfaceDesc(&ddsd);
if ((hr = ddsSurface->GetDC(&hdc)) == DD_OK)
{
StretchBlt( hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage, x, y, width, height, SRCCOPY);
ddsSurface->ReleaseDC(hdc);
}
DeleteDC(hdcImage);
DeleteObject(hbm);
return 1;
}
else
{
return -2;
}
}
I can mail the vb code i have done if this helps ?
