Unicode file dialogs send and receive unicode messages.

This commit is contained in:
Mike McCormack 2004-07-21 21:16:19 +00:00 committed by Alexandre Julliard
parent 649b78d097
commit 8f6545cbcf
1 changed files with 96 additions and 37 deletions

View File

@ -781,27 +781,37 @@ HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
if(!fodInfos) return 0; if(!fodInfos) return 0;
if(fodInfos->unicode)
FIXME("sending OPENFILENAMEA structure. Hook is expecting OPENFILENAMEW!\n");
if(fodInfos->DlgInfos.hwndCustomDlg) if(fodInfos->DlgInfos.hwndCustomDlg)
{ {
OFNOTIFYA ofnNotify;
HRESULT ret; HRESULT ret;
ofnNotify.hdr.hwndFrom=hwndParentDlg;
ofnNotify.hdr.idFrom=0;
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
TRACE("CALL NOTIFY for %x\n", uCode); TRACE("CALL NOTIFY for %x\n", uCode);
ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify); if(fodInfos->unicode)
{
OFNOTIFYW ofnNotify;
ofnNotify.hdr.hwndFrom=hwndParentDlg;
ofnNotify.hdr.idFrom=0;
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = (LPOPENFILENAMEW) fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
ret = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
}
else
{
OFNOTIFYA ofnNotify;
ofnNotify.hdr.hwndFrom=hwndParentDlg;
ofnNotify.hdr.idFrom=0;
ofnNotify.hdr.code = uCode;
ofnNotify.lpOFN = fodInfos->ofnInfos;
ofnNotify.pszFile = NULL;
ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
}
TRACE("RET NOTIFY\n"); TRACE("RET NOTIFY\n");
return ret; return ret;
} }
return TRUE; return TRUE;
} }
HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPSTR buffer) HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)
{ {
UINT sizeUsed = 0, n, total; UINT sizeUsed = 0, n, total;
LPWSTR lpstrFileList = NULL; LPWSTR lpstrFileList = NULL;
@ -820,38 +830,71 @@ HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPSTR buffer)
TRACE("path >%s< filespec >%s< %d files\n", TRACE("path >%s< filespec >%s< %d files\n",
debugstr_w(lpstrCurrentDir),debugstr_w(lpstrFileList),n); debugstr_w(lpstrCurrentDir),debugstr_w(lpstrFileList),n);
total = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1, if( fodInfos->unicode )
NULL, 0, NULL, NULL);
total += WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
NULL, 0, NULL, NULL);
/* Prepend the current path */
n = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1,
buffer, size, NULL, NULL);
if(n<size)
{ {
/* 'n' includes trailing \0 */ LPWSTR bufW = buffer;
buffer[n-1] = '\\'; total = strlenW(lpstrCurrentDir) + 1 + sizeUsed;
WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
&buffer[n], size-n, NULL, NULL); /* Prepend the current path */
n = strlenW(lpstrCurrentDir) + 1;
strncpyW( bufW, lpstrCurrentDir, size );
if(n<size)
{
/* 'n' includes trailing \0 */
bufW[n-1] = '\\';
memcpy( &bufW[n], lpstrFileList, (size-n)*sizeof(WCHAR) );
}
TRACE("returned -> %s\n",debugstr_wn(bufW, total));
}
else
{
LPSTR bufA = buffer;
total = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1,
NULL, 0, NULL, NULL);
total += WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
NULL, 0, NULL, NULL);
/* Prepend the current path */
n = WideCharToMultiByte(CP_ACP, 0, lpstrCurrentDir, -1,
bufA, size, NULL, NULL);
if(n<size)
{
/* 'n' includes trailing \0 */
bufA[n-1] = '\\';
WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
&bufA[n], size-n, NULL, NULL);
}
TRACE("returned -> %s\n",debugstr_an(bufA, total));
} }
MemFree(lpstrFileList); MemFree(lpstrFileList);
TRACE("returned -> %s\n",debugstr_a(buffer));
return total; return total;
} }
HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPSTR buffer) HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)
{ {
UINT sizeUsed = 0; UINT sizeUsed = 0;
LPWSTR lpstrFileList = NULL; LPWSTR lpstrFileList = NULL;
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("CDM_GETSPEC:\n"); TRACE("CDM_GETSPEC:\n");
FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed); FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed, buffer, size, NULL, NULL); if( fodInfos->unicode )
{
LPWSTR bufW = buffer;
memcpy( bufW, lpstrFileList, sizeof(WCHAR)*sizeUsed );
}
else
{
LPSTR bufA = buffer;
sizeUsed = WideCharToMultiByte( CP_ACP, 0, lpstrFileList, sizeUsed,
NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
bufA, size, NULL, NULL);
}
MemFree(lpstrFileList); MemFree(lpstrFileList);
return sizeUsed; return sizeUsed;
@ -864,29 +907,45 @@ HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPSTR buffer)
*/ */
HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
char lpstrPath[MAX_PATH];
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);
if(!fodInfos) return -1; if(!fodInfos) return -1;
switch(uMsg) switch(uMsg)
{ {
case CDM_GETFILEPATH: case CDM_GETFILEPATH:
return FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPSTR)lParam); return FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam);
case CDM_GETFOLDERPATH: case CDM_GETFOLDERPATH:
TRACE("CDM_GETFOLDERPATH:\n"); TRACE("CDM_GETFOLDERPATH:\n");
SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath); if( fodInfos->unicode )
if ((LPSTR)lParam!=NULL) {
lstrcpynA((LPSTR)lParam,lpstrPath,(int)wParam); WCHAR lpstrPath[MAX_PATH], *bufW = (LPWSTR)lParam;
return strlen(lpstrPath); SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if (bufW)
lstrcpynW(bufW,lpstrPath,(int)wParam);
return strlenW(lpstrPath);
}
else
{
char lpstrPath[MAX_PATH], *bufA = (LPSTR)lParam;
SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);
if (bufA)
lstrcpynA(bufA,lpstrPath,(int)wParam);
return strlen(lpstrPath);
}
case CDM_GETSPEC: case CDM_GETSPEC:
return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam); return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);
case CDM_SETCONTROLTEXT: case CDM_SETCONTROLTEXT:
TRACE("CDM_SETCONTROLTEXT:\n"); TRACE("CDM_SETCONTROLTEXT:\n");
if ( 0 != lParam ) if ( lParam )
SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam ); {
if( fodInfos->unicode )
SetDlgItemTextW( hwnd, (UINT) wParam, (LPWSTR) lParam );
else
SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );
}
return TRUE; return TRUE;
case CDM_HIDECONTROL: case CDM_HIDECONTROL: