I'm setting up a simple window in c++ Win32 which will show GIF animation as background. And the file is in directory of executable+gifs\test.gif. And how to split executable name then append other path???? How can I do it?
I've tried with giving full path of gif and it worked, but it won't work on another computer.
#define DRAW_ANIM 1
static HWND hWnd;
static HDC hMWDC;
static Graphics* pGphcs = NULL;
static Image* pImg = NULL;
static unsigned int nFrm = 0, nFrmCnt = 0;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE:
hMWDC = GetDC(hwnd);
pGphcs = new Graphics(hMWDC);
pImg = new Image(L"gifs\\test.gif");
if (pImg) {
nFrmCnt = pImg->GetFrameCount(&FrameDimensionTime);
SetTimer(hwnd, DRAW_ANIM, 100, NULL);
}
break;
case WM_TIMER:
if (wParam == DRAW_ANIM)
{
pImg->SelectActiveFrame(&FrameDimensionTime, nFrm);
Rect DRC(0, 0, pImg->GetWidth(), pImg->GetHeight());
pGphcs->Clear(Color(128, 128, 128));
pGphcs->DrawImage(pImg, DRC);
if (nFrm < (nFrmCnt - 1)) nFrm++; else nFrm = 0;
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
delete pGphcs;
delete pImg;
ReleaseDC(hwnd, hMWDC);
KillTimer(hwnd, DRAW_ANIM);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
I expect a gif showing, but nothing. ;(