2012-10-01 23:16:43 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
[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 19:19:10 +00:00
|
|
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
2012-10-01 23:16:43 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "regedit.h"
|
2012-10-01 23:16:43 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode, ...)
|
2010-11-04 12:05:35 +00:00
|
|
|
{
|
2012-10-01 23:16:43 +00:00
|
|
|
int iRet = 0;
|
2012-10-03 22:42:34 +00:00
|
|
|
LPWSTR lpMsgBuf = NULL;
|
2012-10-01 23:16:43 +00:00
|
|
|
DWORD Status = 0;
|
2015-05-16 10:10:02 +00:00
|
|
|
va_list args;
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
va_start(args, dwErrorCode);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
Status = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL,
|
|
|
|
dwErrorCode,
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPWSTR)&lpMsgBuf,
|
|
|
|
0,
|
|
|
|
&args);
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
2013-01-01 14:55:53 +00:00
|
|
|
iRet = MessageBoxW(hWnd, (Status && lpMsgBuf ? lpMsgBuf : L"Error displaying error message."), lpTitle, MB_OK | MB_ICONERROR);
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
if (lpMsgBuf) LocalFree(lpMsgBuf);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
/* Return the MessageBoxW information */
|
2012-10-01 23:16:43 +00:00
|
|
|
return iRet;
|
|
|
|
}
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage, ...)
|
2012-10-01 23:16:43 +00:00
|
|
|
{
|
|
|
|
int iRet = 0;
|
2012-10-03 22:42:34 +00:00
|
|
|
LPWSTR lpMsgBuf = NULL;
|
2015-05-16 10:10:02 +00:00
|
|
|
va_list args;
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
va_start(args, lpMessage);
|
|
|
|
|
2013-01-01 14:55:53 +00:00
|
|
|
if (lpMessage)
|
|
|
|
{
|
|
|
|
SIZE_T strLen = _vscwprintf(lpMessage, args);
|
|
|
|
|
2013-01-01 14:57:12 +00:00
|
|
|
/* Create a buffer on the heap and zero it out (LPTR) */
|
2013-01-01 14:55:53 +00:00
|
|
|
lpMsgBuf = (LPWSTR)LocalAlloc(LPTR, (strLen + 1) * sizeof(WCHAR));
|
|
|
|
if (lpMsgBuf)
|
|
|
|
{
|
|
|
|
_vsnwprintf(lpMsgBuf, strLen, lpMessage, args);
|
|
|
|
}
|
|
|
|
}
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
2013-01-01 14:55:53 +00:00
|
|
|
iRet = MessageBoxW(hWnd, (lpMessage && lpMsgBuf ? lpMsgBuf : L"Error displaying info message."), lpTitle, uType);
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
if (lpMsgBuf) LocalFree(lpMsgBuf);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
/* Return the MessageBoxW information */
|
2012-10-01 23:16:43 +00:00
|
|
|
return iRet;
|
2010-11-04 12:05:35 +00:00
|
|
|
}
|