*
* See ShellMessageBoxA.
*
+ */
+#ifdef __REACTOS__
+/*
+ * shell32.ShellMessageBoxW directly redirects to shlwapi.ShellMessageBoxWrapW,
+ * while shell32.ShellMessageBoxA is a copy-paste ANSI adaptation of the
+ * shlwapi.ShellMessageBoxWrapW function.
+ *
+ * From Vista+ onwards, all the implementation of ShellMessageBoxA/W that
+ * were existing in shell32 has been completely moved to shlwapi, so that
+ * shell32.ShellMessageBoxA and shell32.ShellMessageBoxW are redirections
+ * to the corresponding shlwapi functions.
+ *
+ */
+#else // !__REACTOS__
+/*
* NOTE:
* shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
* because we can't forward to it in the .spec file since it's exported by
* ordinal. If you change the implementation here please update the code in
* shlwapi as well.
*/
+// Wine version, broken.
int ShellMessageBoxW(
HINSTANCE hInstance,
HWND hWnd,
hInstance,hWnd,lpText,lpCaption,uType);
if (IS_INTRESOURCE(lpCaption))
- LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
+ LoadStringW(hInstance, LOWORD(lpCaption), szTitle, ARRAY_SIZE(szTitle));
else
pszTitle = lpCaption;
if (IS_INTRESOURCE(lpText))
- LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
+ LoadStringW(hInstance, LOWORD(lpText), szText, ARRAY_SIZE(szText));
else
pszText = lpText;
LocalFree(pszTemp);
return ret;
}
+#endif
/*************************************************************************
* ShellMessageBoxA [SHELL32.183]
* NOTES
* Exported by ordinal
*/
+#ifdef __REACTOS__
+/*
+ * Note that we cannot straightforwardly implement ShellMessageBoxA around
+ * ShellMessageBoxW, by converting some parameters from ANSI to UNICODE,
+ * because there may be some variadic ANSI strings, associated with '%s'
+ * printf-like formatters inside the format string, that would also need
+ * to be converted; however there is no way for us to find these and perform
+ * the conversion ourselves.
+ * Therefore, we re-implement ShellMessageBoxA by doing a copy-paste ANSI
+ * adaptation of the shlwapi.ShellMessageBoxWrapW function.
+ */
+#endif
int ShellMessageBoxA(
HINSTANCE hInstance,
HWND hWnd,
UINT uType,
...)
{
+#ifdef __REACTOS__
+ CHAR *szText = NULL, szTitle[100];
+ LPCSTR pszText, pszTitle = szTitle;
+ LPSTR pszTemp;
+ __ms_va_list args;
+ int ret;
+
+ __ms_va_start(args, uType);
+
+ TRACE("(%p,%p,%p,%p,%08x)\n", hInstance, hWnd, lpText, lpCaption, uType);
+
+ if (IS_INTRESOURCE(lpCaption))
+ LoadStringA(hInstance, LOWORD(lpCaption), szTitle, ARRAY_SIZE(szTitle));
+ else
+ pszTitle = lpCaption;
+
+ if (IS_INTRESOURCE(lpText))
+ {
+ /* Retrieve the length of the Unicode string and obtain the maximum
+ * possible length for the corresponding ANSI string (not counting
+ * any possible NULL-terminator). */
+ const WCHAR *ptr;
+ UINT len = LoadStringW(hInstance, LOWORD(lpText), (LPWSTR)&ptr, 0);
+
+ len = WideCharToMultiByte(CP_ACP, 0, ptr, len,
+ NULL, 0, NULL, NULL);
+
+ if (len)
+ {
+ szText = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(CHAR));
+ if (szText) LoadStringA(hInstance, LOWORD(lpText), szText, len + 1);
+ }
+ pszText = szText;
+ if (!pszText) {
+ WARN("Failed to load id %d\n", LOWORD(lpText));
+ __ms_va_end(args);
+ return 0;
+ }
+ }
+ else
+ pszText = lpText;
+
+ FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
+ pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
+
+ __ms_va_end(args);
+
+ ret = MessageBoxA(hWnd, pszTemp, pszTitle, uType | MB_SETFOREGROUND);
+
+ HeapFree(GetProcessHeap(), 0, szText);
+ LocalFree(pszTemp);
+ return ret;
+
+#else // __REACTOS__
+
+// Wine version, broken.
char szText[100],szTitle[100];
LPCSTR pszText = szText, pszTitle = szTitle;
LPSTR pszTemp;
ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
LocalFree(pszTemp);
return ret;
+#endif
}
/*************************************************************************
*
* See shell32.ShellMessageBoxW
*
+#ifndef __REACTOS__
+ *
* NOTE:
* shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
* because we can't forward to it in the .spec file since it's exported by
* ordinal. If you change the implementation here please update the code in
* shell32 as well.
+ *
+#else // __REACTOS__
+ *
+ * From Vista+ onwards, all the implementation of ShellMessageBoxA/W that
+ * were existing in shell32 has been completely moved to shlwapi, so that
+ * shell32.ShellMessageBoxA and shell32.ShellMessageBoxW are redirections
+ * to the corresponding shlwapi functions.
+ *
+ * For Win2003 compatibility, if you change the implementation here please
+ * update the code of ShellMessageBoxA in shell32 as well.
+ *
+#endif
*/
INT WINAPIV ShellMessageBoxWrapW(HINSTANCE hInstance, HWND hWnd, LPCWSTR lpText,
LPCWSTR lpCaption, UINT uType, ...)
TRACE("(%p,%p,%p,%p,%08x)\n", hInstance, hWnd, lpText, lpCaption, uType);
if (IS_INTRESOURCE(lpCaption))
- LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
+ LoadStringW(hInstance, LOWORD(lpCaption), szTitle, ARRAY_SIZE(szTitle));
else
pszTitle = lpCaption;
__ms_va_end(args);
+#ifdef __REACTOS__
+ uType |= MB_SETFOREGROUND;
+#endif
ret = MessageBoxW(hWnd, pszTemp, pszTitle, uType);
HeapFree(GetProcessHeap(), 0, szText);