Unicodification and typesafe interfaces.

This commit is contained in:
Dimitrie O. Paun 2005-03-14 10:09:24 +00:00 committed by Alexandre Julliard
parent 232760ded0
commit 5294ba5816
1 changed files with 139 additions and 137 deletions

View File

@ -3,7 +3,8 @@
* Animation control * Animation control
* *
* Copyright 1998, 1999 Eric Kohl * Copyright 1998, 1999 Eric Kohl
* 1999 Eric Pouech * Copyright 1999 Eric Pouech
* Copyright 2005 Dimitrie O. Paun
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -86,23 +87,23 @@ typedef struct
HBITMAP hbmPrevFrame; HBITMAP hbmPrevFrame;
} ANIMATE_INFO; } ANIMATE_INFO;
#define ANIMATE_GetInfoPtr(hWnd) ((ANIMATE_INFO *)GetWindowLongPtrW(hWnd, 0))
#define ANIMATE_COLOR_NONE 0xffffffff #define ANIMATE_COLOR_NONE 0xffffffff
static void ANIMATE_Notify(ANIMATE_INFO* infoPtr, UINT notif) static void ANIMATE_Notify(ANIMATE_INFO *infoPtr, UINT notif)
{ {
SendMessageA(infoPtr->hwndNotify, WM_COMMAND, SendMessageW(infoPtr->hwndNotify, WM_COMMAND,
MAKEWPARAM(GetDlgCtrlID(infoPtr->hwndSelf), notif), MAKEWPARAM(GetDlgCtrlID(infoPtr->hwndSelf), notif),
(LPARAM)infoPtr->hwndSelf); (LPARAM)infoPtr->hwndSelf);
} }
static BOOL ANIMATE_LoadResA(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpName) static BOOL ANIMATE_LoadResW(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPWSTR lpName)
{ {
static const WCHAR aviW[] = { 'A', 'V', 'I', 0 };
HRSRC hrsrc; HRSRC hrsrc;
MMIOINFO mminfo; MMIOINFO mminfo;
LPVOID lpAvi; LPVOID lpAvi;
hrsrc = FindResourceA(hInst, lpName, "AVI"); hrsrc = FindResourceW(hInst, lpName, aviW);
if (!hrsrc) if (!hrsrc)
return FALSE; return FALSE;
@ -118,8 +119,9 @@ static BOOL ANIMATE_LoadResA(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpNam
mminfo.fccIOProc = FOURCC_MEM; mminfo.fccIOProc = FOURCC_MEM;
mminfo.pchBuffer = (LPSTR)lpAvi; mminfo.pchBuffer = (LPSTR)lpAvi;
mminfo.cchBuffer = SizeofResource(hInst, hrsrc); mminfo.cchBuffer = SizeofResource(hInst, hrsrc);
infoPtr->hMMio = mmioOpenA(NULL, &mminfo, MMIO_READ); infoPtr->hMMio = mmioOpenW(NULL, &mminfo, MMIO_READ);
if (!infoPtr->hMMio) { if (!infoPtr->hMMio)
{
FreeResource(infoPtr->hRes); FreeResource(infoPtr->hRes);
return FALSE; return FALSE;
} }
@ -128,19 +130,15 @@ static BOOL ANIMATE_LoadResA(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpNam
} }
static BOOL ANIMATE_LoadFileA(ANIMATE_INFO *infoPtr, LPSTR lpName) static BOOL ANIMATE_LoadFileW(ANIMATE_INFO *infoPtr, LPWSTR lpName)
{ {
infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL, infoPtr->hMMio = mmioOpenW(lpName, 0, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
if (!infoPtr->hMMio) return (BOOL)infoPtr->hMMio;
return FALSE;
return TRUE;
} }
static LRESULT ANIMATE_DoStop(ANIMATE_INFO *infoPtr) static BOOL ANIMATE_DoStop(ANIMATE_INFO *infoPtr)
{ {
EnterCriticalSection(&infoPtr->cs); EnterCriticalSection(&infoPtr->cs);
@ -206,9 +204,6 @@ static void ANIMATE_Free(ANIMATE_INFO *infoPtr)
DeleteObject(infoPtr->hbmPrevFrame); DeleteObject(infoPtr->hbmPrevFrame);
infoPtr->hbmPrevFrame = 0; infoPtr->hbmPrevFrame = 0;
} }
infoPtr->indata = infoPtr->outdata = NULL;
infoPtr->hwndSelf = 0;
infoPtr->hMMio = 0;
memset(&infoPtr->mah, 0, sizeof(infoPtr->mah)); memset(&infoPtr->mah, 0, sizeof(infoPtr->mah));
memset(&infoPtr->ash, 0, sizeof(infoPtr->ash)); memset(&infoPtr->ash, 0, sizeof(infoPtr->ash));
@ -217,7 +212,7 @@ static void ANIMATE_Free(ANIMATE_INFO *infoPtr)
infoPtr->transparentColor = ANIMATE_COLOR_NONE; infoPtr->transparentColor = ANIMATE_COLOR_NONE;
} }
static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSource) static void ANIMATE_TransparentBlt(ANIMATE_INFO *infoPtr, HDC hdcDest, HDC hdcSource)
{ {
HDC hdcMask; HDC hdcMask;
HBITMAP hbmMask; HBITMAP hbmMask;
@ -249,7 +244,7 @@ static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSo
DeleteDC(hdcMask); DeleteDC(hdcMask);
} }
static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC)
{ {
void* pBitmapData = NULL; void* pBitmapData = NULL;
LPBITMAPINFO pBitmapInfo = NULL; LPBITMAPINFO pBitmapInfo = NULL;
@ -302,7 +297,7 @@ static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC)
infoPtr->transparentColor = GetPixel(hdcMem,0,0); infoPtr->transparentColor = GetPixel(hdcMem,0,0);
} }
if(GetWindowLongA(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT) if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT)
{ {
HDC hdcFinal = CreateCompatibleDC(hDC); HDC hdcFinal = CreateCompatibleDC(hDC);
HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight); HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight);
@ -327,7 +322,7 @@ static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC)
infoPtr->hbmPrevFrame = hbmFinal; infoPtr->hbmPrevFrame = hbmFinal;
} }
if (GetWindowLongA(infoPtr->hwndSelf, GWL_STYLE) & ACS_CENTER) if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_CENTER)
{ {
RECT rect; RECT rect;
@ -342,7 +337,7 @@ static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC)
return TRUE; return TRUE;
} }
static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr) static BOOL ANIMATE_DrawFrame(ANIMATE_INFO *infoPtr)
{ {
HDC hDC; HDC hDC;
@ -381,7 +376,7 @@ static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr)
static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_)
{ {
ANIMATE_INFO* infoPtr = (ANIMATE_INFO*)ptr_; ANIMATE_INFO *infoPtr = (ANIMATE_INFO *)ptr_;
HANDLE event; HANDLE event;
DWORD timeout; DWORD timeout;
@ -400,10 +395,8 @@ static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_)
return TRUE; return TRUE;
} }
static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam) static LRESULT ANIMATE_Play(ANIMATE_INFO *infoPtr, UINT cRepeat, WORD wFrom, WORD wTo)
{ {
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd);
/* nothing opened */ /* nothing opened */
if (!infoPtr->hMMio) if (!infoPtr->hMMio)
return FALSE; return FALSE;
@ -413,9 +406,9 @@ static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
} }
infoPtr->nFromFrame = (INT)LOWORD(lParam); infoPtr->nFromFrame = wFrom;
infoPtr->nToFrame = (INT)HIWORD(lParam); infoPtr->nToFrame = wTo;
infoPtr->nLoop = (INT)wParam; infoPtr->nLoop = cRepeat;
if (infoPtr->nToFrame == 0xFFFF) if (infoPtr->nToFrame == 0xFFFF)
infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1; infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1;
@ -429,20 +422,26 @@ static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam)
infoPtr->currFrame = infoPtr->nFromFrame; infoPtr->currFrame = infoPtr->nFromFrame;
if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TIMER) { if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TIMER)
{
TRACE("Using a timer\n"); TRACE("Using a timer\n");
/* create a timer to display AVI */ /* create a timer to display AVI */
infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL); infoPtr->uTimer = SetTimer(infoPtr->hwndSelf, 1,
} else { infoPtr->mah.dwMicroSecPerFrame / 1000, NULL);
if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) }
else
{ {
infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify, if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT)
WM_CTLCOLORSTATIC, 0, (LPARAM)hWnd); {
infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify,
WM_CTLCOLORSTATIC, 0,
(LPARAM)infoPtr->hwndSelf);
} }
TRACE("Using an animation thread\n"); TRACE("Using an animation thread\n");
infoPtr->hStopEvent = CreateEventW( NULL, TRUE, FALSE, NULL ); infoPtr->hStopEvent = CreateEventW( NULL, TRUE, FALSE, NULL );
infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &infoPtr->threadId); infoPtr->hThread = CreateThread(0, 0, ANIMATE_AnimationThread,
(LPVOID)infoPtr, 0, &infoPtr->threadId);
if(!infoPtr->hThread) if(!infoPtr->hThread)
{ {
ERR("Could not create animation thread!\n"); ERR("Could not create animation thread!\n");
@ -597,10 +596,8 @@ static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr)
infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
infoPtr->mah.dwTotalFrames * sizeof(DWORD)); infoPtr->mah.dwTotalFrames * sizeof(DWORD));
if (!infoPtr->lpIndex) { if (!infoPtr->lpIndex)
WARN("Can't alloc index array\n");
return FALSE; return FALSE;
}
numFrame = insize = 0; numFrame = insize = 0;
while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 &&
@ -621,10 +618,8 @@ static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr)
} }
infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize); infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize);
if (!infoPtr->indata) { if (!infoPtr->indata)
WARN("Can't alloc input buffer\n");
return FALSE; return FALSE;
}
return TRUE; return TRUE;
} }
@ -654,22 +649,19 @@ static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr)
(DWORD)infoPtr->inbih, 0L); (DWORD)infoPtr->inbih, 0L);
infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize); infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize);
if (!infoPtr->outbih) { if (!infoPtr->outbih)
WARN("Can't alloc output BIH\n");
return FALSE; return FALSE;
}
if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,
(DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != outSize) { (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != outSize)
{
WARN("Can't get output BIH\n"); WARN("Can't get output BIH\n");
return FALSE; return FALSE;
} }
infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage); infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage);
if (!infoPtr->outdata) { if (!infoPtr->outdata)
WARN("Can't alloc output buffer\n");
return FALSE; return FALSE;
}
if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN,
(DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) {
@ -680,74 +672,92 @@ static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr)
return TRUE; return TRUE;
} }
static LRESULT ANIMATE_OpenA(HWND hWnd, WPARAM wParam, LPARAM lParam) static BOOL ANIMATE_OpenW(ANIMATE_INFO *infoPtr, HINSTANCE hInstance, LPWSTR lpszName)
{ {
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd);
HINSTANCE hInstance = (HINSTANCE)wParam;
ANIMATE_Free(infoPtr); ANIMATE_Free(infoPtr);
infoPtr->hwndSelf = hWnd;
if (!lParam) { if (!lpszName)
{
TRACE("Closing avi!\n"); TRACE("Closing avi!\n");
/* installer of thebat! v1.62 requires FALSE here */ /* installer of thebat! v1.62 requires FALSE here */
return (infoPtr->hMMio != 0); return (infoPtr->hMMio != 0);
} }
if (!hInstance) if (!hInstance)
hInstance = (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE); hInstance = (HINSTANCE)GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_HINSTANCE);
if (HIWORD(lParam)) { if (HIWORD(lpszName))
TRACE("(\"%s\");\n", (LPSTR)lParam); {
TRACE("(\"%s\");\n", debugstr_w(lpszName));
if (!ANIMATE_LoadResA(infoPtr, hInstance, (LPSTR)lParam)) { if (!ANIMATE_LoadResW(infoPtr, hInstance, lpszName))
{
TRACE("No AVI resource found!\n"); TRACE("No AVI resource found!\n");
if (!ANIMATE_LoadFileA(infoPtr, (LPSTR)lParam)) { if (!ANIMATE_LoadFileW(infoPtr, lpszName))
{
WARN("No AVI file found!\n"); WARN("No AVI file found!\n");
return FALSE; return FALSE;
} }
} }
} else { }
TRACE("(%u);\n", (WORD)LOWORD(lParam)); else
{
TRACE("(%u);\n", (WORD)(DWORD)lpszName);
if (!ANIMATE_LoadResA(infoPtr, hInstance, if (!ANIMATE_LoadResW(infoPtr, hInstance, MAKEINTRESOURCEW((INT)lpszName)))
MAKEINTRESOURCEA((INT)lParam))) { {
WARN("No AVI resource found!\n"); WARN("No AVI resource found!\n");
return FALSE; return FALSE;
} }
} }
if (!ANIMATE_GetAviInfo(infoPtr)) { if (!ANIMATE_GetAviInfo(infoPtr))
{
WARN("Can't get AVI information\n"); WARN("Can't get AVI information\n");
ANIMATE_Free(infoPtr); ANIMATE_Free(infoPtr);
return FALSE; return FALSE;
} }
if (!ANIMATE_GetAviCodec(infoPtr)) { if (!ANIMATE_GetAviCodec(infoPtr))
{
WARN("Can't get AVI Codec\n"); WARN("Can't get AVI Codec\n");
ANIMATE_Free(infoPtr); ANIMATE_Free(infoPtr);
return FALSE; return FALSE;
} }
if (!GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { if (!GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_CENTER)
SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight, SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
}
if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_AUTOPLAY) { if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_AUTOPLAY)
return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1)); return ANIMATE_Play(infoPtr, -1, 0, infoPtr->mah.dwTotalFrames - 1);
}
return TRUE; return TRUE;
} }
/* << ANIMATE_Open32W >> */ static BOOL ANIMATE_OpenA(ANIMATE_INFO *infoPtr, HINSTANCE hInstance, LPSTR lpszName)
static LRESULT ANIMATE_Stop(HWND hWnd, WPARAM wParam, LPARAM lParam)
{ {
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd); LPWSTR lpwszName;
LRESULT result;
INT len;
if (!HIWORD(lpszName))
return ANIMATE_OpenW(infoPtr, hInstance, (LPWSTR)lpszName);
len = MultiByteToWideChar(CP_ACP, 0, lpszName, -1, NULL, 0);
lpwszName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!lpwszName) return FALSE;
MultiByteToWideChar(CP_ACP, 0, lpszName, -1, lpwszName, len);
result = ANIMATE_OpenW(infoPtr, hInstance, lpwszName);
HeapFree(GetProcessHeap(), 0, lpwszName);
return result;
}
static BOOL ANIMATE_Stop(ANIMATE_INFO *infoPtr)
{
/* nothing opened */ /* nothing opened */
if (!infoPtr->hMMio) if (!infoPtr->hMMio)
return FALSE; return FALSE;
@ -757,9 +767,10 @@ static LRESULT ANIMATE_Stop(HWND hWnd, WPARAM wParam, LPARAM lParam)
} }
static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam) static BOOL ANIMATE_Create(HWND hWnd, LPCREATESTRUCTW lpcs)
{ {
ANIMATE_INFO* infoPtr; static const WCHAR msvfw32W[] = { 'm', 's', 'v', 'f', 'w', '3', '2', '.', 'd', 'l', 'l', 0 };
ANIMATE_INFO *infoPtr;
if (!fnIC.hModule) /* FIXME: not thread safe */ if (!fnIC.hModule) /* FIXME: not thread safe */
{ {
@ -768,7 +779,7 @@ static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam)
* - handle it by hand * - handle it by hand
* AJ wants the latter :-( * AJ wants the latter :-(
*/ */
fnIC.hModule = LoadLibraryA("msvfw32.dll"); fnIC.hModule = LoadLibraryW(msvfw32W);
if (!fnIC.hModule) return FALSE; if (!fnIC.hModule) return FALSE;
fnIC.fnICOpen = (void*)GetProcAddress(fnIC.hModule, "ICOpen"); fnIC.fnICOpen = (void*)GetProcAddress(fnIC.hModule, "ICOpen");
@ -779,19 +790,16 @@ static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam)
/* allocate memory for info structure */ /* allocate memory for info structure */
infoPtr = (ANIMATE_INFO *)Alloc(sizeof(ANIMATE_INFO)); infoPtr = (ANIMATE_INFO *)Alloc(sizeof(ANIMATE_INFO));
if (!infoPtr) { if (!infoPtr) return FALSE;
ERR("could not allocate info memory!\n");
return 0;
}
/* store crossref hWnd <-> info structure */ /* store crossref hWnd <-> info structure */
SetWindowLongPtrW(hWnd, 0, (DWORD_PTR)infoPtr); SetWindowLongPtrW(hWnd, 0, (DWORD_PTR)infoPtr);
infoPtr->hwndSelf = hWnd; infoPtr->hwndSelf = hWnd;
infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent; infoPtr->hwndNotify = lpcs->hwndParent;
infoPtr->transparentColor = ANIMATE_COLOR_NONE; infoPtr->transparentColor = ANIMATE_COLOR_NONE;
infoPtr->hbmPrevFrame = 0; infoPtr->hbmPrevFrame = 0;
TRACE("Animate style=0x%08lx, parent=%p\n", GetWindowLongA(hWnd, GWL_STYLE), infoPtr->hwndNotify); TRACE("Animate style=0x%08lx, parent=%p\n", GetWindowLongW(hWnd, GWL_STYLE), infoPtr->hwndNotify);
InitializeCriticalSection(&infoPtr->cs); InitializeCriticalSection(&infoPtr->cs);
@ -799,97 +807,91 @@ static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam)
} }
static LRESULT ANIMATE_Destroy(HWND hWnd, WPARAM wParam, LPARAM lParam) static LRESULT ANIMATE_Destroy(ANIMATE_INFO *infoPtr)
{ {
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd);
/* free avi data */ /* free avi data */
ANIMATE_Free(infoPtr); ANIMATE_Free(infoPtr);
/* free animate info data */ /* free animate info data */
SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0);
Free(infoPtr); Free(infoPtr);
SetWindowLongPtrW(hWnd, 0, 0);
return 0; return 0;
} }
static LRESULT ANIMATE_EraseBackground(HWND hWnd, WPARAM wParam, LPARAM lParam) static BOOL ANIMATE_EraseBackground(ANIMATE_INFO *infoPtr, HDC hdc)
{ {
ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd);
RECT rect; RECT rect;
HBRUSH hBrush = 0; HBRUSH hBrush = 0;
if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT)
{ {
hBrush = (HBRUSH)SendMessageA(infoPtr->hwndNotify,WM_CTLCOLORSTATIC, hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLORSTATIC,
wParam, (LPARAM)hWnd); (WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
} }
GetClientRect(hWnd, &rect); GetClientRect(infoPtr->hwndSelf, &rect);
FillRect((HDC)wParam, &rect, hBrush ? hBrush : GetCurrentObject((HDC)wParam, OBJ_BRUSH)); FillRect(hdc, &rect, hBrush ? hBrush : GetCurrentObject(hdc, OBJ_BRUSH));
return TRUE; return TRUE;
} }
static LRESULT WINAPI ANIMATE_Size(HWND hWnd, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI ANIMATE_Size(ANIMATE_INFO *infoPtr, INT flags, WORD width, WORD height)
{ {
if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_CENTER)
InvalidateRect(hWnd, NULL, TRUE); {
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
} }
return TRUE; return TRUE;
} }
static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
ANIMATE_INFO *infoPtr = (ANIMATE_INFO *)GetWindowLongPtrW(hWnd, 0);
TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam); TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam);
if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE)) if (!infoPtr && (uMsg != WM_NCCREATE))
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case ACM_OPENA: case ACM_OPENA:
return ANIMATE_OpenA(hWnd, wParam, lParam); return ANIMATE_OpenA(infoPtr, (HINSTANCE)wParam, (LPSTR)lParam);
case ACM_OPENW: case ACM_OPENW:
FIXME("ACM_OPENW: stub!\n"); return ANIMATE_OpenW(infoPtr, (HINSTANCE)wParam, (LPWSTR)lParam);
/* return ANIMATE_Open32W(hWnd, wParam, lParam); */
return 0;
case ACM_PLAY: case ACM_PLAY:
return ANIMATE_Play(hWnd, wParam, lParam); return ANIMATE_Play(infoPtr, (INT)wParam, LOWORD(lParam), HIWORD(lParam));
case ACM_STOP: case ACM_STOP:
return ANIMATE_Stop(hWnd, wParam, lParam); return ANIMATE_Stop(infoPtr);
case WM_NCCREATE: case WM_NCCREATE:
return ANIMATE_Create(hWnd, wParam, lParam); return ANIMATE_Create(hWnd, (LPCREATESTRUCTW)lParam);
case WM_NCHITTEST: case WM_NCHITTEST:
return HTTRANSPARENT; return HTTRANSPARENT;
case WM_DESTROY: case WM_DESTROY:
return ANIMATE_Destroy(hWnd, wParam, lParam); return ANIMATE_Destroy(infoPtr);
case WM_ERASEBKGND: case WM_ERASEBKGND:
return ANIMATE_EraseBackground(hWnd, wParam, lParam); return ANIMATE_EraseBackground(infoPtr, (HDC)wParam);
/* case WM_STYLECHANGED: FIXME shall we do something ?? */ /* case WM_STYLECHANGED: FIXME shall we do something ?? */
case WM_TIMER: case WM_TIMER:
if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT)
{ {
ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify,
infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify,
WM_CTLCOLORSTATIC, WM_CTLCOLORSTATIC,
wParam, (LPARAM)hWnd); wParam, (LPARAM)infoPtr->hwndSelf);
} }
return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd)); return ANIMATE_DrawFrame(infoPtr);
case WM_PAINT: case WM_PAINT:
{ {
ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd);
/* the animation isn't playing, or has not decompressed /* the animation isn't playing, or has not decompressed
* (and displayed) the first frame yet, don't paint * (and displayed) the first frame yet, don't paint
*/ */
@ -897,13 +899,13 @@ static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
!infoPtr->hbmPrevFrame) !infoPtr->hbmPrevFrame)
{ {
/* default paint handling */ /* default paint handling */
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT)
infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify, infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify,
WM_CTLCOLORSTATIC, WM_CTLCOLORSTATIC,
wParam, (LPARAM)hWnd); wParam, (LPARAM)infoPtr->hwndSelf);
if (wParam) if (wParam)
{ {
@ -914,47 +916,47 @@ static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
else else
{ {
PAINTSTRUCT ps; PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps); HDC hDC = BeginPaint(infoPtr->hwndSelf, &ps);
EnterCriticalSection(&infoPtr->cs); EnterCriticalSection(&infoPtr->cs);
ANIMATE_PaintFrame(infoPtr, hDC); ANIMATE_PaintFrame(infoPtr, hDC);
LeaveCriticalSection(&infoPtr->cs); LeaveCriticalSection(&infoPtr->cs);
EndPaint(hWnd, &ps); EndPaint(infoPtr->hwndSelf, &ps);
} }
} }
break; break;
case WM_SIZE: case WM_SIZE:
return ANIMATE_Size(hWnd, wParam, lParam); return ANIMATE_Size(infoPtr, (INT)wParam, LOWORD(lParam), HIWORD(lParam));
default: default:
if ((uMsg >= WM_USER) && (uMsg < WM_APP)) if ((uMsg >= WM_USER) && (uMsg < WM_APP))
ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
return 0; return 0;
} }
void ANIMATE_Register(void) void ANIMATE_Register(void)
{ {
WNDCLASSA wndClass; WNDCLASSW wndClass;
ZeroMemory(&wndClass, sizeof(WNDCLASSA)); ZeroMemory(&wndClass, sizeof(WNDCLASSW));
wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
wndClass.lpfnWndProc = ANIMATE_WindowProc; wndClass.lpfnWndProc = ANIMATE_WindowProc;
wndClass.cbClsExtra = 0; wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = sizeof(ANIMATE_INFO *); wndClass.cbWndExtra = sizeof(ANIMATE_INFO *);
wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); wndClass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndClass.lpszClassName = ANIMATE_CLASSA; wndClass.lpszClassName = ANIMATE_CLASSW;
RegisterClassA(&wndClass); RegisterClassW(&wndClass);
} }
void ANIMATE_Unregister(void) void ANIMATE_Unregister(void)
{ {
UnregisterClassA(ANIMATE_CLASSA, NULL); UnregisterClassW(ANIMATE_CLASSW, NULL);
} }