Thursday, July 30, 2009

Show bitmaps from other folders using C++?

I'm using Dev-C++ to make a game I can make the bitmaps appear but they must be in the same folder as the files with the code for the game for the bitmaps to be found.





The code for the file that show the pictures is





#include%26lt;windows.h%26gt;





int LoadPicture(char* FileName,int x,int y,int width,int height,HWND hwnd);





int LoadPicture(char* FileName,int x,int y,int width,int height,HWND hwnd)








{


BITMAP bm;


HDC hdc = GetDC(hwnd);


HBITMAP BitHandle = (HBITMAP)LoadImage(NULL, FileName, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE);


if(BitHandle == NULL)


{


MessageBox(0,"The specified bitmap was not found","Program Error",


MB_ICONERROR | MB_SYSTEMMODAL | MB_OK);


}


HDC dc = CreateCompatibleDC(hdc);


SelectObject(dc, BitHandle);


GetObject(BitHandle, sizeof(BITMAP), %26amp;bm);


BitBlt(hdc, x, y,width,height, dc, 0,0, SRCCOPY);


ReleaseDC(hwnd, hdc);


return(0);


}





Is there a way to include the folders with #include.

Show bitmaps from other folders using C++?
yeah


No comments:

Post a Comment