msacm32: Convert acmFormatChoose internals to Unicode, implement acmFormatChoose[AW] on top of it.

This commit is contained in:
Eric Pouech 2012-08-12 10:03:41 +02:00 committed by Alexandre Julliard
parent 03ab4bea9c
commit 22789aa30e
1 changed files with 125 additions and 56 deletions

View File

@ -1,5 +1,3 @@
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/* /*
* MSACM32 library * MSACM32 library
* *
@ -45,13 +43,13 @@ struct MSACM_FillFormatData {
#define WINE_ACMFF_FORMAT 1 #define WINE_ACMFF_FORMAT 1
#define WINE_ACMFF_WFX 2 #define WINE_ACMFF_WFX 2
int mode; int mode;
char szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS]; WCHAR szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
PACMFORMATCHOOSEA afc; PACMFORMATCHOOSEW afc;
DWORD ret; DWORD ret;
}; };
static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid, static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
PACMFORMATTAGDETAILSA paftd, PACMFORMATTAGDETAILSW paftd,
DWORD_PTR dwInstance, DWORD_PTR dwInstance,
DWORD fdwSupport) DWORD fdwSupport)
{ {
@ -59,21 +57,21 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
switch (affd->mode) { switch (affd->mode) {
case WINE_ACMFF_TAG: case WINE_ACMFF_TAG:
if (SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, if (SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_FINDSTRINGEXACT, -1, CB_FINDSTRINGEXACT, -1,
(LPARAM)paftd->szFormatTag) == CB_ERR) (LPARAM)paftd->szFormatTag) == CB_ERR)
SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_ADDSTRING, 0, (LPARAM)paftd->szFormatTag); CB_ADDSTRING, 0, (LPARAM)paftd->szFormatTag);
break; break;
case WINE_ACMFF_FORMAT: case WINE_ACMFF_FORMAT:
if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) { if (strcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) {
HACMDRIVER had; HACMDRIVER had;
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) { if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
ACMFORMATDETAILSA afd; ACMFORMATDETAILSW afd;
unsigned int i, len; unsigned int i, len;
MMRESULT mmr; MMRESULT mmr;
char buffer[ACMFORMATDETAILS_FORMAT_CHARS+16]; WCHAR buffer[ACMFORMATDETAILS_FORMAT_CHARS+16];
afd.cbStruct = sizeof(afd); afd.cbStruct = sizeof(afd);
afd.dwFormatTag = paftd->dwFormatTag; afd.dwFormatTag = paftd->dwFormatTag;
@ -84,42 +82,45 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
afd.cbwfx = paftd->cbFormatSize; afd.cbwfx = paftd->cbFormatSize;
for (i = 0; i < paftd->cStandardFormats; i++) { for (i = 0; i < paftd->cStandardFormats; i++) {
static const WCHAR fmtW[] = {'%','d',' ','K','o','/','s','\0'};
int j;
afd.dwFormatIndex = i; afd.dwFormatIndex = i;
mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX); mmr = acmFormatDetailsW(had, &afd, ACM_FORMATDETAILSF_INDEX);
if (mmr == MMSYSERR_NOERROR) { if (mmr == MMSYSERR_NOERROR) {
lstrcpynA(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1); lstrcpynW(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1);
len = strlen(buffer); len = strlenW(buffer);
memset(buffer+len, ' ', ACMFORMATTAGDETAILS_FORMATTAG_CHARS - len); for (j = len; j < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; j++)
wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS, buffer[j] = ' ';
"%d Ko/s", wsprintfW(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
(afd.pwfx->nAvgBytesPerSec + 512) / 1024); fmtW, (afd.pwfx->nAvgBytesPerSec + 512) / 1024);
SendDlgItemMessageA(affd->hWnd, SendDlgItemMessageW(affd->hWnd,
IDD_ACMFORMATCHOOSE_CMB_FORMAT, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
CB_ADDSTRING, 0, (LPARAM)buffer); CB_ADDSTRING, 0, (LPARAM)buffer);
} }
} }
acmDriverClose(had, 0); acmDriverClose(had, 0);
SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
CB_SETCURSEL, 0, 0); CB_SETCURSEL, 0, 0);
HeapFree(MSACM_hHeap, 0, afd.pwfx); HeapFree(MSACM_hHeap, 0, afd.pwfx);
} }
} }
break; break;
case WINE_ACMFF_WFX: case WINE_ACMFF_WFX:
if (strcmp(affd->szFormatTag, paftd->szFormatTag) == 0) { if (strcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) {
HACMDRIVER had; HACMDRIVER had;
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) { if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
ACMFORMATDETAILSA afd; ACMFORMATDETAILSW afd;
afd.cbStruct = sizeof(afd); afd.cbStruct = sizeof(afd);
afd.dwFormatTag = paftd->dwFormatTag; afd.dwFormatTag = paftd->dwFormatTag;
afd.pwfx = affd->afc->pwfx; afd.pwfx = affd->afc->pwfx;
afd.cbwfx = affd->afc->cbwfx; afd.cbwfx = affd->afc->cbwfx;
afd.dwFormatIndex = SendDlgItemMessageA(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, afd.dwFormatIndex = SendDlgItemMessageW(affd->hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT,
CB_GETCURSEL, 0, 0); CB_GETCURSEL, 0, 0);
affd->ret = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX); affd->ret = acmFormatDetailsW(had, &afd, ACM_FORMATDETAILSF_INDEX);
acmDriverClose(had, 0); acmDriverClose(had, 0);
return TRUE; return TRUE;
} }
@ -134,7 +135,7 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
static BOOL MSACM_FillFormatTags(HWND hWnd) static BOOL MSACM_FillFormatTags(HWND hWnd)
{ {
ACMFORMATTAGDETAILSA aftd; ACMFORMATTAGDETAILSW aftd;
struct MSACM_FillFormatData affd; struct MSACM_FillFormatData affd;
memset(&aftd, 0, sizeof(aftd)); memset(&aftd, 0, sizeof(aftd));
@ -143,37 +144,37 @@ static BOOL MSACM_FillFormatTags(HWND hWnd)
affd.hWnd = hWnd; affd.hWnd = hWnd;
affd.mode = WINE_ACMFF_TAG; affd.mode = WINE_ACMFF_TAG;
acmFormatTagEnumA(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0); acmFormatTagEnumW(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, CB_SETCURSEL, 0, 0); SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, CB_SETCURSEL, 0, 0);
return TRUE; return TRUE;
} }
static BOOL MSACM_FillFormat(HWND hWnd) static BOOL MSACM_FillFormat(HWND hWnd)
{ {
ACMFORMATTAGDETAILSA aftd; ACMFORMATTAGDETAILSW aftd;
struct MSACM_FillFormatData affd; struct MSACM_FillFormatData affd;
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_RESETCONTENT, 0, 0); SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_RESETCONTENT, 0, 0);
memset(&aftd, 0, sizeof(aftd)); memset(&aftd, 0, sizeof(aftd));
aftd.cbStruct = sizeof(aftd); aftd.cbStruct = sizeof(aftd);
affd.hWnd = hWnd; affd.hWnd = hWnd;
affd.mode = WINE_ACMFF_FORMAT; affd.mode = WINE_ACMFF_FORMAT;
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETLBTEXT, CB_GETLBTEXT,
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETCURSEL, 0, 0), CB_GETCURSEL, 0, 0),
(LPARAM)affd.szFormatTag); (LPARAM)affd.szFormatTag);
acmFormatTagEnumA(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0); acmFormatTagEnumW(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_SETCURSEL, 0, 0); SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMAT, CB_SETCURSEL, 0, 0);
return TRUE; return TRUE;
} }
static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEA afc) static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEW afc)
{ {
ACMFORMATTAGDETAILSA aftd; ACMFORMATTAGDETAILSW aftd;
struct MSACM_FillFormatData affd; struct MSACM_FillFormatData affd;
memset(&aftd, 0, sizeof(aftd)); memset(&aftd, 0, sizeof(aftd));
@ -183,29 +184,29 @@ static MMRESULT MSACM_GetWFX(HWND hWnd, PACMFORMATCHOOSEA afc)
affd.mode = WINE_ACMFF_WFX; affd.mode = WINE_ACMFF_WFX;
affd.afc = afc; affd.afc = afc;
affd.ret = MMSYSERR_NOERROR; affd.ret = MMSYSERR_NOERROR;
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETLBTEXT, CB_GETLBTEXT,
SendDlgItemMessageA(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG, SendDlgItemMessageW(hWnd, IDD_ACMFORMATCHOOSE_CMB_FORMATTAG,
CB_GETCURSEL, 0, 0), CB_GETCURSEL, 0, 0),
(LPARAM)affd.szFormatTag); (LPARAM)affd.szFormatTag);
acmFormatTagEnumA(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0); acmFormatTagEnumW(NULL, &aftd, MSACM_FillFormatTagsCB, (DWORD_PTR)&affd, 0);
return affd.ret; return affd.ret;
} }
static const char* fmt_prop = "acmprop"; static const WCHAR fmt_prop[] = {'a','c','m','p','r','o','p','\0'};
static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg, static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
{ {
PACMFORMATCHOOSEA afc = (PACMFORMATCHOOSEA)GetPropA(hWnd, fmt_prop); PACMFORMATCHOOSEW afc = (PACMFORMATCHOOSEW)GetPropW(hWnd, fmt_prop);
TRACE("hwnd=%p msg=%i 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam); TRACE("hwnd=%p msg=%i 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam);
switch (msg) { switch (msg) {
case WM_INITDIALOG: case WM_INITDIALOG:
afc = (PACMFORMATCHOOSEA)lParam; afc = (PACMFORMATCHOOSEW)lParam;
SetPropA(hWnd, fmt_prop, (HANDLE)afc); SetPropW(hWnd, fmt_prop, (HANDLE)afc);
MSACM_FillFormatTags(hWnd); MSACM_FillFormatTags(hWnd);
MSACM_FillFormat(hWnd); MSACM_FillFormat(hWnd);
if ((afc->fdwStyle & ~(ACMFORMATCHOOSE_STYLEF_CONTEXTHELP| if ((afc->fdwStyle & ~(ACMFORMATCHOOSE_STYLEF_CONTEXTHELP|
@ -236,8 +237,8 @@ static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
break; break;
case IDD_ACMFORMATCHOOSE_BTN_HELP: case IDD_ACMFORMATCHOOSE_BTN_HELP:
if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP) if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_SHOWHELP)
SendMessageA(afc->hwndOwner, SendMessageW(afc->hwndOwner,
RegisterWindowMessageA(ACMHELPMSGSTRINGA), 0L, 0L); RegisterWindowMessageW(ACMHELPMSGSTRINGW), 0L, 0L);
break; break;
default: default:
@ -248,15 +249,15 @@ static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
break; break;
case WM_CONTEXTMENU: case WM_CONTEXTMENU:
if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP) if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
SendMessageA(afc->hwndOwner, SendMessageW(afc->hwndOwner,
RegisterWindowMessageA(ACMHELPMSGCONTEXTMENUA), RegisterWindowMessageW(ACMHELPMSGCONTEXTMENUW),
wParam, lParam); wParam, lParam);
break; break;
#if defined(WM_CONTEXTHELP) #if defined(WM_CONTEXTHELP)
case WM_CONTEXTHELP: case WM_CONTEXTHELP:
if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP) if (afc->fdwStyle & ACMFORMATCHOOSE_STYLEF_CONTEXTHELP)
SendMessageA(afc->hwndOwner, SendMessageW(afc->hwndOwner,
RegisterWindowMessageA(ACMHELPMSGCONTEXTHELPA), RegisterWindowMessageW(ACMHELPMSGCONTEXTHELPW),
wParam, lParam); wParam, lParam);
break; break;
#endif #endif
@ -273,8 +274,77 @@ static INT_PTR CALLBACK FormatChooseDlgProc(HWND hWnd, UINT msg,
*/ */
MMRESULT WINAPI acmFormatChooseA(PACMFORMATCHOOSEA pafmtc) MMRESULT WINAPI acmFormatChooseA(PACMFORMATCHOOSEA pafmtc)
{ {
return DialogBoxParamA(MSACM_hInstance32, MAKEINTRESOURCEA(DLG_ACMFORMATCHOOSE_ID), ACMFORMATCHOOSEW afcw;
pafmtc->hwndOwner, FormatChooseDlgProc, (LPARAM)pafmtc); MMRESULT ret;
LPWSTR title = NULL;
LPWSTR name = NULL;
LPWSTR templ = NULL;
DWORD sz;
afcw.cbStruct = sizeof(afcw);
afcw.fdwStyle = pafmtc->fdwStyle;
afcw.hwndOwner = pafmtc->hwndOwner;
afcw.pwfx = pafmtc->pwfx;
afcw.cbwfx = pafmtc->cbwfx;
if (pafmtc->pszTitle)
{
sz = MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTitle, -1, NULL, 0);
if (!(title = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
{
ret = MMSYSERR_NOMEM;
goto done;
}
MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTitle, -1, title, sz);
}
afcw.pszTitle = title;
if (pafmtc->pszName)
{
sz = MultiByteToWideChar(CP_ACP, 0, pafmtc->pszName, -1, NULL, 0);
if (!(name = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
{
ret = MMSYSERR_NOMEM;
goto done;
}
MultiByteToWideChar(CP_ACP, 0, pafmtc->pszName, -1, name, sz);
}
afcw.pszName = name;
afcw.cchName = pafmtc->cchName;
afcw.fdwEnum = pafmtc->fdwEnum;
afcw.pwfxEnum = pafmtc->pwfxEnum;
afcw.hInstance = pafmtc->hInstance;
if (pafmtc->pszTemplateName)
{
sz = MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTemplateName, -1, NULL, 0);
if (!(templ = HeapAlloc(GetProcessHeap(), 0, sz * sizeof(WCHAR))))
{
ret = MMSYSERR_NOMEM;
goto done;
}
MultiByteToWideChar(CP_ACP, 0, pafmtc->pszTemplateName, -1, templ, sz);
}
afcw.pszTemplateName = templ;
/* FIXME: hook procs not supported yet */
if (pafmtc->pfnHook)
{
FIXME("Unsupported hook procs\n");
ret = MMSYSERR_NOTSUPPORTED;
goto done;
}
ret = acmFormatChooseW(&afcw);
if (ret == MMSYSERR_NOERROR)
{
WideCharToMultiByte(CP_ACP, 0, afcw.szFormatTag, -1, pafmtc->szFormatTag, sizeof(pafmtc->szFormatTag),
NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, afcw.szFormat, -1, pafmtc->szFormat, sizeof(pafmtc->szFormat),
NULL, NULL);
if (pafmtc->pszName)
WideCharToMultiByte(CP_ACP, 0, afcw.pszName, -1, pafmtc->pszName, pafmtc->cchName, NULL, NULL);
}
done:
HeapFree(GetProcessHeap(), 0, title);
HeapFree(GetProcessHeap(), 0, name);
HeapFree(GetProcessHeap(), 0, templ);
return ret;
} }
/*********************************************************************** /***********************************************************************
@ -282,9 +352,8 @@ MMRESULT WINAPI acmFormatChooseA(PACMFORMATCHOOSEA pafmtc)
*/ */
MMRESULT WINAPI acmFormatChooseW(PACMFORMATCHOOSEW pafmtc) MMRESULT WINAPI acmFormatChooseW(PACMFORMATCHOOSEW pafmtc)
{ {
FIXME("(%p): stub\n", pafmtc); return DialogBoxParamW(MSACM_hInstance32, MAKEINTRESOURCEW(DLG_ACMFORMATCHOOSE_ID),
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); pafmtc->hwndOwner, FormatChooseDlgProc, (LPARAM)pafmtc);
return MMSYSERR_ERROR;
} }
/*********************************************************************** /***********************************************************************