reactos/base/applications/regedit/error.c
Joachim Henze 470cef7bfd
[REGEDIT] Deduplication and other formatting changes (#7193)
- Deduplicates unused IDC_REGEDIT MENU vs. actually used IDR_REGEDIT_MENU
- shrinks the binary size, GCC8.4.0dbg build shrinks from 1.052.672 -> 1.049.600 bytes
- that also solves a few FIXME's, e.g. in hu-HU, pl-PL, sl-SI, sq-AL, tr-TR, uk-UA
- translates the help-popup string in th-TH.rc
- slightly tweak some headers to be a bit closer to newstyle without going all the way
- also link to LPGL2.1+ in the source files to reduce the wall-of-text, also some other whitespace tweaks in those, but no functional change
- security.c: vertical-compactness-whitespace-changes aim to get HeapAlloc closer to HeapFree
- id-ID.rc: "&Data nilai" and "&Nama nilai" does exist in 4 dialogs, Harmonize them
- pt-PT.rc: add 2 missing accels in IDD_EDIT_STRING
- edit.c: 3x ARRAY_SIZE
- the most review-worthy change in the actual .h/.c files is clb.c the change from ClbWndClass.hInstance = hinstDLL, ClbWndClass.hIcon = NULL; to ClbWndClass.hInstance = hinstDLL; ClbWndClass.hIcon = NULL;
- clb.c the stripped INT_PTR-cast for EndDialog() was Co-authored-by: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
2024-07-29 21:19:10 +02:00

66 lines
1.8 KiB
C

/*
* Regedit errors, warnings, informations displaying
*
* Copyright (C) 2010 Adam Kachwalla <geekdundee@gmail.com>
* Copyright (C) 2012 Hermès Bélusca - Maïto <hermes.belusca@sfr.fr>
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
*/
#include "regedit.h"
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode, ...)
{
int iRet = 0;
LPWSTR lpMsgBuf = NULL;
DWORD Status = 0;
va_list args;
va_start(args, dwErrorCode);
Status = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&lpMsgBuf,
0,
&args);
va_end(args);
iRet = MessageBoxW(hWnd, (Status && lpMsgBuf ? lpMsgBuf : L"Error displaying error message."), lpTitle, MB_OK | MB_ICONERROR);
if (lpMsgBuf) LocalFree(lpMsgBuf);
/* Return the MessageBoxW information */
return iRet;
}
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage, ...)
{
int iRet = 0;
LPWSTR lpMsgBuf = NULL;
va_list args;
va_start(args, lpMessage);
if (lpMessage)
{
SIZE_T strLen = _vscwprintf(lpMessage, args);
/* Create a buffer on the heap and zero it out (LPTR) */
lpMsgBuf = (LPWSTR)LocalAlloc(LPTR, (strLen + 1) * sizeof(WCHAR));
if (lpMsgBuf)
{
_vsnwprintf(lpMsgBuf, strLen, lpMessage, args);
}
}
va_end(args);
iRet = MessageBoxW(hWnd, (lpMessage && lpMsgBuf ? lpMsgBuf : L"Error displaying info message."), lpTitle, uType);
if (lpMsgBuf) LocalFree(lpMsgBuf);
/* Return the MessageBoxW information */
return iRet;
}