diff --git a/reactos/dll/win32/comdlg32/colordlg.c b/reactos/dll/win32/comdlg32/colordlg.c index 88e8f9206a0..590e6a8351a 100644 --- a/reactos/dll/win32/comdlg32/colordlg.c +++ b/reactos/dll/win32/comdlg32/colordlg.c @@ -235,7 +235,7 @@ static void CC_DrawFocusRect(CCPRIV *lpp, HWND hwnd, int x, int y, int rows, int /* draw it */ hdc = GetDC(hwnd); DrawFocusRect(hdc, &rect); - CopyRect(&lpp->focusRect, &rect); + lpp->focusRect = rect; lpp->hwndFocus = hwnd; ReleaseDC(hwnd, hdc); } diff --git a/reactos/dll/win32/comdlg32/filedlg.c b/reactos/dll/win32/comdlg32/filedlg.c index 023768991a0..5baaf299094 100644 --- a/reactos/dll/win32/comdlg32/filedlg.c +++ b/reactos/dll/win32/comdlg32/filedlg.c @@ -196,6 +196,7 @@ LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl); static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName); static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl); static UINT GetNumSelected( IDataObject *doSelected ); +static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium); /* Shell memory allocation */ static void *MemAlloc(UINT size); @@ -3587,6 +3588,25 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd) RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr); } +/*********************************************************************** + * get_def_format + * + * Fill the FORMATETC used in the shell id list + */ +static FORMATETC get_def_format(void) +{ + static CLIPFORMAT cfFormat; + FORMATETC formatetc; + + if (!cfFormat) cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLISTA); + formatetc.cfFormat = cfFormat; + formatetc.ptd = 0; + formatetc.dwAspect = DVASPECT_CONTENT; + formatetc.lindex = -1; + formatetc.tymed = TYMED_HGLOBAL; + return formatetc; +} + /*********************************************************************** * FILEDLG95_FILENAME_FillFromSelection * @@ -3596,84 +3616,72 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) { FileOpenDlgInfos *fodInfos; LPITEMIDLIST pidl; - UINT nFiles = 0, nFileToOpen, nFileSelected, nLength = 0; - WCHAR lpstrTemp[MAX_PATH]; - LPWSTR lpstrAllFile, lpstrCurrFile; + LPWSTR lpstrAllFiles, lpstrTmp; + UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength; + STGMEDIUM medium; + LPIDA cida; + FORMATETC formatetc = get_def_format(); TRACE("\n"); fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr); - /* Count how many files we have */ - nFileSelected = GetNumSelected( fodInfos->Shell.FOIDataObject ); + if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, &medium))) + return; - /* calculate the string length, count files */ - if (nFileSelected >= 1) + cida = GlobalLock(medium.u.hGlobal); + nFileSelected = cida->cidl; + + /* Allocate a buffer */ + nAllFilesMaxLength = MAX_PATH + 3; + lpstrAllFiles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nAllFilesMaxLength * sizeof(WCHAR)); + if (!lpstrAllFiles) + goto ret; + + /* Loop through the selection, handle only files (not folders) */ + for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++) { - nLength += 3; /* first and last quotes, trailing \0 */ - for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ ) - { - pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 ); - + pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]); if (pidl) - { - /* get the total length of the selected file names */ - lpstrTemp[0] = '\0'; - GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp ); - - if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* Ignore folders */ - { - nLength += lstrlenW( lpstrTemp ) + 3; - nFiles++; - } - COMDLG32_SHFree( pidl ); - } - } + { + if (!IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) + { + if (nAllFilesLength + MAX_PATH + 3 > nAllFilesMaxLength) + { + nAllFilesMaxLength *= 2; + lpstrTmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpstrAllFiles, nAllFilesMaxLength * sizeof(WCHAR)); + if (!lpstrTmp) + goto ret; + lpstrAllFiles = lpstrTmp; + } + nFiles += 1; + lpstrAllFiles[nAllFilesLength++] = '"'; + GetName(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, lpstrAllFiles + nAllFilesLength); + nThisFileLength = lstrlenW(lpstrAllFiles + nAllFilesLength); + nAllFilesLength += nThisFileLength; + lpstrAllFiles[nAllFilesLength++] = '"'; + lpstrAllFiles[nAllFilesLength++] = ' '; + } + } } - /* allocate the buffer */ - if (nFiles <= 1) nLength = MAX_PATH; - lpstrAllFile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * sizeof(WCHAR)); - - /* Generate the string for the edit control */ - if(nFiles >= 1) + if (nFiles != 0) { - lpstrCurrFile = lpstrAllFile; - for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ ) - { - pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, nFileToOpen+1 ); - - if (pidl) - { - /* get the file name */ - lpstrTemp[0] = '\0'; - GetName( fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp ); - - if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore folders */ - { - if ( nFiles > 1) - { - *lpstrCurrFile++ = '\"'; - lstrcpyW( lpstrCurrFile, lpstrTemp ); - lpstrCurrFile += lstrlenW( lpstrTemp ); - *lpstrCurrFile++ = '\"'; - *lpstrCurrFile++ = ' '; - *lpstrCurrFile = 0; - } - else - { - lstrcpyW( lpstrAllFile, lpstrTemp ); - } - } - COMDLG32_SHFree( pidl ); - } - } - SetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrAllFile ); - - /* Select the file name like Windows does */ - if (filename_is_edit( fodInfos )) - SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1); + /* If there's only one file, use the name as-is without quotes */ + lpstrTmp = lpstrAllFiles; + if (nFiles == 1) + { + lpstrTmp += 1; + lpstrTmp[nThisFileLength] = 0; + } + SetWindowTextW(fodInfos->DlgInfos.hwndFileName, lpstrTmp); + /* Select the file name like Windows does */ + if (filename_is_edit(fodInfos)) + SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1); } - HeapFree(GetProcessHeap(),0, lpstrAllFile ); + +ret: + HeapFree(GetProcessHeap(), 0, lpstrAllFiles); + COMCTL32_ReleaseStgMedium(medium); } @@ -3734,15 +3742,6 @@ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, U return nFileCount; } -#define SETDefFormatEtc(fe,cf,med) \ -{ \ - (fe).cfFormat = cf;\ - (fe).dwAspect = DVASPECT_CONTENT; \ - (fe).ptd =NULL;\ - (fe).tymed = med;\ - (fe).lindex = -1;\ -}; - /* * DATAOBJECT Helper functions */ @@ -3776,16 +3775,13 @@ LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex) { STGMEDIUM medium; - FORMATETC formatetc; + FORMATETC formatetc = get_def_format(); LPITEMIDLIST pidl = NULL; TRACE("sv=%p index=%u\n", doSelected, nPidlIndex); if (!doSelected) return NULL; - - /* Set the FORMATETC structure*/ - SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), TYMED_HGLOBAL); /* Get the pidls from IDataObject */ if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) @@ -3810,15 +3806,12 @@ static UINT GetNumSelected( IDataObject *doSelected ) { UINT retVal = 0; STGMEDIUM medium; - FORMATETC formatetc; + FORMATETC formatetc = get_def_format(); TRACE("sv=%p\n", doSelected); if (!doSelected) return 0; - /* Set the FORMATETC structure*/ - SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), TYMED_HGLOBAL); - /* Get the pidls from IDataObject */ if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) { diff --git a/reactos/dll/win32/comdlg32/itemdlg.c b/reactos/dll/win32/comdlg32/itemdlg.c index 75b31eb61c1..156ab515e77 100644 --- a/reactos/dll/win32/comdlg32/itemdlg.c +++ b/reactos/dll/win32/comdlg32/itemdlg.c @@ -386,14 +386,12 @@ static UINT get_file_name(FileDialogImpl *This, LPWSTR *str) static BOOL set_file_name(FileDialogImpl *This, LPCWSTR str) { - HWND hwnd_edit = GetDlgItem(This->dlg_hwnd, IDC_FILENAME); - if(This->set_filename) LocalFree(This->set_filename); - This->set_filename = StrDupW(str); + This->set_filename = str ? StrDupW(str) : NULL; - return SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)str); + return SetDlgItemTextW(This->dlg_hwnd, IDC_FILENAME, This->set_filename); } static void fill_filename_from_selection(FileDialogImpl *This) @@ -2610,10 +2608,8 @@ static HRESULT WINAPI IFileDialog2_fnGetFileName(IFileDialog2 *iface, LPWSTR *ps return E_INVALIDARG; *pszName = NULL; - if(get_file_name(This, pszName)) - return S_OK; - else - return E_FAIL; + get_file_name(This, pszName); + return *pszName ? S_OK : E_FAIL; } static HRESULT WINAPI IFileDialog2_fnSetTitle(IFileDialog2 *iface, LPCWSTR pszTitle) diff --git a/reactos/dll/win32/comdlg32/printdlg.c b/reactos/dll/win32/comdlg32/printdlg.c index 6d5a9547dbf..b043231fb96 100644 --- a/reactos/dll/win32/comdlg32/printdlg.c +++ b/reactos/dll/win32/comdlg32/printdlg.c @@ -3595,11 +3595,8 @@ PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) default_page_paint_hook(hWnd, WM_PSD_MARGINRECT, (WPARAM)hdc, (LPARAM)&rcMargin, data); /* give text a bit of a space from the frame */ - rcMargin.left += 2; - rcMargin.top += 2; - rcMargin.right -= 2; - rcMargin.bottom -= 2; - + InflateRect(&rcMargin, -2, -2); + /* if the space is too small then we make sure to not draw anything */ rcMargin.left = min(rcMargin.left, rcMargin.right); rcMargin.top = min(rcMargin.top, rcMargin.bottom); diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index fac80845eec..6bd885fdbc6 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -55,7 +55,7 @@ reactos/dll/win32/cabinet # Synced to WineStaging-1.9.16 reactos/dll/win32/clusapi # Synced to WineStaging-1.9.11 reactos/dll/win32/comcat # Synced to WineStaging-1.9.11 reactos/dll/win32/comctl32 # Synced to WineStaging-1.9.16 -reactos/dll/win32/comdlg32 # Synced to WineStaging-1.9.11 +reactos/dll/win32/comdlg32 # Synced to WineStaging-1.9.16 reactos/dll/win32/compstui # Synced to WineStaging-1.9.11 reactos/dll/win32/credui # Synced to WineStaging-1.9.16 reactos/dll/win32/crypt32 # Synced to WineStaging-1.9.16