mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 20:50:29 +00:00
[SHIMGVW]
Dynamically allocate the string for the file-type box. Patch by Ricardo Hanke. CORE-7702 #resolve svn path=/trunk/; revision=65602
This commit is contained in:
parent
5e1a81a596
commit
e6979b9c26
1 changed files with 32 additions and 13 deletions
|
@ -76,7 +76,7 @@ static void pSaveImageAs(HWND hwnd)
|
||||||
OPENFILENAMEW sfn;
|
OPENFILENAMEW sfn;
|
||||||
ImageCodecInfo *codecInfo;
|
ImageCodecInfo *codecInfo;
|
||||||
WCHAR szSaveFileName[MAX_PATH];
|
WCHAR szSaveFileName[MAX_PATH];
|
||||||
WCHAR szFilterMask[2048];
|
WCHAR *szFilterMask;
|
||||||
GUID rawFormat;
|
GUID rawFormat;
|
||||||
UINT num;
|
UINT num;
|
||||||
UINT size;
|
UINT size;
|
||||||
|
@ -84,17 +84,6 @@ static void pSaveImageAs(HWND hwnd)
|
||||||
UINT j;
|
UINT j;
|
||||||
WCHAR *c;
|
WCHAR *c;
|
||||||
|
|
||||||
ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
|
|
||||||
ZeroMemory(szFilterMask, sizeof(szFilterMask));
|
|
||||||
ZeroMemory(&sfn, sizeof(sfn));
|
|
||||||
sfn.lStructSize = sizeof(sfn);
|
|
||||||
sfn.hwndOwner = hwnd;
|
|
||||||
sfn.hInstance = hInstance;
|
|
||||||
sfn.lpstrFile = szSaveFileName;
|
|
||||||
sfn.lpstrFilter = szFilterMask;
|
|
||||||
sfn.nMaxFile = MAX_PATH;
|
|
||||||
sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
|
||||||
|
|
||||||
GdipGetImageEncodersSize(&num, &size);
|
GdipGetImageEncodersSize(&num, &size);
|
||||||
codecInfo = malloc(size);
|
codecInfo = malloc(size);
|
||||||
if (!codecInfo)
|
if (!codecInfo)
|
||||||
|
@ -106,7 +95,36 @@ static void pSaveImageAs(HWND hwnd)
|
||||||
GdipGetImageEncoders(num, size, codecInfo);
|
GdipGetImageEncoders(num, size, codecInfo);
|
||||||
GdipGetImageRawFormat(image, &rawFormat);
|
GdipGetImageRawFormat(image, &rawFormat);
|
||||||
|
|
||||||
sizeRemain = sizeof(szFilterMask);
|
sizeRemain = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < num; ++j)
|
||||||
|
{
|
||||||
|
// Every pair needs space for the Description, twice the Extensions, 1 char for the space, 2 for the braces and 2 for the NULL terminators.
|
||||||
|
sizeRemain = sizeRemain + (((wcslen(codecInfo[j].FormatDescription) + (wcslen(codecInfo[j].FilenameExtension) * 2) + 5) * sizeof(WCHAR)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add two more chars for the last terminator */
|
||||||
|
sizeRemain = sizeRemain + (sizeof(WCHAR) * 2);
|
||||||
|
|
||||||
|
szFilterMask = malloc(sizeRemain);
|
||||||
|
if (!szFilterMask)
|
||||||
|
{
|
||||||
|
DPRINT1("cannot allocate memory for filter mask in pSaveImageAs()");
|
||||||
|
free(codecInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
|
||||||
|
ZeroMemory(szFilterMask, sizeRemain);
|
||||||
|
ZeroMemory(&sfn, sizeof(sfn));
|
||||||
|
sfn.lStructSize = sizeof(sfn);
|
||||||
|
sfn.hwndOwner = hwnd;
|
||||||
|
sfn.hInstance = hInstance;
|
||||||
|
sfn.lpstrFile = szSaveFileName;
|
||||||
|
sfn.lpstrFilter = szFilterMask;
|
||||||
|
sfn.nMaxFile = MAX_PATH;
|
||||||
|
sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
||||||
|
|
||||||
c = szFilterMask;
|
c = szFilterMask;
|
||||||
|
|
||||||
for (j = 0; j < num; ++j)
|
for (j = 0; j < num; ++j)
|
||||||
|
@ -137,6 +155,7 @@ static void pSaveImageAs(HWND hwnd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(szFilterMask);
|
||||||
free(codecInfo);
|
free(codecInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue