ReactOS  0.4.13-dev-79-gcd489d8
messagebox.c File Reference
#include <user32.h>
#include <ndk/exfuncs.h>
#include <ntstrsafe.h>
Include dependency graph for messagebox.c:

Go to the source code of this file.

Classes

struct  _MSGBTNINFO
 

Macros

#define MSGBOX_IDICON   (1088)
 
#define MSGBOX_IDTEXT   (0xffff)
 
#define IDI_HANDW   MAKEINTRESOURCEW(32513)
 
#define IDI_QUESTIONW   MAKEINTRESOURCEW(32514)
 
#define IDI_EXCLAMATIONW   MAKEINTRESOURCEW(32515)
 
#define IDI_ASTERISKW   MAKEINTRESOURCEW(32516)
 
#define IDI_WINLOGOW   MAKEINTRESOURCEW(32517)
 
#define BTN_CX   (75)
 
#define BTN_CY   (23)
 
#define MSGBOXEX_SPACING   (16)
 
#define MSGBOXEX_BUTTONSPACING   (6)
 
#define MSGBOXEX_MARGIN   (12)
 
#define MSGBOXEX_MAXBTNSTR   (32)
 
#define MSGBOXEX_MAXBTNS   (4)
 
#define RESCALE_X(_x, _units)   (((_x) * 4 + (_units).cx - 1) / (_units).cx)
 
#define RESCALE_Y(_y, _units)   (((_y) * 8 + (_units).cy - 1) / (_units).cy)
 
#define DECLARE_MB_1(_btn0)   { 1, { ID##_btn0, 0, 0 }, { IDS_##_btn0, 0, 0 } }
 
#define DECLARE_MB_2(_btn0, _btn1)   { 2, { ID##_btn0, ID##_btn1, 0 }, { IDS_##_btn0, IDS_##_btn1, 0 } }
 
#define DECLARE_MB_3(_btn0, _btn1, _btn2)   { 3, { ID##_btn0, ID##_btn1, ID##_btn2 }, { IDS_##_btn0, IDS_##_btn1, IDS_##_btn2 } }
 

Typedefs

typedef struct _MSGBTNINFO MSGBTNINFO
 
typedef struct _MSGBTNINFOPMSGBTNINFO
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (user32)
 
static UINT LoadAllocStringW (IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT PWSTR *pString, IN PCWSTR pDefaultString OPTIONAL)
 
static VOID MessageBoxTextToClipboard (HWND DialogWindow)
 
static INT_PTR CALLBACK MessageBoxProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static int MessageBoxTimeoutIndirectW (CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout)
 
int WINAPI SoftModalMessageBox (IN LPMSGBOXDATA lpMsgBoxData)
 
int WINAPI MessageBoxA (IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType)
 
int WINAPI MessageBoxW (IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType)
 
int WINAPI MessageBoxExA (IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId)
 
int WINAPI MessageBoxExW (IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId)
 
int WINAPI MessageBoxIndirectA (IN CONST MSGBOXPARAMSA *lpMsgBoxParams)
 
int WINAPI MessageBoxIndirectW (IN CONST MSGBOXPARAMSW *lpMsgBoxParams)
 
int WINAPI MessageBoxTimeoutA (IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwTimeout)
 
int WINAPI MessageBoxTimeoutW (IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwTimeout)
 
BOOL WINAPI MessageBeep (IN UINT uType)
 
LPCWSTR WINAPI MB_GetString (IN UINT wBtn)
 

Variables

static const MSGBTNINFO MsgBtnInfo []
 

Macro Definition Documentation

◆ BTN_CX

#define BTN_CX   (75)

Definition at line 53 of file messagebox.c.

◆ BTN_CY

#define BTN_CY   (23)

Definition at line 54 of file messagebox.c.

◆ DECLARE_MB_1

#define DECLARE_MB_1 (   _btn0)    { 1, { ID##_btn0, 0, 0 }, { IDS_##_btn0, 0, 0 } }

Definition at line 69 of file messagebox.c.

◆ DECLARE_MB_2

#define DECLARE_MB_2 (   _btn0,
  _btn1 
)    { 2, { ID##_btn0, ID##_btn1, 0 }, { IDS_##_btn0, IDS_##_btn1, 0 } }

Definition at line 72 of file messagebox.c.

◆ DECLARE_MB_3

#define DECLARE_MB_3 (   _btn0,
  _btn1,
  _btn2 
)    { 3, { ID##_btn0, ID##_btn1, ID##_btn2 }, { IDS_##_btn0, IDS_##_btn1, IDS_##_btn2 } }

Definition at line 75 of file messagebox.c.

◆ IDI_ASTERISKW

#define IDI_ASTERISKW   MAKEINTRESOURCEW(32516)

Definition at line 47 of file messagebox.c.

◆ IDI_EXCLAMATIONW

#define IDI_EXCLAMATIONW   MAKEINTRESOURCEW(32515)

Definition at line 46 of file messagebox.c.

◆ IDI_HANDW

#define IDI_HANDW   MAKEINTRESOURCEW(32513)

Definition at line 44 of file messagebox.c.

◆ IDI_QUESTIONW

#define IDI_QUESTIONW   MAKEINTRESOURCEW(32514)

Definition at line 45 of file messagebox.c.

◆ IDI_WINLOGOW

#define IDI_WINLOGOW   MAKEINTRESOURCEW(32517)

Definition at line 48 of file messagebox.c.

◆ MSGBOX_IDICON

#define MSGBOX_IDICON   (1088)

Definition at line 41 of file messagebox.c.

◆ MSGBOX_IDTEXT

#define MSGBOX_IDTEXT   (0xffff)

Definition at line 42 of file messagebox.c.

◆ MSGBOXEX_BUTTONSPACING

#define MSGBOXEX_BUTTONSPACING   (6)

Definition at line 57 of file messagebox.c.

◆ MSGBOXEX_MARGIN

#define MSGBOXEX_MARGIN   (12)

Definition at line 58 of file messagebox.c.

◆ MSGBOXEX_MAXBTNS

#define MSGBOXEX_MAXBTNS   (4)

Definition at line 60 of file messagebox.c.

◆ MSGBOXEX_MAXBTNSTR

#define MSGBOXEX_MAXBTNSTR   (32)

Definition at line 59 of file messagebox.c.

◆ MSGBOXEX_SPACING

#define MSGBOXEX_SPACING   (16)

Definition at line 56 of file messagebox.c.

◆ RESCALE_X

#define RESCALE_X (   _x,
  _units 
)    (((_x) * 4 + (_units).cx - 1) / (_units).cx)

Definition at line 63 of file messagebox.c.

◆ RESCALE_Y

#define RESCALE_Y (   _y,
  _units 
)    (((_y) * 8 + (_units).cy - 1) / (_units).cy)

Definition at line 64 of file messagebox.c.

Typedef Documentation

◆ MSGBTNINFO

◆ PMSGBTNINFO

Function Documentation

◆ LoadAllocStringW()

static UINT LoadAllocStringW ( IN HINSTANCE hInstance  OPTIONAL,
IN UINT  uID,
OUT PWSTR pString,
IN PCWSTR pDefaultString  OPTIONAL 
)
static

Definition at line 108 of file messagebox.c.

113 {
114  UINT Length;
115  PCWSTR pStr;
116 
117  /* Try to load the string from the resource */
118  Length = LoadStringW(hInstance, uID, (LPWSTR)&pStr, 0);
119  if (Length == 0)
120  {
121  /* If the resource string was not found, use the fallback default one */
122 
123  if (!pDefaultString)
124  {
125  /* None was specified, return NULL */
126  *pString = NULL;
127  return 0;
128  }
129 
130  pStr = pDefaultString;
131  Length = wcslen(pStr);
132  }
133 
134  /* Allocate a new buffer, adding a NULL-terminator */
135  *pString = RtlAllocateHeap(RtlGetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR));
136  if (!*pString)
137  return 0;
138 
139  /* Copy the string, NULL-terminated */
140  RtlStringCchCopyNW(*pString, Length + 1, pStr, Length);
141  return Length;
142 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE hInstance
Definition: charmap.c:20
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSTRSAFEAPI RtlStringCchCopyNW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_reads_or_z_(cchToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cchToCopy)
Definition: ntstrsafe.h:360
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by MessageBoxTimeoutIndirectW(), and SoftModalMessageBox().

◆ MB_GetString()

LPCWSTR WINAPI MB_GetString ( IN UINT  wBtn)

Definition at line 1345 of file messagebox.c.

1347 {
1348  static BOOL bCached = FALSE;
1349  static MBSTRING MBStrings[MAX_MB_STRINGS]; // FIXME: Use gpsi->MBStrings when this is loaded by Win32k!
1350 
1351  //
1352  // FIXME - TODO: The gpsi->MBStrings[] array should be loaded by win32k!
1353  //
1355  if (!bCached)
1356  {
1357  UINT i;
1358  for (i = 0; i < MAX_MB_STRINGS; ++i)
1359  {
1360  /*gpsi->*/MBStrings[i].uID = IDOK + i;
1361  /*gpsi->*/MBStrings[i].uStr = IDS_OK + i; // See user32/include/resource.h
1363  /*gpsi->*/MBStrings[i].uStr,
1364  /*gpsi->*/MBStrings[i].szName,
1365  ARRAYSIZE(/*gpsi->*/MBStrings[i].szName));
1366  }
1367  bCached = TRUE;
1368  }
1369 
1370  /*
1371  * The allowable IDs are between "IDOK - 1" (0) and "IDCONTINUE - 1" (10) inclusive.
1372  * See psdk/winuser.h and user32/include/resource.h .
1373  */
1374  if (wBtn > IDCONTINUE - 1)
1375  return NULL;
1376 
1377  return /*gpsi->*/MBStrings[wBtn].szName;
1378 }
WCHAR szName[16]
Definition: ntuser.h:938
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_MB_STRINGS
Definition: ntuser.h:907
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE User32Instance
Definition: dllmain.c:10
UINT uStr
Definition: ntuser.h:940
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
UINT uID
Definition: ntuser.h:939
#define IDS_OK
Definition: resource.h:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IDCONTINUE
Definition: vfdguiut.c:42
unsigned int UINT
Definition: ndis.h:50
static const WCHAR szName[]
Definition: msipriv.h:1194

Referenced by MessageBoxTimeoutIndirectW().

◆ MessageBeep()

BOOL WINAPI MessageBeep ( IN UINT  uType)

Definition at line 1329 of file messagebox.c.

1331 {
1332  return NtUserxMessageBeep(uType);
1333 }
EXTINLINE BOOL NtUserxMessageBeep(UINT uType)
Definition: ntwrapper.h:621

Referenced by SoftModalMessageBox().

◆ MessageBoxA()

int WINAPI MessageBoxA ( IN HWND  hWnd,
IN LPCSTR  lpText,
IN LPCSTR  lpCaption,
IN UINT  uType 
)

Definition at line 1074 of file messagebox.c.

1079 {
1080  return MessageBoxExA(hWnd, lpText, lpCaption, uType, LANG_NEUTRAL);
1081 }
#define LANG_NEUTRAL
Definition: nls.h:22
HWND hWnd
Definition: settings.c:17
int WINAPI MessageBoxExA(IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId)
Definition: messagebox.c:1103

◆ MessageBoxExA()

int WINAPI MessageBoxExA ( IN HWND  hWnd,
IN LPCSTR  lpText,
IN LPCSTR  lpCaption,
IN UINT  uType,
IN WORD  wLanguageId 
)

Definition at line 1103 of file messagebox.c.

1109 {
1110  MSGBOXPARAMSA msgbox;
1111 
1112  msgbox.cbSize = sizeof(msgbox);
1113  msgbox.hwndOwner = hWnd;
1114  msgbox.hInstance = 0;
1115  msgbox.lpszText = lpText;
1116  msgbox.lpszCaption = lpCaption;
1117  msgbox.dwStyle = uType;
1118  msgbox.lpszIcon = NULL;
1119  msgbox.dwContextHelpId = 0;
1120  msgbox.lpfnMsgBoxCallback = NULL;
1121  msgbox.dwLanguageId = wLanguageId;
1122 
1123  return MessageBoxIndirectA(&msgbox);
1124 }
int WINAPI MessageBoxIndirectA(IN CONST MSGBOXPARAMSA *lpMsgBoxParams)
Definition: messagebox.c:1160
LPCSTR lpszText
Definition: winuser.h:3268
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: winuser.h:3267
DWORD dwStyle
Definition: winuser.h:3270
smooth NULL
Definition: ftsmooth.c:416
DWORD dwLanguageId
Definition: winuser.h:3274
HWND hwndOwner
Definition: winuser.h:3266
LPCSTR lpszIcon
Definition: winuser.h:3271
MSGBOXCALLBACK lpfnMsgBoxCallback
Definition: winuser.h:3273
DWORD_PTR dwContextHelpId
Definition: winuser.h:3272
LPCSTR lpszCaption
Definition: winuser.h:3269

Referenced by MessageBoxA().

◆ MessageBoxExW()

int WINAPI MessageBoxExW ( IN HWND  hWnd,
IN LPCWSTR  lpText,
IN LPCWSTR  lpCaption,
IN UINT  uType,
IN WORD  wLanguageId 
)

Definition at line 1131 of file messagebox.c.

1137 {
1138  MSGBOXPARAMSW msgbox;
1139 
1140  msgbox.cbSize = sizeof(msgbox);
1141  msgbox.hwndOwner = hWnd;
1142  msgbox.hInstance = 0;
1143  msgbox.lpszText = lpText;
1144  msgbox.lpszCaption = lpCaption;
1145  msgbox.dwStyle = uType;
1146  msgbox.lpszIcon = NULL;
1147  msgbox.dwContextHelpId = 0;
1148  msgbox.lpfnMsgBoxCallback = NULL;
1149  msgbox.dwLanguageId = wLanguageId;
1150 
1151  return MessageBoxTimeoutIndirectW(&msgbox, (UINT)-1);
1152 }
DWORD dwLanguageId
Definition: winuser.h:3287
HWND hWnd
Definition: settings.c:17
LPCWSTR lpszText
Definition: winuser.h:3281
LPCWSTR lpszIcon
Definition: winuser.h:3284
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszCaption
Definition: winuser.h:3282
DWORD_PTR dwContextHelpId
Definition: winuser.h:3285
HWND hwndOwner
Definition: winuser.h:3279
HINSTANCE hInstance
Definition: winuser.h:3280
static int MessageBoxTimeoutIndirectW(CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout)
Definition: messagebox.c:449
MSGBOXCALLBACK lpfnMsgBoxCallback
Definition: winuser.h:3286
unsigned int UINT
Definition: ndis.h:50
DWORD dwStyle
Definition: winuser.h:3283

Referenced by MessageBoxW().

◆ MessageBoxIndirectA()

int WINAPI MessageBoxIndirectA ( IN CONST MSGBOXPARAMSA lpMsgBoxParams)

Definition at line 1160 of file messagebox.c.

1162 {
1163  MSGBOXPARAMSW msgboxW;
1164  UNICODE_STRING textW, captionW, iconW;
1165  int ret;
1166 
1167  if (!IS_INTRESOURCE(lpMsgBoxParams->lpszText))
1168  {
1169  RtlCreateUnicodeStringFromAsciiz(&textW, (PCSZ)lpMsgBoxParams->lpszText);
1170  /*
1171  * UNICODE_STRING objects are always allocated with an extra byte so you
1172  * can null-term if you want
1173  */
1174  textW.Buffer[textW.Length / sizeof(WCHAR)] = L'\0';
1175  }
1176  else
1177  textW.Buffer = (LPWSTR)lpMsgBoxParams->lpszText;
1178 
1179  if (!IS_INTRESOURCE(lpMsgBoxParams->lpszCaption))
1180  {
1181  RtlCreateUnicodeStringFromAsciiz(&captionW, (PCSZ)lpMsgBoxParams->lpszCaption);
1182  /*
1183  * UNICODE_STRING objects are always allocated with an extra byte so you
1184  * can null-term if you want
1185  */
1186  captionW.Buffer[captionW.Length / sizeof(WCHAR)] = L'\0';
1187  }
1188  else
1189  captionW.Buffer = (LPWSTR)lpMsgBoxParams->lpszCaption;
1190 
1191  if (lpMsgBoxParams->dwStyle & MB_USERICON)
1192  {
1193  if (!IS_INTRESOURCE(lpMsgBoxParams->lpszIcon))
1194  {
1195  RtlCreateUnicodeStringFromAsciiz(&iconW, (PCSZ)lpMsgBoxParams->lpszIcon);
1196  /*
1197  * UNICODE_STRING objects are always allocated with an extra byte so you
1198  * can null-term if you want
1199  */
1200  iconW.Buffer[iconW.Length / sizeof(WCHAR)] = L'\0';
1201  }
1202  else
1203  iconW.Buffer = (LPWSTR)lpMsgBoxParams->lpszIcon;
1204  }
1205  else
1206  iconW.Buffer = NULL;
1207 
1208  msgboxW.cbSize = sizeof(msgboxW);
1209  msgboxW.hwndOwner = lpMsgBoxParams->hwndOwner;
1210  msgboxW.hInstance = lpMsgBoxParams->hInstance;
1211  msgboxW.lpszText = textW.Buffer;
1212  msgboxW.lpszCaption = captionW.Buffer;
1213  msgboxW.dwStyle = lpMsgBoxParams->dwStyle;
1214  msgboxW.lpszIcon = iconW.Buffer;
1215  msgboxW.dwContextHelpId = lpMsgBoxParams->dwContextHelpId;
1216  msgboxW.lpfnMsgBoxCallback = lpMsgBoxParams->lpfnMsgBoxCallback;
1217  msgboxW.dwLanguageId = lpMsgBoxParams->dwLanguageId;
1218 
1219  ret = MessageBoxTimeoutIndirectW(&msgboxW, (UINT)-1);
1220 
1221  if (!IS_INTRESOURCE(lpMsgBoxParams->lpszText))
1223 
1224  if (!IS_INTRESOURCE(lpMsgBoxParams->lpszCaption))
1225  RtlFreeUnicodeString(&captionW);
1226 
1227  if ((lpMsgBoxParams->dwStyle & MB_USERICON) && !IS_INTRESOURCE(iconW.Buffer))
1229 
1230  return ret;
1231 }
CONST char * PCSZ
Definition: umtypes.h:125
DWORD dwLanguageId
Definition: winuser.h:3287
LPCWSTR lpszText
Definition: winuser.h:3281
#define MB_USERICON
Definition: winuser.h:777
LPCWSTR lpszIcon
Definition: winuser.h:3284
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszCaption
Definition: winuser.h:3282
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
DWORD_PTR dwContextHelpId
Definition: winuser.h:3285
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
HWND hwndOwner
Definition: winuser.h:3279
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret
static const WCHAR L[]
Definition: oid.c:1250
HINSTANCE hInstance
Definition: winuser.h:3280
static int MessageBoxTimeoutIndirectW(CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout)
Definition: messagebox.c:449
static const WCHAR textW[]
Definition: itemdlg.c:1559
MSGBOXCALLBACK lpfnMsgBoxCallback
Definition: winuser.h:3286
static const WCHAR iconW[]
Definition: sec_mgr.c:42
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
DWORD dwStyle
Definition: winuser.h:3283

Referenced by MessageBoxExA().

◆ MessageBoxIndirectW()

int WINAPI MessageBoxIndirectW ( IN CONST MSGBOXPARAMSW lpMsgBoxParams)

Definition at line 1238 of file messagebox.c.

1240 {
1241  return MessageBoxTimeoutIndirectW(lpMsgBoxParams, (UINT)-1);
1242 }
static int MessageBoxTimeoutIndirectW(CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout)
Definition: messagebox.c:449
unsigned int UINT
Definition: ndis.h:50

◆ MessageBoxProc()

static INT_PTR CALLBACK MessageBoxProc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 248 of file messagebox.c.

251 {
252  PMSGBOXDATA mbd;
253 
254  switch (message)
255  {
256  case WM_INITDIALOG:
257  {
258  int Alert;
259 
260  mbd = (PMSGBOXDATA)lParam;
261 
264 
265  if (!GetPropW(hwnd, L"ROS_MSGBOX"))
266  {
267  SetPropW(hwnd, L"ROS_MSGBOX", (HANDLE)lParam);
268 
269  if (mbd->mbp.dwContextHelpId)
271 
272  if (mbd->mbp.lpszIcon)
273  {
275  Alert = ALERT_SYSTEM_WARNING;
276  }
277  else /* Setup the rest of the alerts */
278  {
279  switch (mbd->mbp.dwStyle & MB_ICONMASK)
280  {
281  case MB_ICONWARNING:
282  Alert = ALERT_SYSTEM_WARNING;
283  break;
284  case MB_ICONERROR:
285  Alert = ALERT_SYSTEM_ERROR;
286  break;
287  case MB_ICONQUESTION:
288  Alert = ALERT_SYSTEM_QUERY;
289  break;
290  default:
291  Alert = ALERT_SYSTEM_INFORMATIONAL;
292  /* Fall through */
293  }
294  }
295  /* Send out the alert notifications */
296  NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd, OBJID_ALERT, Alert);
297 
298  /* Disable the Close menu button if no Cancel button is specified */
299  if (mbd->uCancelId == 0)
300  {
301  HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
302  if (hSysMenu)
303  DeleteMenu(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
304  }
305 
306  /* Set the focus to the default button */
307  if (mbd->dwButtons > 0)
308  {
309  ASSERT(mbd->uDefButton < mbd->dwButtons);
311  }
312 
313  /* Set up the window timer */
314  if (mbd->dwTimeout && (mbd->dwTimeout != (UINT)-1))
315  SetTimer(hwnd, 0, mbd->dwTimeout, NULL);
316  }
317  return FALSE;
318  }
319 
320  case WM_COMMAND:
321  {
322  UINT i;
323  INT_PTR iCtrlId = LOWORD(wParam);
324 
325  switch (iCtrlId)
326  {
327  /* Handle the default message-box buttons */
328  case IDOK:
329  case IDCANCEL:
330  /*
331  * The dialog manager always sends IDCANCEL when the user
332  * presses ESCape. We check here whether the message box
333  * has a CANCEL button, or whether we should fall back to
334  * the OK button, by using the correct uCancelId.
335  */
336  if (iCtrlId == IDCANCEL)
337  {
338  mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX");
339  if (!mbd)
340  return FALSE; /* Ignore */
341 
342  /* Check whether we can cancel the message box */
343  if (mbd->uCancelId == 0)
344  return TRUE; // FALSE; /* No, ignore */
345  /* Quit with the correct return value */
346  iCtrlId = mbd->uCancelId;
347  }
348  if (!GetDlgItem(hwnd, iCtrlId))
349  return FALSE; /* Ignore */
350 
351  /* Fall through */
352  case IDABORT:
353  case IDRETRY:
354  case IDIGNORE:
355  case IDYES:
356  case IDNO:
357  case IDTRYAGAIN:
358  case IDCONTINUE:
359  EndDialog(hwnd, iCtrlId);
360  return TRUE;
361 
362  case IDCLOSE:
363  return FALSE; /* Ignore */
364 
365  case IDHELP:
366  {
367  /* Send WM_HELP message to the message-box window */
368  HELPINFO hi;
369  hi.cbSize = sizeof(hi);
371  hi.iCtrlId = iCtrlId;
372  hi.hItemHandle = (HANDLE)lParam;
373  hi.dwContextId = 0;
374  GetCursorPos(&hi.MousePos);
375  SendMessageW(hwnd, WM_HELP, 0, (LPARAM)&hi);
376  return TRUE;
377  }
378 
379  default:
380  break;
381  }
382 
383  /* Check for any other user-defined buttons */
384  mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX");
385  if (!mbd)
386  return FALSE;
387 
388  for (i = 0; i < mbd->dwButtons; ++i)
389  {
390  if (iCtrlId == mbd->pidButton[i])
391  {
392  EndDialog(hwnd, iCtrlId);
393  return TRUE;
394  }
395  }
396 
397  return FALSE;
398  }
399 
400  case WM_COPY:
402  return TRUE;
403 
404  case WM_HELP:
405  {
407  mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX");
408  if (!mbd)
409  return FALSE;
411 
412  if (mbd->mbp.lpfnMsgBoxCallback)
413  {
414  mbd->mbp.lpfnMsgBoxCallback(phi);
415  }
416  else
417  {
418  HWND hwndOwner = GetWindow(hwnd, GW_OWNER);
419  if (hwndOwner)
420  SendMessageW(hwndOwner, WM_HELP, 0, lParam);
421  }
422  return TRUE;
423  }
424 
425  case WM_CLOSE:
426  {
427  mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX");
428  if (!mbd)
429  return FALSE;
430 
431  /* Check whether we can cancel the message box */
432  if (mbd->uCancelId == 0)
433  return TRUE; /* No, ignore */
434  /* Quit with the correct return value */
435  EndDialog(hwnd, mbd->uCancelId);
436  return TRUE;
437  }
438 
439  case WM_TIMER:
440  if (wParam == 0)
442  return FALSE;
443  }
444 
445  return FALSE;
446 }
#define MB_ICONMASK
Definition: winuser.h:813
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define STM_SETICON
Definition: winuser.h:2053
Definition: tftpd.h:59
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define IDABORT
Definition: winuser.h:826
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDYES
Definition: winuser.h:829
void WINAPI NotifyWinEvent(DWORD, HWND, LONG, LONG)
Definition: hook.c:325
DWORD_PTR dwContextId
Definition: winuser.h:3258
HANDLE hItemHandle
Definition: winuser.h:3257
INT * pidButton
Definition: messagebox.c:31
EXTINLINE BOOL NtUserxSetMessageBox(HWND hWnd)
Definition: ntwrapper.h:741
HWND WINAPI SetFocus(_In_opt_ HWND)
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:62
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define MB_ICONWARNING
Definition: winuser.h:780
#define IDTRYAGAIN
Definition: vfdguiut.c:38
#define IDHELP
Definition: resource_2.h:8
struct tagHELPINFO * LPHELPINFO
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define OBJID_ALERT
Definition: winable.h:25
#define WM_COPY
Definition: winuser.h:1823
LPCWSTR lpszIcon
Definition: winuser.h:3284
struct _MSGBOXDATA * PMSGBOXDATA
BOOL WINAPI SetWindowContextHelpId(_In_ HWND, _In_ DWORD)
#define IDTIMEOUT
Definition: wtsapi32.h:31
#define GWLP_USERDATA
Definition: treelist.c:63
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONQUESTION
Definition: winuser.h:783
LONG_PTR LPARAM
Definition: windef.h:208
static VOID MessageBoxTextToClipboard(HWND DialogWindow)
Definition: messagebox.c:144
POINT MousePos
Definition: winuser.h:3259
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
int iContextType
Definition: winuser.h:3255
DWORD dwTimeout
Definition: messagebox.c:37
DWORD_PTR dwContextHelpId
Definition: winuser.h:3285
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_TIMER
Definition: winuser.h:1718
#define WM_CLOSE
Definition: winuser.h:1603
DWORD WINAPI GetWindowContextHelpId(_In_ HWND)
DWORD dwButtons
Definition: messagebox.c:33
PVOID HANDLE
Definition: typedefs.h:71
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDRETRY
Definition: winuser.h:827
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
static const WCHAR L[]
Definition: oid.c:1250
#define IDCONTINUE
Definition: vfdguiut.c:42
#define MB_ICONERROR
Definition: winuser.h:781
UINT cbSize
Definition: winuser.h:3254
#define WM_COMMAND
Definition: winuser.h:1716
MSGBOXCALLBACK lpfnMsgBoxCallback
Definition: winuser.h:3286
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int iCtrlId
Definition: winuser.h:3256
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
UINT uDefButton
Definition: messagebox.c:34
unsigned int UINT
Definition: ndis.h:50
#define GW_OWNER
Definition: winuser.h:761
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
MSGBOXPARAMSW mbp
Definition: messagebox.c:25
#define SC_CLOSE
Definition: winuser.h:2546
#define SetWindowLongPtrW
Definition: winuser.h:5215
#define IDNO
Definition: winuser.h:830
#define IDCANCEL
Definition: winuser.h:825
#define HELPINFO_WINDOW
Definition: winuser.h:1158
UINT uCancelId
Definition: messagebox.c:35
DWORD dwStyle
Definition: winuser.h:3283
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define IDIGNORE
Definition: winuser.h:828
#define MSGBOX_IDICON
Definition: messagebox.c:41

Referenced by SoftModalMessageBox().

◆ MessageBoxTextToClipboard()

static VOID MessageBoxTextToClipboard ( HWND  DialogWindow)
static

Definition at line 144 of file messagebox.c.

145 {
146  HWND hwndText;
147  PMSGBOXDATA mbd;
148  int cchTotal, cchTitle, cchText, cchButton, i, n, cchBuffer;
149  LPWSTR pszBuffer, pszBufferPos, pMessageBoxText, pszTitle, pszText, pszButton;
151  HGLOBAL hGlobal;
152 
153  static const WCHAR szLine[] = L"---------------------------\r\n";
154 
155  mbd = (PMSGBOXDATA)GetPropW(DialogWindow, L"ROS_MSGBOX");
157  cchTitle = GetWindowTextLengthW(DialogWindow) + 1;
158  cchText = GetWindowTextLengthW(hwndText) + 1;
159 
160  if (!mbd)
161  return;
162 
163  pMessageBoxText = (LPWSTR)RtlAllocateHeap(GetProcessHeap(), 0, (cchTitle + cchText) * sizeof(WCHAR));
164 
165  if (pMessageBoxText == NULL)
166  {
167  RtlFreeHeap(GetProcessHeap(), 0, pMessageBoxText);
168  return;
169  }
170 
171  pszTitle = pMessageBoxText;
172  pszText = pMessageBoxText + cchTitle;
173 
174  if (GetWindowTextW(DialogWindow, pszTitle, cchTitle) == 0 ||
175  GetWindowTextW(hwndText, pszText, cchText) == 0)
176  {
177  RtlFreeHeap(GetProcessHeap(), 0, pMessageBoxText);
178  return;
179  }
180 
181  /*
182  * Calculate the total buffer size.
183  */
184  cchTotal = 6 + cchTitle + cchText + (lstrlenW(szLine) * 4) + (mbd->dwButtons * MSGBOXEX_MAXBTNSTR + 3);
185 
186  hGlobal = GlobalAlloc(GHND, cchTotal * sizeof(WCHAR));
187 
188  pszBuffer = (LPWSTR)GlobalLock(hGlobal);
189 
190  if (pszBuffer == NULL)
191  {
192  RtlFreeHeap(GetProcessHeap(), 0, pMessageBoxText);
193  GlobalFree(hGlobal);
194  return;
195  }
196 
197  /*
198  * First format title and text.
199  * ------------------
200  * Title
201  * ------------------
202  * Text
203  * ------------------
204  */
205  cchBuffer = wsprintfW(pszBuffer, L"%s%s\r\n%s%s\r\n%s", szLine, pszTitle, szLine, pszText, szLine);
206  pszBufferPos = pszBuffer + cchBuffer;
207 
208  for (i = 0; i < mbd->dwButtons; i++)
209  {
211 
212  cchButton = strlenW(szButton);
213  pszButton = szButton;
214 
215  /* Skip '&' character. */
216  if (szButton[0] == '&')
217  {
218  pszButton = pszButton + 1;
219  cchButton = cchButton - 1;
220  }
221 
222  for (n = 0; n < cchButton; n++)
223  *(pszBufferPos++) = pszButton[n];
224 
225  /* Add spaces. */
226  *(pszBufferPos++) = L' ';
227  *(pszBufferPos++) = L' ';
228  *(pszBufferPos++) = L' ';
229  }
230 
231  wsprintfW(pszBufferPos, L"\r\n%s", szLine);
232 
233  GlobalUnlock(hGlobal);
234 
236  {
237  EmptyClipboard();
239  CloseClipboard();
240  }
241  else
242  {
243  GlobalFree(hGlobal);
244  }
245  RtlFreeHeap(GetProcessHeap(), 0, pMessageBoxText);
246 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define MSGBOXEX_MAXBTNSTR
Definition: messagebox.c:59
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
GLdouble n
Definition: glext.h:7729
INT * pidButton
Definition: messagebox.c:31
#define lstrlenW
Definition: compat.h:407
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
#define GHND
Definition: winbase.h:294
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static DWORD cchBuffer
Definition: fusion.c:83
struct _MSGBOXDATA * PMSGBOXDATA
#define CF_UNICODETEXT
Definition: constants.h:408
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR szLine[]
Definition: dialog.c:141
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
_In_ int cchText
Definition: winuser.h:4334
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
#define GetProcessHeap()
Definition: compat.h:395
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define MSGBOX_IDTEXT
Definition: messagebox.c:42
DWORD dwButtons
Definition: messagebox.c:33
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
static const WCHAR L[]
Definition: oid.c:1250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
static const WCHAR szButton[]
Definition: dialog.c:136
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1378
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by MessageBoxProc().

◆ MessageBoxTimeoutA()

int WINAPI MessageBoxTimeoutA ( IN HWND  hWnd,
IN LPCSTR  lpText,
IN LPCSTR  lpCaption,
IN UINT  uType,
IN WORD  wLanguageId,
IN DWORD  dwTimeout 
)

Definition at line 1250 of file messagebox.c.

1257 {
1258  MSGBOXPARAMSW msgboxW;
1259  UNICODE_STRING textW, captionW;
1260  int ret;
1261 
1262  if (!IS_INTRESOURCE(lpText))
1264  else
1265  textW.Buffer = (LPWSTR)lpText;
1266 
1267  if (!IS_INTRESOURCE(lpCaption))
1268  RtlCreateUnicodeStringFromAsciiz(&captionW, (PCSZ)lpCaption);
1269  else
1270  captionW.Buffer = (LPWSTR)lpCaption;
1271 
1272  msgboxW.cbSize = sizeof(msgboxW);
1273  msgboxW.hwndOwner = hWnd;
1274  msgboxW.hInstance = 0;
1275  msgboxW.lpszText = textW.Buffer;
1276  msgboxW.lpszCaption = captionW.Buffer;
1277  msgboxW.dwStyle = uType;
1278  msgboxW.lpszIcon = NULL;
1279  msgboxW.dwContextHelpId = 0;
1280  msgboxW.lpfnMsgBoxCallback = NULL;
1281  msgboxW.dwLanguageId = wLanguageId;
1282 
1284 
1285  if (!IS_INTRESOURCE(textW.Buffer))
1287 
1288  if (!IS_INTRESOURCE(captionW.Buffer))
1289  RtlFreeUnicodeString(&captionW);
1290 
1291  return ret;
1292 }
CONST char * PCSZ
Definition: umtypes.h:125
DWORD dwLanguageId
Definition: winuser.h:3287
HWND hWnd
Definition: settings.c:17
LPCWSTR lpszText
Definition: winuser.h:3281
LPCWSTR lpszIcon
Definition: winuser.h:3284
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszCaption
Definition: winuser.h:3282
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
DWORD_PTR dwContextHelpId
Definition: winuser.h:3285
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
HWND hwndOwner
Definition: winuser.h:3279
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret
HINSTANCE hInstance
Definition: winuser.h:3280
static int MessageBoxTimeoutIndirectW(CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout)
Definition: messagebox.c:449
static const WCHAR textW[]
Definition: itemdlg.c:1559
MSGBOXCALLBACK lpfnMsgBoxCallback
Definition: winuser.h:3286
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
DWORD dwStyle
Definition: winuser.h:3283

◆ MessageBoxTimeoutIndirectW()

static int MessageBoxTimeoutIndirectW ( CONST MSGBOXPARAMSW lpMsgBoxParams,
UINT  dwTimeout 
)
static

Definition at line 449 of file messagebox.c.

451 {
452  int ret = 0;
453  UINT i;
454  LPWSTR defCaption = NULL;
455  MSGBOXDATA mbd;
457  LPCWSTR ButtonText[MSGBOXEX_MAXBTNS];
458 
459  // TODO: Check whether the caller is an NT 3.x app and if so, check
460  // instead for the MB_SERVICE_NOTIFICATION_NT3X flag and adjust it.
461  if (lpMsgBoxParams->dwStyle & MB_SERVICE_NOTIFICATION)
462  {
464  UNICODE_STRING CaptionU, TextU;
465  ULONG Response = ResponseNotHandled; /* HARDERROR_RESPONSE */
466  ULONG_PTR MsgBoxParams[4] =
467  {
468  (ULONG_PTR)&TextU,
469  (ULONG_PTR)&CaptionU,
470  /*
471  * Retrieve the message box flags. Note that we filter out
472  * MB_SERVICE_NOTIFICATION to not enter an infinite recursive
473  * loop when we will call MessageBox() later on.
474  */
475  lpMsgBoxParams->dwStyle & ~MB_SERVICE_NOTIFICATION,
476  dwTimeout
477  };
478 
479  /* hwndOwner must be NULL */
480  if (lpMsgBoxParams->hwndOwner != NULL)
481  {
482  ERR("MessageBoxTimeoutIndirectW(MB_SERVICE_NOTIFICATION): hwndOwner is not NULL!\n");
483  return 0;
484  }
485 
486  //
487  // FIXME: TODO: Implement the special case for Terminal Services.
488  //
489 
490  RtlInitUnicodeString(&CaptionU, lpMsgBoxParams->lpszCaption);
491  RtlInitUnicodeString(&TextU, lpMsgBoxParams->lpszText);
492 
494  ARRAYSIZE(MsgBoxParams),
495  (1 | 2),
496  MsgBoxParams,
497  OptionOk, /* NOTE: This parameter is ignored */
498  &Response);
499  if (!NT_SUCCESS(Status))
500  {
501  ERR("MessageBoxTimeoutIndirectW(MB_SERVICE_NOTIFICATION): NtRaiseHardError failed, Status = 0x%08lx\n", Status);
502  return 0;
503  }
504 
505  /* Map the returned response to the buttons */
506  switch (Response)
507  {
508  /* Not handled */
510  case ResponseNotHandled:
511  break;
512 
513  case ResponseAbort:
514  return IDABORT;
515  case ResponseCancel:
516  return IDCANCEL;
517  case ResponseIgnore:
518  return IDIGNORE;
519  case ResponseNo:
520  return IDNO;
521  case ResponseOk:
522  return IDOK;
523  case ResponseRetry:
524  return IDRETRY;
525  case ResponseYes:
526  return IDYES;
527  case ResponseTryAgain:
528  return IDTRYAGAIN;
529  case ResponseContinue:
530  return IDCONTINUE;
531 
532  /* Not handled */
533  default:
534  break;
535  }
536  return 0;
537  }
538 
539  ZeroMemory(&mbd, sizeof(mbd));
540  memcpy(&mbd.mbp, lpMsgBoxParams, sizeof(mbd.mbp));
541  mbd.wLanguageId = (WORD)lpMsgBoxParams->dwLanguageId;
542  mbd.dwTimeout = dwTimeout;
543 
544  if (!mbd.mbp.lpszCaption)
545  {
546  /* No caption, use the default one */
548  IDS_ERROR,
549  &defCaption,
550  L"Error");
551  mbd.mbp.lpszCaption = (defCaption ? defCaption : L"Error");
552  }
553 
554  /* Create the selected buttons; unknown types will fall back to MB_OK */
555  i = (lpMsgBoxParams->dwStyle & MB_TYPEMASK);
556  if (i >= ARRAYSIZE(MsgBtnInfo))
557  i = MB_OK;
558 
559  /* Get the buttons IDs */
560  Buttons = MsgBtnInfo[i];
561 
562  /* Add the Help button */
563  if (lpMsgBoxParams->dwStyle & MB_HELP)
564  {
565  Buttons.btnIdx[Buttons.btnCnt] = IDHELP;
566  Buttons.btnIds[Buttons.btnCnt] = IDS_HELP;
567  Buttons.btnCnt++;
568  }
569 
570  ASSERT(Buttons.btnCnt <= MSGBOXEX_MAXBTNS);
571 
572  /* Retrieve the pointers to the button labels and find the Cancel button */
573  mbd.uCancelId = (i == MB_OK ? IDOK : 0);
574  for (i = 0; i < Buttons.btnCnt; ++i)
575  {
576  // FIXME: Use the strings in the correct language.
577  // MB_GetString gives the string in default system language.
578  ButtonText[i] = MB_GetString(Buttons.btnIds[i] - IDS_OK); /* or: Buttons.btnIdx[i] - IDOK */
579 #if 0
581  Buttons.btnIds[i],
582  &ButtonText[i],
583  L"");
584 #endif
585  if (Buttons.btnIdx[i] == IDCANCEL)
586  mbd.uCancelId = IDCANCEL;
587  }
588 
589  mbd.pidButton = Buttons.btnIdx;
590  mbd.ppszButtonText = ButtonText;
591  mbd.dwButtons = Buttons.btnCnt;
592 
593  mbd.uDefButton = ((lpMsgBoxParams->dwStyle & MB_DEFMASK) >> 8);
594  /* Make the first button the default button if none other is */
595  if (mbd.uDefButton >= mbd.dwButtons)
596  mbd.uDefButton = 0;
597 
598  /* Call the helper function */
599  ret = SoftModalMessageBox(&mbd);
600 
601 #if 0
602  for (i = 0; i < mbd.dwButtons; i++)
603  {
604  if (ButtonText[i] && *ButtonText[i])
605  RtlFreeHeap(RtlGetProcessHeap(), 0, ButtonText[i]);
606  }
607 #endif
608 
609  if (defCaption)
610  RtlFreeHeap(RtlGetProcessHeap(), 0, defCaption);
611 
612  return ret;
613 }
LPCWSTR * ppszButtonText
Definition: messagebox.c:32
#define IDOK
Definition: winuser.h:824
#define IDABORT
Definition: winuser.h:826
#define IDYES
Definition: winuser.h:829
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int WINAPI SoftModalMessageBox(IN LPMSGBOXDATA lpMsgBoxData)
Definition: messagebox.c:617
NTSTATUS NTAPI NtRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
Definition: harderr.c:553
WORD wLanguageId
Definition: messagebox.c:30
#define MSGBOXEX_MAXBTNS
Definition: messagebox.c:60
LPCWSTR WINAPI MB_GetString(IN UINT wBtn)
Definition: messagebox.c:1345
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
INT * pidButton
Definition: messagebox.c:31
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE User32Instance
Definition: dllmain.c:10
#define MB_TYPEMASK
Definition: winuser.h:818
#define IDTRYAGAIN
Definition: vfdguiut.c:38
#define IDHELP
Definition: resource_2.h:8
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define HARDERROR_OVERRIDE_ERRORMODE
Definition: extypes.h:146
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszCaption
Definition: winuser.h:3282
#define MB_HELP
Definition: winuser.h:788
DWORD dwTimeout
Definition: messagebox.c:37
static UINT LoadAllocStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT PWSTR *pString, IN PCWSTR pDefaultString OPTIONAL)
Definition: messagebox.c:108
static const TBBUTTON Buttons[]
Definition: mplay32.c:41
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MB_DEFMASK
Definition: winuser.h:814
unsigned short WORD
Definition: ntddk_ex.h:93
DWORD dwButtons
Definition: messagebox.c:33
#define IDRETRY
Definition: winuser.h:827
Definition: ncftp.h:89
#define IDS_OK
Definition: resource.h:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define IDCONTINUE
Definition: vfdguiut.c:42
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
static const MSGBTNINFO MsgBtnInfo[]
Definition: messagebox.c:86
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
#define IDS_HELP
Definition: resource.h:3
UINT uDefButton
Definition: messagebox.c:34
unsigned int UINT
Definition: ndis.h:50
#define MB_OK
Definition: winuser.h:784
MSGBOXPARAMSW mbp
Definition: messagebox.c:25
#define IDS_ERROR
Definition: resource.h:18
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
#define IDNO
Definition: winuser.h:830
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define STATUS_SERVICE_NOTIFICATION
Definition: ntstatus.h:138
UINT uCancelId
Definition: messagebox.c:35
#define IDIGNORE
Definition: winuser.h:828

Referenced by MessageBoxExW(), MessageBoxIndirectA(), MessageBoxIndirectW(), MessageBoxTimeoutA(), and MessageBoxTimeoutW().

◆ MessageBoxTimeoutW()

int WINAPI MessageBoxTimeoutW ( IN HWND  hWnd,
IN LPCWSTR  lpText,
IN LPCWSTR  lpCaption,
IN UINT  uType,
IN WORD  wLanguageId,
IN DWORD  dwTimeout 
)

Definition at line 1299 of file messagebox.c.

1306 {
1307  MSGBOXPARAMSW msgbox;
1308 
1309  msgbox.cbSize = sizeof(msgbox);
1310  msgbox.hwndOwner = hWnd;
1311  msgbox.hInstance = 0;
1312  msgbox.lpszText = lpText;
1313  msgbox.lpszCaption = lpCaption;
1314  msgbox.dwStyle = uType;
1315  msgbox.lpszIcon = NULL;
1316  msgbox.dwContextHelpId = 0;
1317  msgbox.lpfnMsgBoxCallback = NULL;
1318  msgbox.dwLanguageId = wLanguageId;
1319 
1320  return MessageBoxTimeoutIndirectW(&msgbox, (UINT)dwTimeout);
1321 }
DWORD dwLanguageId
Definition: winuser.h:3287
HWND hWnd
Definition: settings.c:17
LPCWSTR lpszText
Definition: winuser.h:3281
LPCWSTR lpszIcon
Definition: winuser.h:3284
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszCaption
Definition: winuser.h:3282
DWORD_PTR dwContextHelpId
Definition: winuser.h:3285
HWND hwndOwner
Definition: winuser.h:3279
HINSTANCE hInstance
Definition: winuser.h:3280
static int MessageBoxTimeoutIndirectW(CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout)
Definition: messagebox.c:449
MSGBOXCALLBACK lpfnMsgBoxCallback
Definition: winuser.h:3286
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
unsigned int UINT
Definition: ndis.h:50
DWORD dwStyle
Definition: winuser.h:3283

◆ MessageBoxW()

int WINAPI MessageBoxW ( IN HWND  hWnd,
IN LPCWSTR  lpText,
IN LPCWSTR  lpCaption,
IN UINT  uType 
)

Definition at line 1088 of file messagebox.c.

1093 {
1094  return MessageBoxExW(hWnd, lpText, lpCaption, uType, LANG_NEUTRAL);
1095 }
#define LANG_NEUTRAL
Definition: nls.h:22
HWND hWnd
Definition: settings.c:17
int WINAPI MessageBoxExW(IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId)
Definition: messagebox.c:1131

Referenced by TestMsgBoxServiceNotification().

◆ SoftModalMessageBox()

int WINAPI SoftModalMessageBox ( IN LPMSGBOXDATA  lpMsgBoxData)

Definition at line 617 of file messagebox.c.

618 {
619  int ret = 0;
620  MSGBOXDATA mbd;
621  LPMSGBOXPARAMSW lpMsgBoxParams = &mbd.mbp;
622  DLGTEMPLATE *tpl;
623  DLGITEMTEMPLATE *iico, *itxt, *ibtn;
624  NONCLIENTMETRICSW nclm;
625  LPVOID buf;
626  BYTE *dest;
627  LPWSTR caption, text;
628  HFONT hFont, hOldFont;
629  HICON hIcon;
630  HWND hDCWnd;
631  HDC hDC;
632  SIZE units;
633  int bufsize, caplen, textlen, i, btnleft, btntop;
634  size_t ButtonLen;
635  RECT btnrect, txtrect, rc;
636  SIZE btnsize;
637  POINT iconPos; SIZE iconSize;
638 
639  /* Capture the MsgBoxData */
640  memcpy(&mbd, lpMsgBoxData, sizeof(mbd));
641 
642  /* Load the caption */
643  caption = NULL;
644  if (lpMsgBoxParams->lpszCaption && IS_INTRESOURCE(lpMsgBoxParams->lpszCaption))
645  {
646  /* User-defined resource string */
647  caplen = LoadAllocStringW(lpMsgBoxParams->hInstance,
648  PtrToUlong(lpMsgBoxParams->lpszCaption),
649  &caption,
650  NULL);
651  lpMsgBoxParams->lpszCaption = caption;
652  }
653  else if (lpMsgBoxParams->lpszCaption)
654  {
655  /* UNICODE string pointer */
656  caplen = wcslen(lpMsgBoxParams->lpszCaption);
657  }
658  if (!lpMsgBoxParams->lpszCaption)
659  {
660  /* No caption, use blank */
661  lpMsgBoxParams->lpszCaption = L"";
662  caplen = 0;
663  }
664 
665  /* Load the text */
666  text = NULL;
667  if (lpMsgBoxParams->lpszText && IS_INTRESOURCE(lpMsgBoxParams->lpszText))
668  {
669  /* User-defined resource string */
670  textlen = LoadAllocStringW(lpMsgBoxParams->hInstance,
671  PtrToUlong(lpMsgBoxParams->lpszText),
672  &text,
673  NULL);
674  lpMsgBoxParams->lpszText = text;
675  }
676  else if (lpMsgBoxParams->lpszText)
677  {
678  /* UNICODE string pointer */
679  textlen = wcslen(lpMsgBoxParams->lpszText);
680  }
681  if (!lpMsgBoxParams->lpszText)
682  {
683  /* No text, use blank */
684  lpMsgBoxParams->lpszText = L"";
685  textlen = 0;
686  }
687 
688  /* Load the icon */
689  switch (lpMsgBoxParams->dwStyle & MB_ICONMASK)
690  {
691  case MB_ICONEXCLAMATION: // case MB_ICONWARNING:
694  break;
695  case MB_ICONQUESTION:
698  break;
699  case MB_ICONASTERISK: // case MB_ICONINFORMATION:
702  break;
703  case MB_ICONHAND: // case MB_ICONSTOP: case MB_ICONERROR:
706  break;
707  case MB_USERICON:
708  hIcon = LoadIconW(lpMsgBoxParams->hInstance, lpMsgBoxParams->lpszIcon);
710  break;
711  default:
712  /*
713  * By default, Windows 95/98/NT does not associate an icon
714  * to message boxes. So ReactOS should do the same.
715  */
716  hIcon = NULL;
718  break;
719  }
720  /* Reuse the internal pointer! */
721  lpMsgBoxParams->lpszIcon = (LPCWSTR)hIcon;
722 
723  /* Basic space */
724  bufsize = sizeof(DLGTEMPLATE) +
725  2 * sizeof(WORD) + /* menu and class */
726  (caplen + 1) * sizeof(WCHAR) + /* title */
727  sizeof(WORD); /* font height */
728 
729  /* Space for the icon */
730  if (hIcon)
731  {
733  bufsize += sizeof(DLGITEMTEMPLATE) +
734  4 * sizeof(WORD) +
735  sizeof(WCHAR);
736  }
737 
738  /* Space for the text */
740  bufsize += sizeof(DLGITEMTEMPLATE) +
741  3 * sizeof(WORD) +
742  (textlen + 1) * sizeof(WCHAR);
743 
744  /* Space for the buttons */
745  for (i = 0; i < mbd.dwButtons; i++)
746  {
747  if (!mbd.ppszButtonText[i] || !*mbd.ppszButtonText[i])
748  {
749  /* No text, use blank */
750  mbd.ppszButtonText[i] = L"";
751  ButtonLen = 0;
752  }
753  else
754  {
755  /* UNICODE string pointer */
756  ButtonLen = wcslen(mbd.ppszButtonText[i]);
757  }
758 
760  bufsize += sizeof(DLGITEMTEMPLATE) +
761  3 * sizeof(WORD) +
762  (ButtonLen + 1) * sizeof(WCHAR);
763  }
764 
765  /* Allocate the dialog template */
766  buf = RtlAllocateHeap(RtlGetProcessHeap(), 0, bufsize);
767  if (!buf)
768  goto Quit;
769 
770  iico = itxt = NULL;
771 
772 
773  nclm.cbSize = sizeof(nclm);
774  SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0);
775  hFont = CreateFontIndirectW(&nclm.lfMessageFont);
776  if (!hFont)
777  {
778  ERR("Cannot retrieve nclm.lfMessageFont! (error %lu)\n", GetLastError());
779  goto Quit;
780  }
781 
782  hDCWnd = NULL;
783  hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE);
784  if (!hDC)
785  {
786  /* Retry with the DC of the owner window */
787  hDCWnd = lpMsgBoxParams->hwndOwner;
788  hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE);
789  }
790  if (!hDC)
791  {
792  ERR("GetDCEx() failed, bail out! (error %lu)\n", GetLastError());
793  goto Quit;
794  }
795  hOldFont = SelectObject(hDC, hFont);
796 
798  if (!units.cx)
799  {
800  DWORD defUnits;
801  ERR("GdiGetCharDimensions() failed, falling back to default values (error %lu)\n", GetLastError());
802  defUnits = GetDialogBaseUnits();
803  units.cx = LOWORD(defUnits);
804  units.cy = HIWORD(defUnits);
805  }
806 
807  /* Calculate the caption rectangle */
808  txtrect.right = MulDiv(GetSystemMetrics(SM_CXSCREEN), 4, 5);
809  if (hIcon)
811  txtrect.top = txtrect.left = txtrect.bottom = 0;
812  if (textlen != 0)
813  {
814  DrawTextW(hDC, lpMsgBoxParams->lpszText, textlen, &txtrect,
816  }
817  else
818  {
819  txtrect.right = txtrect.left + 1;
820  txtrect.bottom = txtrect.top + 1;
821  }
822  txtrect.right++;
823 
824  /* Calculate the maximum buttons size */
825  btnsize.cx = BTN_CX;
826  btnsize.cy = BTN_CY;
827  btnrect.left = btnrect.top = 0;
828  for (i = 0; i < mbd.dwButtons; i++)
829  {
830  // btnrect.right = btnrect.bottom = 0; // FIXME: Is it needed??
832  &btnrect, DT_LEFT | DT_SINGLELINE | DT_CALCRECT);
833  btnsize.cx = max(btnsize.cx, btnrect.right);
834  btnsize.cy = max(btnsize.cy, btnrect.bottom);
835  }
836 
837  if (hOldFont)
838  SelectObject(hDC, hOldFont);
839 
840  ReleaseDC(hDCWnd, hDC);
841 
842  if (hFont)
844 
845 
846  /* Calculate position and size of controls */
847 
848 
849  /* Calculate position and size of the icon */
850  rc.left = rc.bottom = rc.right = 0;
851  btntop = 0;
852  if (hIcon)
853  {
856 #ifdef MSGBOX_ICONVCENTER
857  rc.top = MSGBOXEX_MARGIN + ((max(txtrect.bottom, rc.bottom) - rc.bottom) / 2);
858  rc.top = max(MSGBOXEX_SPACING, rc.top);
859 #else
860  rc.top = MSGBOXEX_MARGIN;
861 #endif
862  btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING;
863  if (btnleft > txtrect.right + rc.right + MSGBOXEX_SPACING)
864  {
865 #ifdef MSGBOX_TEXTHCENTER
866  rc.left = MSGBOXEX_MARGIN + ((btnleft - txtrect.right - rc.right - MSGBOXEX_SPACING) / 2);
867 #else
868  rc.left = MSGBOXEX_MARGIN;
869 #endif
870  btnleft = MSGBOXEX_MARGIN;
871  }
872  else
873  {
874  rc.left = MSGBOXEX_MARGIN;
875  btnleft = MSGBOXEX_MARGIN + ((txtrect.right + rc.right + MSGBOXEX_SPACING - btnleft) / 2);
876  }
877 
878  iconPos.x = RESCALE_X(rc.left, units);
879  iconPos.y = RESCALE_Y(rc.top, units);
880  iconSize.cx = RESCALE_X(rc.right, units);
881  iconSize.cy = RESCALE_Y(rc.bottom, units);
882 
883  btntop = rc.top + rc.bottom + MSGBOXEX_SPACING;
884  rc.left += rc.right + MSGBOXEX_SPACING;
885  }
886  else
887  {
888  btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING;
889  if (btnleft > txtrect.right)
890  {
891 #ifdef MSGBOX_TEXTHCENTER
892  rc.left = MSGBOXEX_MARGIN + ((btnleft - txtrect.right) / 2);
893 #else
894  rc.left = MSGBOXEX_MARGIN;
895 #endif
896  btnleft = MSGBOXEX_MARGIN;
897  }
898  else
899  {
900  rc.left = MSGBOXEX_MARGIN;
901  btnleft = MSGBOXEX_MARGIN + ((txtrect.right - btnleft) / 2);
902  }
903  }
904 
905 
906  /* Initialize the dialog template */
907  tpl = (DLGTEMPLATE *)buf;
908 
912  if (lpMsgBoxParams->dwStyle & MB_TOPMOST)
914  if (lpMsgBoxParams->dwStyle & MB_RIGHT)
916  tpl->x = 100;
917  tpl->y = 100;
918  tpl->cdit = mbd.dwButtons + (hIcon ? 1 : 0) + 1; /* Buttons, icon and text */
919 
920  dest = (BYTE *)(tpl + 1);
921 
922  *(DWORD*)dest = 0; /* no menu and use default window class */
923  dest += 2 * sizeof(WORD);
924  memcpy(dest, lpMsgBoxParams->lpszCaption, caplen * sizeof(WCHAR));
925  dest += caplen * sizeof(WCHAR);
926  *(WCHAR*)dest = L'\0';
927  dest += sizeof(WCHAR);
928 
929  /*
930  * A font point size (height) of 0x7FFF means that we use
931  * the message box font (NONCLIENTMETRICSW.lfMessageFont).
932  */
933  *(WORD*)dest = 0x7FFF;
934  dest += sizeof(WORD);
935 
936  /* Create the icon */
937  if (hIcon)
938  {
940  iico = (DLGITEMTEMPLATE *)dest;
941  iico->style = WS_CHILD | WS_VISIBLE | SS_ICON;
942  iico->dwExtendedStyle = 0;
943  iico->id = MSGBOX_IDICON;
944 
945  iico->x = iconPos.x;
946  iico->y = iconPos.y;
947  iico->cx = iconSize.cx;
948  iico->cy = iconSize.cy;
949 
950  dest += sizeof(DLGITEMTEMPLATE);
951  *(WORD*)dest = 0xFFFF;
952  dest += sizeof(WORD);
953  *(WORD*)dest = 0x0082; /* static control */
954  dest += sizeof(WORD);
955  *(WORD*)dest = 0xFFFF;
956  dest += sizeof(WORD);
957  *(WCHAR*)dest = 0;
958  dest += sizeof(WCHAR);
959  *(WORD*)dest = 0;
960  dest += sizeof(WORD);
961  }
962 
963  /* Create static for text */
965  itxt = (DLGITEMTEMPLATE *)dest;
966  itxt->style = WS_CHILD | WS_VISIBLE | SS_NOPREFIX;
967  if (lpMsgBoxParams->dwStyle & MB_RIGHT)
968  itxt->style |= SS_RIGHT;
969  else
970  itxt->style |= SS_LEFT;
971  itxt->dwExtendedStyle = 0;
972  itxt->id = MSGBOX_IDTEXT;
973  dest += sizeof(DLGITEMTEMPLATE);
974  *(WORD*)dest = 0xFFFF;
975  dest += sizeof(WORD);
976  *(WORD*)dest = 0x0082; /* static control */
977  dest += sizeof(WORD);
978  memcpy(dest, lpMsgBoxParams->lpszText, textlen * sizeof(WCHAR));
979  dest += textlen * sizeof(WCHAR);
980  *(WCHAR*)dest = 0;
981  dest += sizeof(WCHAR);
982  *(WORD*)dest = 0;
983  dest += sizeof(WORD);
984 
985 
986  /* Calculate position of the text */
987  rc.top = MSGBOXEX_MARGIN + ((rc.bottom - txtrect.bottom) / 2);
988  rc.top = max(rc.top, MSGBOXEX_MARGIN);
989 
990 
991  /* Make the first button the default button if none other is */
992  if (mbd.uDefButton >= mbd.dwButtons)
993  mbd.uDefButton = 0;
994 
995  /* Create and calculate the position of the buttons */
996  btntop = max(rc.top + txtrect.bottom + MSGBOXEX_SPACING, btntop);
997  for (i = 0; i < mbd.dwButtons; i++)
998  {
999  ButtonLen = wcslen(mbd.ppszButtonText[i]);
1000 
1002  ibtn = (DLGITEMTEMPLATE *)dest;
1003 
1004  ibtn->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
1005  if (i == mbd.uDefButton)
1006  ibtn->style |= BS_DEFPUSHBUTTON;
1007  else
1008  ibtn->style |= BS_PUSHBUTTON;
1009 
1010  ibtn->dwExtendedStyle = 0;
1011  ibtn->id = mbd.pidButton[i];
1012  dest += sizeof(DLGITEMTEMPLATE);
1013  *(WORD*)dest = 0xFFFF;
1014  dest += sizeof(WORD);
1015  *(WORD*)dest = 0x0080; /* button control */
1016  dest += sizeof(WORD);
1017  memcpy(dest, mbd.ppszButtonText[i], ButtonLen * sizeof(WCHAR));
1018  dest += ButtonLen * sizeof(WCHAR);
1019  *(WORD*)dest = 0;
1020  dest += sizeof(WORD);
1021  *(WORD*)dest = 0;
1022  dest += sizeof(WORD);
1023 
1024  ibtn->x = RESCALE_X(btnleft, units);
1025  ibtn->y = RESCALE_Y(btntop, units);
1026  ibtn->cx = RESCALE_X(btnsize.cx, units);
1027  ibtn->cy = RESCALE_Y(btnsize.cy, units);
1028  btnleft += btnsize.cx + MSGBOXEX_BUTTONSPACING;
1029  }
1030 
1031  /* Calculate the size and position of the message-box window */
1032  btnleft = max(btnleft - MSGBOXEX_BUTTONSPACING, rc.left + txtrect.right);
1033  btnleft += MSGBOXEX_MARGIN;
1034  if (mbd.dwButtons > 0)
1035  btntop += btnsize.cy + MSGBOXEX_MARGIN;
1036 
1037  /* Set the size and position of the static message */
1038  itxt->x = RESCALE_X(rc.left, units);
1039  itxt->y = RESCALE_Y(rc.top, units);
1040  itxt->cx = RESCALE_X(btnleft - rc.left - MSGBOXEX_MARGIN, units);
1041  itxt->cy = RESCALE_Y(txtrect.bottom, units);
1042 
1043  /* Set the size of the window */
1044  tpl->cx = RESCALE_X(btnleft, units);
1045  tpl->cy = RESCALE_Y(btntop, units);
1046 
1047  /* Finally show the message-box */
1048  ERR("MessageBox: %s\n", wine_dbgstr_wn(lpMsgBoxParams->lpszText, textlen));
1049  ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl,
1050  lpMsgBoxParams->hwndOwner,
1051  MessageBoxProc, (LPARAM)&mbd);
1052 
1053 Quit:
1054  if (buf)
1055  RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
1056 
1057  if (text)
1058  RtlFreeHeap(RtlGetProcessHeap(), 0, text);
1059 
1060  if (caption)
1061  RtlFreeHeap(RtlGetProcessHeap(), 0, caption);
1062 
1063  return ret;
1064 }
#define MB_ICONMASK
Definition: winuser.h:813
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define MB_ICONHAND
Definition: winuser.h:782
#define DT_EXPANDTABS
Definition: winuser.h:532
#define IDI_HANDW
Definition: messagebox.c:44
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define max(a, b)
Definition: svc.c:63
static HICON
Definition: imagelist.c:84
LPCWSTR * ppszButtonText
Definition: messagebox.c:32
long y
Definition: polytest.cpp:48
#define ALIGN_UP(size, type)
Definition: umtypes.h:91
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
long x
Definition: polytest.cpp:48
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MSGBOXEX_BUTTONSPACING
Definition: messagebox.c:57
static INT_PTR CALLBACK MessageBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: messagebox.c:248
const WCHAR * text
Definition: package.c:1827
#define DT_WORDBREAK
Definition: winuser.h:544
#define BTN_CY
Definition: messagebox.c:54
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
static HDC
Definition: imagelist.c:92
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define DS_CENTER
Definition: winuser.h:369
LONG top
Definition: windef.h:292
INT * pidButton
Definition: messagebox.c:31
DWORD style
Definition: winuser.h:3012
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LPCWSTR lpszText
Definition: winuser.h:3281
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:291
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
#define MB_TOPMOST
Definition: winuser.h:819
LONG right
Definition: windef.h:293
#define DT_NOPREFIX
Definition: winuser.h:537
#define WS_EX_RIGHT
Definition: winuser.h:400
#define IDI_EXCLAMATIONW
Definition: messagebox.c:46
#define SS_RIGHT
Definition: pedump.c:694
HFONT hFont
Definition: main.c:53
#define DCX_WINDOW
Definition: winuser.h:2074
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define DS_MODALFRAME
Definition: winuser.h:375
#define SM_CXSCREEN
Definition: winuser.h:949
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define WS_EX_CONTROLPARENT
Definition: winuser.h:387
#define DT_LEFT
Definition: winuser.h:534
#define DT_CALCRECT
Definition: winuser.h:526
#define MB_USERICON
Definition: winuser.h:777
LPCWSTR lpszIcon
Definition: winuser.h:3284
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SS_LEFT
Definition: pedump.c:692
#define SM_CXICON
Definition: winuser.h:962
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
LPCWSTR lpszCaption
Definition: winuser.h:3282
#define MB_ICONQUESTION
Definition: winuser.h:783
LONG cx
Definition: windef.h:319
LONG_PTR LPARAM
Definition: windef.h:208
POINT iconPos
Definition: startmenu.cpp:1391
#define PtrToUlong(u)
Definition: config.h:107
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
DWORD dwExtendedStyle
Definition: winuser.h:3013
#define WS_CAPTION
Definition: pedump.c:624
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
#define MSGBOXEX_SPACING
Definition: messagebox.c:56
static UINT LoadAllocStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT PWSTR *pString, IN PCWSTR pDefaultString OPTIONAL)
Definition: messagebox.c:108
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DS_NOIDLEMSG
Definition: winuser.h:377
HWND hwndOwner
Definition: winuser.h:3279
#define MSGBOX_IDTEXT
Definition: messagebox.c:42
unsigned short WORD
Definition: ntddk_ex.h:93
int WINAPI GetSystemMetrics(_In_ int)
DWORD dwButtons
Definition: messagebox.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MB_ICONASTERISK
Definition: winuser.h:778
int ret
#define SM_CYICON
Definition: winuser.h:963
static const WCHAR L[]
Definition: oid.c:1250
#define DS_SETFONT
Definition: winuser.h:378
short x
Definition: winuser.h:3015
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define WS_EX_TOPMOST
Definition: pedump.c:647
HINSTANCE hInstance
Definition: winuser.h:3280
#define SS_NOPREFIX
Definition: winuser.h:350
const char * wine_dbgstr_wn(const WCHAR *str, int n)
Definition: compat.c:342
#define RESCALE_X(_x, _units)
Definition: messagebox.c:63
#define WS_TABSTOP
Definition: pedump.c:634
short y
Definition: winuser.h:3016
BOOL WINAPI MessageBeep(IN UINT uType)
Definition: messagebox.c:1329
#define BS_PUSHBUTTON
Definition: pedump.c:651
WORD cdit
Definition: winuser.h:3014
#define ERR(fmt,...)
Definition: debug.h:109
static HDC hDC
Definition: 3dtext.c:33
#define DCX_CACHE
Definition: winuser.h:2075
#define DT_SINGLELINE
Definition: winuser.h:540
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *)
Definition: font.c:2145
#define BTN_CX
Definition: messagebox.c:53
#define MB_RIGHT
Definition: winuser.h:789
HICON hIcon
Definition: msconfig.c:44
#define DT_EXTERNALLEADING
Definition: winuser.h:533
#define ALIGN_UP_POINTER(ptr, type)
Definition: umtypes.h:97
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define WS_POPUP
Definition: pedump.c:616
UINT uDefButton
Definition: messagebox.c:34
#define MB_OK
Definition: winuser.h:784
short cy
Definition: winuser.h:3018
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
MSGBOXPARAMSW mbp
Definition: messagebox.c:25
#define RESCALE_Y(_y, _units)
Definition: messagebox.c:64
#define HIWORD(l)
Definition: typedefs.h:246
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
LONG bottom
Definition: windef.h:294
static char * dest
Definition: rtl.c:135
WCHAR * LPWSTR
Definition: xmlstorage.h:184
DWORD dwExtendedStyle
Definition: winuser.h:3003
GLfloat units
Definition: glext.h:11727
short cx
Definition: winuser.h:3017
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_SYSMENU
Definition: pedump.c:629
DWORD dwStyle
Definition: winuser.h:3283
#define SS_ICON
Definition: pedump.c:695
LONG cy
Definition: windef.h:320
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MSGBOXEX_MARGIN
Definition: messagebox.c:58
#define IDI_ASTERISKW
Definition: messagebox.c:47
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define DT_EDITCONTROL
Definition: winuser.h:528
#define IDI_QUESTIONW
Definition: messagebox.c:45
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
LONG WINAPI GetDialogBaseUnits(void)
Definition: dialog.c:2076
#define MSGBOX_IDICON
Definition: messagebox.c:41

Referenced by MessageBoxTimeoutIndirectW(), and TestSoftModalMsgBox().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( user32  )

Variable Documentation

◆ MsgBtnInfo

const MSGBTNINFO MsgBtnInfo[]
static
Initial value:
=
{
DECLARE_MB_2(OK, CANCEL),
DECLARE_MB_3(YES, NO, CANCEL),
DECLARE_MB_2(YES, NO),
DECLARE_MB_2(RETRY, CANCEL),
}
#define OK(condition, fail_message,...)
#define DECLARE_MB_1(_btn0)
Definition: messagebox.c:69
#define IGNORE
Definition: tif_dirread.c:44
#define DECLARE_MB_3(_btn0, _btn1, _btn2)
Definition: messagebox.c:75
#define DECLARE_MB_2(_btn0, _btn1)
Definition: messagebox.c:72
#define ABORT
Definition: ftp_var.h:30

Definition at line 86 of file messagebox.c.

Referenced by MessageBoxTimeoutIndirectW().