Skip to content

Commit b55cf70

Browse files
committed
[USER32] Code formatting only.
1 parent cb77cc7 commit b55cf70

File tree

1 file changed

+79
-64
lines changed

1 file changed

+79
-64
lines changed

win32ss/user/user32/windows/messagebox.c

Lines changed: 79 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1818
*/
1919
/*
20-
*
2120
* PROJECT: ReactOS user32.dll
2221
* FILE: win32ss/user/user32/windows/messagebox.c
23-
* PURPOSE: Input
22+
* PURPOSE: Message Boxes
2423
* PROGRAMMERS: Casper S. Hornstrup ([email protected])
2524
* Thomas Weidenmueller ([email protected])
2625
* UPDATE HISTORY:
@@ -109,6 +108,7 @@ typedef struct _MSGBOXINFO
109108
UINT Timeout;
110109
} MSGBOXINFO, *PMSGBOXINFO;
111110

111+
112112
/* INTERNAL FUNCTIONS ********************************************************/
113113

114114
static VOID MessageBoxTextToClipboard(HWND DialogWindow)
@@ -222,7 +222,7 @@ static INT_PTR CALLBACK MessageBoxProc(
222222
int Alert;
223223
PMSGBOXINFO mbi;
224224
HELPINFO hi;
225-
HWND owner;
225+
HWND hwndOwner;
226226

227227
switch (message)
228228
{
@@ -296,7 +296,7 @@ static INT_PTR CALLBACK MessageBoxProc(
296296
return 0;
297297
case IDHELP:
298298
/* send WM_HELP message to messagebox window */
299-
hi.cbSize = sizeof(HELPINFO);
299+
hi.cbSize = sizeof(hi);
300300
hi.iContextType = HELPINFO_WINDOW;
301301
hi.iCtrlId = LOWORD(wParam);
302302
hi.hItemHandle = (HANDLE)lParam;
@@ -320,12 +320,14 @@ static INT_PTR CALLBACK MessageBoxProc(
320320
hi.dwContextId = GetWindowContextHelpId(hwnd);
321321

322322
if (mbi->lpfnMsgBoxCallback)
323+
{
323324
mbi->lpfnMsgBoxCallback(&hi);
325+
}
324326
else
325327
{
326-
owner = GetWindow(hwnd, GW_OWNER);
327-
if (owner)
328-
SendMessageW(GetWindow(hwnd, GW_OWNER), WM_HELP, 0, (LPARAM)&hi);
328+
hwndOwner = GetWindow(hwnd, GW_OWNER);
329+
if (hwndOwner)
330+
SendMessageW(hwndOwner, WM_HELP, 0, (LPARAM)&hi);
329331
}
330332
return 0;
331333
}
@@ -348,7 +350,7 @@ static INT_PTR CALLBACK MessageBoxProc(
348350
case WM_TIMER:
349351
if (wParam == 0)
350352
{
351-
EndDialog(hwnd, 32000);
353+
EndDialog(hwnd, IDTIMEOUT);
352354
}
353355
return 0;
354356
}
@@ -357,7 +359,7 @@ static INT_PTR CALLBACK MessageBoxProc(
357359

358360
static int
359361
MessageBoxTimeoutIndirectW(
360-
CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT Timeout)
362+
CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout)
361363
{
362364
DLGTEMPLATE *tpl;
363365
DLGITEMTEMPLATE *iico, *itxt;
@@ -388,7 +390,9 @@ MessageBoxTimeoutIndirectW(
388390
else if (IS_INTRESOURCE(lpMsgBoxParams->lpszCaption))
389391
{
390392
/* User-defined resource string */
391-
caplen = LoadStringW(lpMsgBoxParams->hInstance, PtrToUlong(lpMsgBoxParams->lpszCaption), (LPWSTR)&caption, 0);
393+
caplen = LoadStringW(lpMsgBoxParams->hInstance,
394+
PtrToUlong(lpMsgBoxParams->lpszCaption),
395+
(LPWSTR)&caption, 0);
392396
}
393397
else
394398
{
@@ -406,7 +410,9 @@ MessageBoxTimeoutIndirectW(
406410
else if (IS_INTRESOURCE(lpMsgBoxParams->lpszText))
407411
{
408412
/* User-defined resource string */
409-
textlen = LoadStringW(lpMsgBoxParams->hInstance, PtrToUlong(lpMsgBoxParams->lpszText), (LPWSTR)&text, 0);
413+
textlen = LoadStringW(lpMsgBoxParams->hInstance,
414+
PtrToUlong(lpMsgBoxParams->lpszText),
415+
(LPWSTR)&text, 0);
410416
}
411417
else
412418
{
@@ -433,33 +439,34 @@ MessageBoxTimeoutIndirectW(
433439

434440
switch (lpMsgBoxParams->dwStyle & MB_ICONMASK)
435441
{
436-
case MB_ICONEXCLAMATION:
437-
Icon = LoadIconW(0, IDI_EXCLAMATIONW);
438-
MessageBeep(MB_ICONEXCLAMATION);
439-
break;
440-
case MB_ICONQUESTION:
441-
Icon = LoadIconW(0, IDI_QUESTIONW);
442-
MessageBeep(MB_ICONQUESTION);
443-
break;
444-
case MB_ICONASTERISK:
445-
Icon = LoadIconW(0, IDI_ASTERISKW);
446-
MessageBeep(MB_ICONASTERISK);
447-
break;
448-
case MB_ICONHAND:
449-
Icon = LoadIconW(0, IDI_HANDW);
450-
MessageBeep(MB_ICONHAND);
451-
break;
452-
case MB_USERICON:
453-
Icon = LoadIconW(lpMsgBoxParams->hInstance, lpMsgBoxParams->lpszIcon);
454-
MessageBeep(MB_OK);
455-
break;
456-
default:
457-
/* By default, Windows 95/98/NT does not associate an icon to message boxes.
458-
* So ReactOS should do the same.
459-
*/
460-
Icon = (HICON)0;
461-
MessageBeep(MB_OK);
462-
break;
442+
case MB_ICONEXCLAMATION: // case MB_ICONWARNING:
443+
Icon = LoadIconW(0, IDI_EXCLAMATIONW);
444+
MessageBeep(MB_ICONEXCLAMATION);
445+
break;
446+
case MB_ICONQUESTION:
447+
Icon = LoadIconW(0, IDI_QUESTIONW);
448+
MessageBeep(MB_ICONQUESTION);
449+
break;
450+
case MB_ICONASTERISK: // case MB_ICONINFORMATION:
451+
Icon = LoadIconW(0, IDI_ASTERISKW);
452+
MessageBeep(MB_ICONASTERISK);
453+
break;
454+
case MB_ICONHAND: // case MB_ICONSTOP: case MB_ICONERROR:
455+
Icon = LoadIconW(0, IDI_HANDW);
456+
MessageBeep(MB_ICONHAND);
457+
break;
458+
case MB_USERICON:
459+
Icon = LoadIconW(lpMsgBoxParams->hInstance, lpMsgBoxParams->lpszIcon);
460+
MessageBeep(MB_OK);
461+
break;
462+
default:
463+
/*
464+
* By default, Windows 95/98/NT does not associate an icon
465+
* to message boxes. So ReactOS should do the same.
466+
*/
467+
Icon = NULL;
468+
MessageBeep(MB_OK);
469+
break;
463470
}
464471

465472
/* Basic space */
@@ -469,16 +476,16 @@ MessageBoxTimeoutIndirectW(
469476
sizeof(WORD); /* font height */
470477

471478
/* Space for icon */
472-
if (NULL != Icon)
479+
if (Icon)
473480
{
474-
bufsize = (bufsize + 3) & ~3;
475-
bufsize += sizeof(DLGITEMTEMPLATE) +
476-
4 * sizeof(WORD) +
477-
sizeof(WCHAR);
481+
bufsize = ALIGN_UP(bufsize, DWORD);
482+
bufsize += sizeof(DLGITEMTEMPLATE) +
483+
4 * sizeof(WORD) +
484+
sizeof(WCHAR);
478485
}
479486

480487
/* Space for text */
481-
bufsize = (bufsize + 3) & ~3;
488+
bufsize = ALIGN_UP(bufsize, DWORD);
482489
bufsize += sizeof(DLGITEMTEMPLATE) +
483490
3 * sizeof(WORD) +
484491
(textlen + 1) * sizeof(WCHAR);
@@ -488,19 +495,22 @@ MessageBoxTimeoutIndirectW(
488495
/* Get the default text of the buttons */
489496
if (Buttons.btnIds[i])
490497
{
491-
ButtonLen[i] = LoadStringW(User32Instance, Buttons.btnIds[i], (LPWSTR)&ButtonText[i], 0);
498+
ButtonLen[i] = LoadStringW(User32Instance,
499+
Buttons.btnIds[i],
500+
(LPWSTR)&ButtonText[i], 0);
492501
}
493502
else
494503
{
504+
/* No text, use blank */
495505
ButtonText[i] = L"";
496-
ButtonLen[i] = 0;
506+
ButtonLen[i] = 0;
497507
}
498508

499-
/* Space for buttons */
500-
bufsize = (bufsize + 3) & ~3;
501-
bufsize += sizeof(DLGITEMTEMPLATE) +
502-
3 * sizeof(WORD) +
503-
(ButtonLen[i] + 1) * sizeof(WCHAR);
509+
/* Space for buttons */
510+
bufsize = ALIGN_UP(bufsize, DWORD);
511+
bufsize += sizeof(DLGITEMTEMPLATE) +
512+
3 * sizeof(WORD) +
513+
(ButtonLen[i] + 1) * sizeof(WCHAR);
504514
}
505515

506516
buf = RtlAllocateHeap(GetProcessHeap(), 0, bufsize);
@@ -520,15 +530,16 @@ MessageBoxTimeoutIndirectW(
520530

521531
tpl = (DLGTEMPLATE *)buf;
522532

523-
tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU | DS_CENTER | DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG;
533+
tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU |
534+
DS_CENTER | DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG;
524535
tpl->dwExtendedStyle = WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT;
525536
if (lpMsgBoxParams->dwStyle & MB_TOPMOST)
526537
tpl->dwExtendedStyle |= WS_EX_TOPMOST;
527538
if (lpMsgBoxParams->dwStyle & MB_RIGHT)
528539
tpl->dwExtendedStyle |= WS_EX_RIGHT;
529540
tpl->x = 100;
530541
tpl->y = 100;
531-
tpl->cdit = Buttons.btnCnt + ((Icon != (HICON)0) ? 1 : 0) + 1;
542+
tpl->cdit = Buttons.btnCnt + (Icon ? 1 : 0) + 1;
532543

533544
dest = (BYTE *)(tpl + 1);
534545

@@ -550,7 +561,7 @@ MessageBoxTimeoutIndirectW(
550561
/* Create icon */
551562
if (Icon)
552563
{
553-
dest = (BYTE*)(((ULONG_PTR)dest + 3) & ~3);
564+
dest = ALIGN_UP_POINTER(dest, DWORD);
554565
iico = (DLGITEMTEMPLATE *)dest;
555566
iico->style = WS_CHILD | WS_VISIBLE | SS_ICON;
556567
iico->dwExtendedStyle = 0;
@@ -569,8 +580,8 @@ MessageBoxTimeoutIndirectW(
569580
dest += sizeof(WORD);
570581
}
571582

572-
/* create static for text */
573-
dest = (BYTE*)(((UINT_PTR)dest + 3) & ~3);
583+
/* Create static for text */
584+
dest = ALIGN_UP_POINTER(dest, DWORD);
574585
itxt = (DLGITEMTEMPLATE *)dest;
575586
itxt->style = WS_CHILD | WS_VISIBLE | SS_NOPREFIX;
576587
if (lpMsgBoxParams->dwStyle & MB_RIGHT)
@@ -616,15 +627,16 @@ MessageBoxTimeoutIndirectW(
616627
units.cy = HIWORD(defUnits);
617628
}
618629

619-
/* create buttons */
630+
/* Create buttons */
620631
btnsize.cx = BTN_CX;
621632
btnsize.cy = BTN_CY;
622633
btnrect.left = btnrect.top = 0;
623634

624635
for (i = 0; i < Buttons.btnCnt; i++)
625636
{
626-
dest = (BYTE*)(((UINT_PTR)dest + 3) & ~3);
637+
dest = ALIGN_UP_POINTER(dest, DWORD);
627638
ibtn[i] = (DLGITEMTEMPLATE *)dest;
639+
628640
ibtn[i]->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
629641
if (!defbtn && (i == ((lpMsgBoxParams->dwStyle & MB_DEFMASK) >> 8)))
630642
{
@@ -651,7 +663,8 @@ MessageBoxTimeoutIndirectW(
651663
dest += sizeof(WORD);
652664

653665
// btnrect.right = btnrect.bottom = 0; // FIXME: Is it needed??
654-
DrawTextW(hDC, ButtonText[i], ButtonLen[i], &btnrect, DT_LEFT | DT_SINGLELINE | DT_CALCRECT);
666+
DrawTextW(hDC, ButtonText[i], ButtonLen[i], &btnrect,
667+
DT_LEFT | DT_SINGLELINE | DT_CALCRECT);
655668
btnsize.cx = max(btnsize.cx, btnrect.right);
656669
btnsize.cy = max(btnsize.cy, btnrect.bottom);
657670
}
@@ -671,7 +684,8 @@ MessageBoxTimeoutIndirectW(
671684
txtrect.top = txtrect.left = txtrect.bottom = 0;
672685
if (textlen != 0)
673686
{
674-
DrawTextW(hDC, text, textlen, &txtrect, DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT);
687+
DrawTextW(hDC, text, textlen, &txtrect,
688+
DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT);
675689
}
676690
else
677691
{
@@ -770,14 +784,14 @@ MessageBoxTimeoutIndirectW(
770784
tpl->cx = RESCALE_X(btnleft, units);
771785
tpl->cy = RESCALE_Y(btntop, units);
772786

773-
/* finally show the messagebox */
787+
/* Finally show the messagebox */
774788
mbi.Icon = Icon;
775789
mbi.dwContextHelpId = lpMsgBoxParams->dwContextHelpId;
776790
mbi.lpfnMsgBoxCallback = lpMsgBoxParams->lpfnMsgBoxCallback;
777791
mbi.dwStyle = lpMsgBoxParams->dwStyle;
778792
mbi.nButtons = Buttons.btnCnt;
779793
mbi.Btns = Buttons.btnIdx;
780-
mbi.Timeout = Timeout;
794+
mbi.Timeout = dwTimeout;
781795

782796
/* Pass on to Justin Case so he can peek the message? */
783797
mbi.cbSize = lpMsgBoxParams->cbSize;
@@ -788,16 +802,17 @@ MessageBoxTimeoutIndirectW(
788802
mbi.lpszIcon = lpMsgBoxParams->lpszIcon;
789803
mbi.dwLanguageId = lpMsgBoxParams->dwLanguageId;
790804

791-
ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl, lpMsgBoxParams->hwndOwner,
805+
ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl,
806+
lpMsgBoxParams->hwndOwner,
792807
MessageBoxProc, (LPARAM)&mbi);
793808

794809
Quit:
795810
RtlFreeHeap(GetProcessHeap(), 0, buf);
796811
return ret;
797812
}
798813

799-
/* FUNCTIONS *****************************************************************/
800814

815+
/* FUNCTIONS *****************************************************************/
801816

802817
/*
803818
* @implemented

0 commit comments

Comments
 (0)