Commit be6d014f authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Add Unicode->ANSI MCI message mapping, implement mciSendCommandW, fix

a bug with a window creation belonging to another hInstance, add support for MCI_WINDOW command in mciavi.drv, add support for MCI_PLAY and MCI_STOP in the MCIWndClass implementation.
parent 042f8953
......@@ -60,7 +60,7 @@ typedef struct
SendMessageW((info)->hwndOwner, MCIWNDM_NOTIFYMODE, (WPARAM)(info)->hWnd, (LPARAM)SendMessageW((info)->hWnd, MCIWNDM_GETMODEW, 0, 0))
#define MCIWND_NOTIFY_SIZE(info) \
if (mwi->dwStyle & MCIWNDF_NOTIFYSIZE) \
if ((info)->dwStyle & MCIWNDF_NOTIFYSIZE) \
SendMessageW((info)->hwndOwner, MCIWNDM_NOTIFYSIZE, (WPARAM)(info)->hWnd, 0);
#define MCIWND_NOTIFY_ERROR(info) \
......@@ -84,7 +84,13 @@ BOOL VFWAPIV MCIWndRegisterClass(HINSTANCE hInst)
{
WNDCLASSW wc;
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_OWNDC;
/* Since we are going to register a class belonging to MSVFW32
* and later we will create windows with a different hInstance
* CS_GLOBALCLASS is needed. And because the second attempt
* to register a global class will fail we need to test whether
* the class was already registered.
*/
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_OWNDC | CS_GLOBALCLASS;
wc.lpfnWndProc = MCIWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(MCIWndInfo*);
......@@ -95,7 +101,10 @@ BOOL VFWAPIV MCIWndRegisterClass(HINSTANCE hInst)
wc.lpszMenuName = NULL;
wc.lpszClassName = mciWndClassW;
return RegisterClassW(&wc);
if (RegisterClassW(&wc)) return TRUE;
if (GetLastError() == ERROR_CLASS_ALREADY_EXISTS) return TRUE;
return FALSE;
}
/***********************************************************************
......@@ -394,7 +403,6 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa
MCIWND_NOTIFY_MODE(mwi);
return 0;
case MCIWNDM_OPENA:
{
UNICODE_STRING nameW;
......@@ -450,10 +458,6 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa
(DWORD_PTR)&mci_devcaps);
if (mwi->lasterror)
{
WCHAR error_str[MAXERRORLENGTH];
mciGetErrorStringW(mwi->lasterror, error_str, MAXERRORLENGTH);
MCIWND_NOTIFY_ERROR(mwi);
goto end_of_mci_open;
}
......@@ -486,10 +490,8 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa
if (!(mwi->dwStyle & MCIWNDF_NOPLAYBAR))
rc.bottom += 32; /* add the height of the playbar */
SetWindowPos(hWnd, 0, 0, 0, rc.right - rc.left,
rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER);
rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
if (mwi->dwStyle & MCIWNDF_NOOPEN)
ShowWindow(mwi->hWnd, SW_SHOW);
MCIWND_NOTIFY_MEDIA(mwi);
SendDlgItemMessageW(hWnd, CTL_TRACKBAR, TBM_SETRANGEMIN, 0L, 0L);
......@@ -670,6 +672,27 @@ end_of_mci_open:
mwi->hwndOwner = (HWND)wParam;
return 0;
case MCI_PLAY:
{
LRESULT end = SendMessageW(hWnd, MCIWNDM_GETEND, 0, 0);
return SendMessageW(hWnd, MCIWNDM_PLAYTO, 0, end);
}
case MCI_STOP:
{
MCI_GENERIC_PARMS mci_generic;
mci_generic.dwCallback = 0;
mwi->lasterror = mciSendCommandW(mwi->mci, MCI_STOP, 0, (DWORD_PTR)&mci_generic);
if (mwi->lasterror)
{
MCIWND_NOTIFY_ERROR(mwi);
return mwi->lasterror;
}
return 0;
}
case MCI_SEEK:
{
MCI_SEEK_PARMS mci_seek;
......@@ -697,16 +720,20 @@ end_of_mci_open:
}
case MCI_CLOSE:
if (mwi->mci)
{
MCI_GENERIC_PARMS mci_generic;
mci_generic.dwCallback = 0;
mciSendCommandW(mwi->mci, MCI_CLOSE, 0, (DWORD_PTR)&mci_generic);
mwi->mci = 0;
mwi->lasterror = mciSendCommandW(mwi->mci, MCI_CLOSE, 0, (DWORD_PTR)&mci_generic);
if (mwi->lasterror)
{
MCIWND_NOTIFY_ERROR(mwi);
return mwi->lasterror;
}
return 0;
}
}
if ((wMsg >= WM_USER) && (wMsg < WM_APP))
{
......
......@@ -1157,7 +1157,7 @@ BOOL WINAPI mciFreeCommandResource(UINT uTable)
/**************************************************************************
* MCI_SendCommandFrom32 [internal]
*/
DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
DWORD MCI_SendCommandFrom32(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
DWORD dwRet = MCIERR_INVALID_DEVICE_ID;
LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID);
......@@ -1192,7 +1192,7 @@ DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
/**************************************************************************
* MCI_SendCommandFrom16 [internal]
*/
DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
DWORD MCI_SendCommandFrom16(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
DWORD dwRet = MCIERR_INVALID_DEVICE_ID;
LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID);
......
......@@ -401,8 +401,8 @@ DWORD MCIAVI_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMSA lpPar
TRACE("MCI_DGV_STATUS_HPAL => %lx\n", lpParms->dwReturn);
break;
case MCI_DGV_STATUS_HWND:
lpParms->dwReturn = (DWORD)wma->hWnd;
TRACE("MCI_DGV_STATUS_HWND => %p\n", wma->hWnd);
lpParms->dwReturn = (DWORD)wma->hWndPaint;
TRACE("MCI_DGV_STATUS_HWND => %p\n", wma->hWndPaint);
break;
#if 0
case MCI_DGV_STATUS_KEY_COLOR:
......
......@@ -135,7 +135,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
static DWORD MCIAVI_drvOpen(LPSTR str, LPMCI_OPEN_DRIVER_PARMSA modp)
{
WINE_MCIAVI* wma;
static WCHAR mciAviWStr[] = {'M','C','I','A','V','I',0};
static const WCHAR mciAviWStr[] = {'M','C','I','A','V','I',0};
if (!modp) return 0xFFFFFFFF;
......@@ -356,7 +356,7 @@ static DWORD MCIAVI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
if (!wma->hFile) return MCIERR_FILE_NOT_FOUND;
if (!wma->hWnd) return MCIERR_NO_WINDOW;
if (!wma->hWndPaint) return MCIERR_NO_WINDOW;
wma->dwStatus = MCI_MODE_PLAY;
......@@ -365,7 +365,7 @@ static DWORD MCIAVI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms
(DWORD)lpParms, sizeof(MCI_PLAY_PARMS));
}
ShowWindow(wma->hWnd, SW_SHOW);
ShowWindow(wma->hWndPaint, SW_SHOW);
dwFromFrame = wma->dwCurrVideoFrame;
dwToFrame = wma->dwPlayableVideoFrames - 1;
......
......@@ -575,13 +575,12 @@ LRESULT MCIAVI_DrawFrame(WINE_MCIAVI* wma)
return FALSE;
}
if (IsWindowVisible(wma->hWnd) && (hDC = GetDC(wma->hWnd)) != 0) {
if (IsWindowVisible(wma->hWndPaint) && (hDC = GetDC(wma->hWndPaint)) != 0) {
MCIAVI_PaintFrame(wma, hDC);
ReleaseDC(wma->hWnd, hDC);
ReleaseDC(wma->hWndPaint, hDC);
}
LeaveCriticalSection(&wma->cs);
return TRUE;
}
......@@ -72,7 +72,7 @@ typedef struct {
HANDLE hEvent; /* for synchronization */
DWORD dwEventCount; /* for synchronization */
/* data for play back */
HWND hWnd;
HWND hWnd, hWndPaint;
DWORD dwCurrVideoFrame; /* video frame to display and current position */
DWORD dwCurrAudioBlock; /* current audio block being played */
/* data for the background mechanism */
......
......@@ -87,6 +87,7 @@ BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM
HWND hParent = 0;
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
int p = CW_USEDEFAULT;
RECT rc;
/* what should be done ? */
if (wma->hWnd) return TRUE;
......@@ -106,11 +107,17 @@ BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM
if (dwFlags & MCI_DGV_OPEN_WS) dwStyle = lpOpenParms->dwStyle;
if (dwStyle & WS_CHILD) p = 0;
rc.left = p;
rc.top = p;
rc.right = (wma->hic ? wma->outbih : wma->inbih)->biWidth;
rc.bottom = (wma->hic ? wma->outbih : wma->inbih)->biHeight;
AdjustWindowRect(&rc, dwStyle, FALSE);
wma->hWnd = CreateWindowA("MCIAVI", "Wine MCI-AVI player",
dwStyle, p, p,
(wma->hic ? wma->outbih : wma->inbih)->biWidth,
(wma->hic ? wma->outbih : wma->inbih)->biHeight,
dwStyle, rc.left, rc.top,
rc.right, rc.bottom,
hParent, 0, MCIAVI_hInstance, wma);
wma->hWndPaint = wma->hWnd;
return (BOOL)wma->hWnd;
}
......@@ -193,7 +200,7 @@ DWORD MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
}
if (dwFlags & MCI_DGV_WHERE_WINDOW) {
x = "Window";
GetClientRect(wma->hWnd, &lpParms->rc);
GetClientRect(wma->hWndPaint, &lpParms->rc);
}
TRACE("%s -> (%ld,%ld,%ld,%ld)\n",
x, lpParms->rc.left, lpParms->rc.top, lpParms->rc.right, lpParms->rc.bottom);
......@@ -214,20 +221,18 @@ DWORD MCIAVI_mciWindow(UINT wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSA lpPar
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
if (dwFlags & MCI_DGV_WINDOW_HWND) {
FIXME("Setting hWnd to %08lx\n", (DWORD)lpParms->hWnd);
#if 0
if (wma->hWnd) DestroyWindow(wma->hWnd);
/* is the window to be subclassed ? */
wma->hWnd = lpParms->hWnd;
#endif
TRACE("Setting hWnd to %p\n", lpParms->hWnd);
if (wma->hWnd) ShowWindow(wma->hWnd, SW_HIDE);
wma->hWndPaint = (lpParms->hWnd == MCI_DGV_WINDOW_DEFAULT) ? wma->hWnd : lpParms->hWnd;
InvalidateRect(wma->hWndPaint, NULL, FALSE);
}
if (dwFlags & MCI_DGV_WINDOW_STATE) {
TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow);
ShowWindow(wma->hWnd, lpParms->nCmdShow);
ShowWindow(wma->hWndPaint, lpParms->nCmdShow);
}
if (dwFlags & MCI_DGV_WINDOW_TEXT) {
TRACE("Setting caption to '%s'\n", lpParms->lpstrText);
SetWindowTextA(wma->hWnd, lpParms->lpstrText);
SetWindowTextA(wma->hWndPaint, lpParms->lpstrText);
}
return 0;
......
......@@ -1407,8 +1407,8 @@ MMRESULT WINAPI mmioCreateChunk(HMMIO,MMCKINFO*,UINT);
typedef UINT (CALLBACK *YIELDPROC)(MCIDEVICEID,DWORD);
DWORD WINAPI mciSendCommandA(UINT,UINT,DWORD,DWORD);
DWORD WINAPI mciSendCommandW(UINT,UINT,DWORD,DWORD);
DWORD WINAPI mciSendCommandA(MCIDEVICEID,UINT,DWORD_PTR,DWORD_PTR);
DWORD WINAPI mciSendCommandW(MCIDEVICEID,UINT,DWORD_PTR,DWORD_PTR);
#define mciSendCommand WINELIB_NAME_AW(mciSendCommand)
DWORD WINAPI mciSendStringA(LPCSTR,LPSTR,UINT,HWND);
DWORD WINAPI mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND);
......@@ -1416,12 +1416,12 @@ DWORD WINAPI mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND);
UINT WINAPI mciGetDeviceIDA(LPCSTR);
UINT WINAPI mciGetDeviceIDW(LPCWSTR);
#define mciGetDeviceID WINELIB_NAME_AW(mciGetDeviceID)
BOOL WINAPI mciGetErrorStringA(DWORD,LPSTR,UINT);
BOOL WINAPI mciGetErrorStringW(DWORD,LPWSTR,UINT);
BOOL WINAPI mciGetErrorStringA(MCIERROR,LPSTR,UINT);
BOOL WINAPI mciGetErrorStringW(MCIERROR,LPWSTR,UINT);
#define mciGetErrorString WINELIB_NAME_AW(mciGetErrorString)
BOOL WINAPI mciSetYieldProc(UINT,YIELDPROC,DWORD);
HTASK WINAPI mciGetCreatorTask(UINT);
YIELDPROC WINAPI mciGetYieldProc(UINT,DWORD*);
BOOL WINAPI mciSetYieldProc(MCIDEVICEID,YIELDPROC,DWORD);
HTASK WINAPI mciGetCreatorTask(MCIDEVICEID);
YIELDPROC WINAPI mciGetYieldProc(MCIDEVICEID,DWORD*);
#define MCIERR_INVALID_DEVICE_ID (MCIERR_BASE + 1)
#define MCIERR_UNRECOGNIZED_KEYWORD (MCIERR_BASE + 3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment