mirror of
https://github.com/reactos/reactos.git
synced 2025-05-18 00:31:27 +00:00
[SYSDM] Make ResourceMessageBox() support printf-like messages. (#4844)
+ Make usage of this new functionality. + Cleanup precomp.h.
This commit is contained in:
parent
a4274ad548
commit
a8e06d92e8
9 changed files with 93 additions and 90 deletions
|
@ -11,9 +11,6 @@
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strsafe.h>
|
|
||||||
|
|
||||||
#define MAX_STR_LENGTH 128
|
|
||||||
|
|
||||||
typedef struct _VARIABLE_DATA
|
typedef struct _VARIABLE_DATA
|
||||||
{
|
{
|
||||||
|
@ -986,16 +983,11 @@ EditVariableDlgProc(HWND hwndDlg,
|
||||||
|
|
||||||
case IDC_BUTTON_EDIT_TEXT:
|
case IDC_BUTTON_EDIT_TEXT:
|
||||||
{
|
{
|
||||||
TCHAR szStr[MAX_STR_LENGTH] = _T("");
|
if (ResourceMessageBox(hApplet,
|
||||||
TCHAR szStr2[MAX_STR_LENGTH] = _T("");
|
hwndDlg,
|
||||||
|
MB_OKCANCEL | MB_ICONWARNING | MB_DEFBUTTON1,
|
||||||
LoadString(hApplet, IDS_ENVIRONMENT_WARNING, szStr, _countof(szStr));
|
IDS_ENVIRONMENT_WARNING_TITLE,
|
||||||
LoadString(hApplet, IDS_ENVIRONMENT_WARNING_TITLE, szStr2, _countof(szStr2));
|
IDS_ENVIRONMENT_WARNING) == IDOK)
|
||||||
|
|
||||||
if (MessageBox(hwndDlg,
|
|
||||||
szStr,
|
|
||||||
szStr2,
|
|
||||||
MB_OKCANCEL | MB_ICONWARNING | MB_DEFBUTTON1) == IDOK)
|
|
||||||
{
|
{
|
||||||
EndDialog(hwndDlg, -1);
|
EndDialog(hwndDlg, -1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <winnls.h>
|
#include <winnls.h>
|
||||||
#include <powrprof.h>
|
#include <powrprof.h>
|
||||||
#include <buildno.h>
|
#include <buildno.h>
|
||||||
#include <strsafe.h>
|
|
||||||
|
|
||||||
#define ANIM_STEP 2
|
#define ANIM_STEP 2
|
||||||
#define ANIM_TIME 50
|
#define ANIM_TIME 50
|
||||||
|
|
|
@ -121,13 +121,17 @@ CopyProfileDlgProc(
|
||||||
pProfileNames->szDestinationName,
|
pProfileNames->szDestinationName,
|
||||||
PROFILE_NAME_LENGTH);
|
PROFILE_NAME_LENGTH);
|
||||||
if (IsProfileNameInUse(pProfileNames, FALSE))
|
if (IsProfileNameInUse(pProfileNames, FALSE))
|
||||||
|
{
|
||||||
ResourceMessageBox(hApplet,
|
ResourceMessageBox(hApplet,
|
||||||
NULL,
|
hwndDlg,
|
||||||
MB_OK | MB_ICONERROR,
|
MB_OK | MB_ICONERROR,
|
||||||
IDS_HWPROFILE_WARNING,
|
IDS_HWPROFILE_WARNING,
|
||||||
IDS_HWPROFILE_ALREADY_IN_USE);
|
IDS_HWPROFILE_ALREADY_IN_USE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
EndDialog(hwndDlg, IDOK);
|
EndDialog(hwndDlg, IDOK);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
|
@ -238,13 +242,17 @@ RenameProfileDlgProc(
|
||||||
pProfileNames->szDestinationName,
|
pProfileNames->szDestinationName,
|
||||||
PROFILE_NAME_LENGTH);
|
PROFILE_NAME_LENGTH);
|
||||||
if (IsProfileNameInUse(pProfileNames, TRUE))
|
if (IsProfileNameInUse(pProfileNames, TRUE))
|
||||||
|
{
|
||||||
ResourceMessageBox(hApplet,
|
ResourceMessageBox(hApplet,
|
||||||
NULL,
|
hwndDlg,
|
||||||
MB_OK | MB_ICONERROR,
|
MB_OK | MB_ICONERROR,
|
||||||
IDS_HWPROFILE_WARNING,
|
IDS_HWPROFILE_WARNING,
|
||||||
IDS_HWPROFILE_ALREADY_IN_USE);
|
IDS_HWPROFILE_ALREADY_IN_USE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
EndDialog(hwndDlg, IDOK);
|
EndDialog(hwndDlg, IDOK);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
|
@ -303,23 +311,20 @@ DeleteHardwareProfile(
|
||||||
HWND hwndDlg,
|
HWND hwndDlg,
|
||||||
PPROFILEDATA pProfileData)
|
PPROFILEDATA pProfileData)
|
||||||
{
|
{
|
||||||
WCHAR szMessage[256];
|
|
||||||
WCHAR szBuffer[128];
|
|
||||||
WCHAR szCaption[80];
|
|
||||||
PPROFILE pProfiles;
|
PPROFILE pProfiles;
|
||||||
PPROFILE pProfile;
|
PPROFILE pProfile;
|
||||||
|
|
||||||
pProfile = &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex];
|
pProfile = &pProfileData->pProfiles[pProfileData->dwSelectedProfileIndex];
|
||||||
|
|
||||||
LoadStringW(hApplet, IDS_HWPROFILE_CONFIRM_DELETE_TITLE, szCaption, sizeof(szCaption) / sizeof(WCHAR));
|
if (ResourceMessageBox(hApplet,
|
||||||
LoadStringW(hApplet, IDS_HWPROFILE_CONFIRM_DELETE, szBuffer, sizeof(szBuffer) / sizeof(WCHAR));
|
hwndDlg,
|
||||||
swprintf(szMessage, szBuffer, pProfile->szFriendlyName);
|
MB_YESNO | MB_ICONQUESTION,
|
||||||
|
IDS_HWPROFILE_CONFIRM_DELETE_TITLE,
|
||||||
if (MessageBox(NULL,
|
IDS_HWPROFILE_CONFIRM_DELETE,
|
||||||
szMessage,
|
pProfile->szFriendlyName) != IDYES)
|
||||||
szCaption,
|
{
|
||||||
MB_YESNO | MB_ICONQUESTION) != IDYES)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_DELETESTRING, pProfileData->dwSelectedProfileIndex, 0);
|
SendDlgItemMessageW(hwndDlg, IDC_HRDPROFLSTBOX, LB_DELETESTRING, pProfileData->dwSelectedProfileIndex, 0);
|
||||||
|
|
||||||
|
|
|
@ -21,16 +21,18 @@
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#include <cpl.h>
|
#include <cpl.h>
|
||||||
|
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define NUM_APPLETS (1)
|
#define NUM_APPLETS (1)
|
||||||
|
|
||||||
typedef struct _APPLET
|
typedef struct _APPLET
|
||||||
{
|
{
|
||||||
int idIcon;
|
int idIcon;
|
||||||
int idName;
|
int idName;
|
||||||
int idDescription;
|
int idDescription;
|
||||||
APPLET_PROC AppletProc;
|
APPLET_PROC AppletProc;
|
||||||
} APPLET, *PAPPLET;
|
} APPLET, *PAPPLET;
|
||||||
|
|
||||||
extern HINSTANCE hApplet;
|
extern HINSTANCE hApplet;
|
||||||
|
@ -53,45 +55,15 @@ INT_PTR CALLBACK LicenceDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
|
||||||
/* System information */
|
/* System information */
|
||||||
BOOL GetSystemName(PWSTR pBuf, SIZE_T cchBuf);
|
BOOL GetSystemName(PWSTR pBuf, SIZE_T cchBuf);
|
||||||
|
|
||||||
typedef struct _PAGEFILE
|
#define MAX_STR_LENGTH 256
|
||||||
{
|
|
||||||
TCHAR szDrive[3];
|
|
||||||
LPTSTR pszVolume;
|
|
||||||
INT OldMinSize;
|
|
||||||
INT OldMaxSize;
|
|
||||||
INT NewMinSize;
|
|
||||||
INT NewMaxSize;
|
|
||||||
UINT FreeSize;
|
|
||||||
BOOL bUsed;
|
|
||||||
} PAGEFILE, *PPAGEFILE;
|
|
||||||
|
|
||||||
typedef struct _VIRTMEM
|
INT __cdecl
|
||||||
{
|
|
||||||
HWND hSelf;
|
|
||||||
HWND hListBox;
|
|
||||||
LPTSTR szPagingFiles;
|
|
||||||
TCHAR szDrive[10];
|
|
||||||
INT Count;
|
|
||||||
BOOL bModified;
|
|
||||||
PAGEFILE Pagefile[26];
|
|
||||||
} VIRTMEM, *PVIRTMEM;
|
|
||||||
|
|
||||||
typedef struct _BOOTRECORD
|
|
||||||
{
|
|
||||||
DWORD BootType;
|
|
||||||
WCHAR szSectionName[128];
|
|
||||||
WCHAR szBootPath[MAX_PATH];
|
|
||||||
WCHAR szOptions[512];
|
|
||||||
|
|
||||||
}BOOTRECORD, *PBOOTRECORD;
|
|
||||||
|
|
||||||
INT
|
|
||||||
ResourceMessageBox(
|
ResourceMessageBox(
|
||||||
IN HINSTANCE hInstance,
|
_In_opt_ HINSTANCE hInstance,
|
||||||
IN HWND hwnd,
|
_In_opt_ HWND hwnd,
|
||||||
IN UINT uType,
|
_In_ UINT uType,
|
||||||
IN UINT uCaption,
|
_In_ UINT uCaption,
|
||||||
IN UINT uText);
|
_In_ UINT uText,
|
||||||
|
...);
|
||||||
|
|
||||||
#endif /* __CPL_SYSDM_H */
|
#endif /* __CPL_SYSDM_H */
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
#include <strsafe.h>
|
|
||||||
#include <udmihelp.h>
|
#include <udmihelp.h>
|
||||||
|
|
||||||
typedef struct GENERIC_NAME
|
typedef struct GENERIC_NAME
|
||||||
|
|
|
@ -12,6 +12,14 @@
|
||||||
|
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
|
||||||
|
typedef struct _BOOTRECORD
|
||||||
|
{
|
||||||
|
DWORD BootType;
|
||||||
|
WCHAR szSectionName[128];
|
||||||
|
WCHAR szBootPath[MAX_PATH];
|
||||||
|
WCHAR szOptions[512];
|
||||||
|
} BOOTRECORD, *PBOOTRECORD;
|
||||||
|
|
||||||
typedef struct _STARTINFO
|
typedef struct _STARTINFO
|
||||||
{
|
{
|
||||||
WCHAR szFreeldrIni[MAX_PATH + 15];
|
WCHAR szFreeldrIni[MAX_PATH + 15];
|
||||||
|
|
|
@ -23,22 +23,30 @@ APPLET Applets[NUM_APPLETS] =
|
||||||
#define MAX_SYSTEM_PAGES 32
|
#define MAX_SYSTEM_PAGES 32
|
||||||
|
|
||||||
|
|
||||||
INT
|
INT __cdecl
|
||||||
ResourceMessageBox(
|
ResourceMessageBox(
|
||||||
IN HINSTANCE hInstance,
|
_In_opt_ HINSTANCE hInstance,
|
||||||
IN HWND hwnd,
|
_In_opt_ HWND hwnd,
|
||||||
IN UINT uType,
|
_In_ UINT uType,
|
||||||
IN UINT uCaption,
|
_In_ UINT uCaption,
|
||||||
IN UINT uText)
|
_In_ UINT uText,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
WCHAR szCaption[256];
|
va_list args;
|
||||||
WCHAR szText[256];
|
WCHAR szCaption[MAX_STR_LENGTH];
|
||||||
|
WCHAR szText[MAX_STR_LENGTH];
|
||||||
|
WCHAR szCookedText[2*MAX_STR_LENGTH];
|
||||||
|
|
||||||
LoadStringW(hInstance, uCaption, szCaption, 256);
|
LoadStringW(hInstance, uCaption, szCaption, _countof(szCaption));
|
||||||
LoadStringW(hInstance, uText, szText, 256);
|
LoadStringW(hInstance, uText, szText, _countof(szText));
|
||||||
|
|
||||||
|
va_start(args, uText);
|
||||||
|
StringCchVPrintfW(szCookedText, _countof(szCookedText),
|
||||||
|
szText, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
return MessageBoxW(hwnd,
|
return MessageBoxW(hwnd,
|
||||||
szText,
|
szCookedText,
|
||||||
szCaption,
|
szCaption,
|
||||||
uType);
|
uType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,6 @@ BOOL
|
||||||
DeleteUserProfile(
|
DeleteUserProfile(
|
||||||
_In_ HWND hwndDlg)
|
_In_ HWND hwndDlg)
|
||||||
{
|
{
|
||||||
WCHAR szTitle[64], szRawText[128], szCookedText[256];
|
|
||||||
HWND hwndListView;
|
HWND hwndListView;
|
||||||
LVITEM Item;
|
LVITEM Item;
|
||||||
INT iSelected;
|
INT iSelected;
|
||||||
|
@ -179,14 +178,12 @@ DeleteUserProfile(
|
||||||
if (pProfileData->dwRefCount != 0)
|
if (pProfileData->dwRefCount != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
LoadStringW(hApplet, IDS_USERPROFILE_CONFIRM_DELETE_TITLE, szTitle, ARRAYSIZE(szTitle));
|
if (ResourceMessageBox(hApplet,
|
||||||
LoadStringW(hApplet, IDS_USERPROFILE_CONFIRM_DELETE, szRawText, ARRAYSIZE(szRawText));
|
hwndDlg,
|
||||||
swprintf(szCookedText, szRawText, pProfileData->pszFullName);
|
MB_ICONQUESTION | MB_YESNO,
|
||||||
|
IDS_USERPROFILE_CONFIRM_DELETE_TITLE,
|
||||||
if (MessageBoxW(hwndDlg,
|
IDS_USERPROFILE_CONFIRM_DELETE,
|
||||||
szCookedText,
|
pProfileData->pszFullName) == IDYES)
|
||||||
szTitle,
|
|
||||||
MB_ICONQUESTION | MB_YESNO) == IDYES)
|
|
||||||
{
|
{
|
||||||
/* FIXME: Delete the profile here! */
|
/* FIXME: Delete the profile here! */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -12,6 +12,29 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
typedef struct _PAGEFILE
|
||||||
|
{
|
||||||
|
TCHAR szDrive[3];
|
||||||
|
LPTSTR pszVolume;
|
||||||
|
INT OldMinSize;
|
||||||
|
INT OldMaxSize;
|
||||||
|
INT NewMinSize;
|
||||||
|
INT NewMaxSize;
|
||||||
|
UINT FreeSize;
|
||||||
|
BOOL bUsed;
|
||||||
|
} PAGEFILE, *PPAGEFILE;
|
||||||
|
|
||||||
|
typedef struct _VIRTMEM
|
||||||
|
{
|
||||||
|
HWND hSelf;
|
||||||
|
HWND hListBox;
|
||||||
|
LPTSTR szPagingFiles;
|
||||||
|
INT Count;
|
||||||
|
BOOL bModified;
|
||||||
|
PAGEFILE Pagefile[26];
|
||||||
|
} VIRTMEM, *PVIRTMEM;
|
||||||
|
|
||||||
|
|
||||||
static BOOL OnSelChange(HWND hwndDlg, PVIRTMEM pVirtMem);
|
static BOOL OnSelChange(HWND hwndDlg, PVIRTMEM pVirtMem);
|
||||||
static LPCTSTR lpKey = _T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management");
|
static LPCTSTR lpKey = _T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue