Commit 86a993ea authored by Lauri Kenttä's avatar Lauri Kenttä Committed by Alexandre Julliard

comdlg32: Init clipboard format only once in filedlg.

parent b6bb4c1b
...@@ -3620,6 +3620,25 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd) ...@@ -3620,6 +3620,25 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
} }
/*********************************************************************** /***********************************************************************
* 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 * FILEDLG95_FILENAME_FillFromSelection
* *
* fills the edit box from the cached DataObject * fills the edit box from the cached DataObject
...@@ -3766,15 +3785,6 @@ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, U ...@@ -3766,15 +3785,6 @@ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, U
return nFileCount; 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 * DATAOBJECT Helper functions
*/ */
...@@ -3808,16 +3818,13 @@ LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex) ...@@ -3808,16 +3818,13 @@ LPITEMIDLIST GetPidlFromDataObject ( IDataObject *doSelected, UINT nPidlIndex)
{ {
STGMEDIUM medium; STGMEDIUM medium;
FORMATETC formatetc; FORMATETC formatetc = get_def_format();
LPITEMIDLIST pidl = NULL; LPITEMIDLIST pidl = NULL;
TRACE("sv=%p index=%u\n", doSelected, nPidlIndex); TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
if (!doSelected) if (!doSelected)
return NULL; return NULL;
/* Set the FORMATETC structure*/
SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), TYMED_HGLOBAL);
/* Get the pidls from IDataObject */ /* Get the pidls from IDataObject */
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
...@@ -3842,15 +3849,12 @@ static UINT GetNumSelected( IDataObject *doSelected ) ...@@ -3842,15 +3849,12 @@ static UINT GetNumSelected( IDataObject *doSelected )
{ {
UINT retVal = 0; UINT retVal = 0;
STGMEDIUM medium; STGMEDIUM medium;
FORMATETC formatetc; FORMATETC formatetc = get_def_format();
TRACE("sv=%p\n", doSelected); TRACE("sv=%p\n", doSelected);
if (!doSelected) return 0; if (!doSelected) return 0;
/* Set the FORMATETC structure*/
SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), TYMED_HGLOBAL);
/* Get the pidls from IDataObject */ /* Get the pidls from IDataObject */
if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium))) if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
{ {
......
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