17
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
18
*/
19
19
/*
20
- *
21
20
* PROJECT: ReactOS user32.dll
22
21
* FILE: win32ss/user/user32/windows/messagebox.c
23
- * PURPOSE: Input
22
+ * PURPOSE: Message Boxes
24
23
* PROGRAMMERS: Casper S. Hornstrup ([email protected] )
25
24
* Thomas Weidenmueller ([email protected] )
26
25
* UPDATE HISTORY:
@@ -109,6 +108,7 @@ typedef struct _MSGBOXINFO
109
108
UINT Timeout ;
110
109
} MSGBOXINFO , * PMSGBOXINFO ;
111
110
111
+
112
112
/* INTERNAL FUNCTIONS ********************************************************/
113
113
114
114
static VOID MessageBoxTextToClipboard (HWND DialogWindow )
@@ -222,7 +222,7 @@ static INT_PTR CALLBACK MessageBoxProc(
222
222
int Alert ;
223
223
PMSGBOXINFO mbi ;
224
224
HELPINFO hi ;
225
- HWND owner ;
225
+ HWND hwndOwner ;
226
226
227
227
switch (message )
228
228
{
@@ -296,7 +296,7 @@ static INT_PTR CALLBACK MessageBoxProc(
296
296
return 0 ;
297
297
case IDHELP :
298
298
/* send WM_HELP message to messagebox window */
299
- hi .cbSize = sizeof (HELPINFO );
299
+ hi .cbSize = sizeof (hi );
300
300
hi .iContextType = HELPINFO_WINDOW ;
301
301
hi .iCtrlId = LOWORD (wParam );
302
302
hi .hItemHandle = (HANDLE )lParam ;
@@ -320,12 +320,14 @@ static INT_PTR CALLBACK MessageBoxProc(
320
320
hi .dwContextId = GetWindowContextHelpId (hwnd );
321
321
322
322
if (mbi -> lpfnMsgBoxCallback )
323
+ {
323
324
mbi -> lpfnMsgBoxCallback (& hi );
325
+ }
324
326
else
325
327
{
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 );
329
331
}
330
332
return 0 ;
331
333
}
@@ -348,7 +350,7 @@ static INT_PTR CALLBACK MessageBoxProc(
348
350
case WM_TIMER :
349
351
if (wParam == 0 )
350
352
{
351
- EndDialog (hwnd , 32000 );
353
+ EndDialog (hwnd , IDTIMEOUT );
352
354
}
353
355
return 0 ;
354
356
}
@@ -357,7 +359,7 @@ static INT_PTR CALLBACK MessageBoxProc(
357
359
358
360
static int
359
361
MessageBoxTimeoutIndirectW (
360
- CONST MSGBOXPARAMSW * lpMsgBoxParams , UINT Timeout )
362
+ CONST MSGBOXPARAMSW * lpMsgBoxParams , UINT dwTimeout )
361
363
{
362
364
DLGTEMPLATE * tpl ;
363
365
DLGITEMTEMPLATE * iico , * itxt ;
@@ -388,7 +390,9 @@ MessageBoxTimeoutIndirectW(
388
390
else if (IS_INTRESOURCE (lpMsgBoxParams -> lpszCaption ))
389
391
{
390
392
/* 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 );
392
396
}
393
397
else
394
398
{
@@ -406,7 +410,9 @@ MessageBoxTimeoutIndirectW(
406
410
else if (IS_INTRESOURCE (lpMsgBoxParams -> lpszText ))
407
411
{
408
412
/* 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 );
410
416
}
411
417
else
412
418
{
@@ -433,33 +439,34 @@ MessageBoxTimeoutIndirectW(
433
439
434
440
switch (lpMsgBoxParams -> dwStyle & MB_ICONMASK )
435
441
{
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 ;
463
470
}
464
471
465
472
/* Basic space */
@@ -469,16 +476,16 @@ MessageBoxTimeoutIndirectW(
469
476
sizeof (WORD ); /* font height */
470
477
471
478
/* Space for icon */
472
- if (NULL != Icon )
479
+ if (Icon )
473
480
{
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 );
478
485
}
479
486
480
487
/* Space for text */
481
- bufsize = (bufsize + 3 ) & ~ 3 ;
488
+ bufsize = ALIGN_UP (bufsize , DWORD ) ;
482
489
bufsize += sizeof (DLGITEMTEMPLATE ) +
483
490
3 * sizeof (WORD ) +
484
491
(textlen + 1 ) * sizeof (WCHAR );
@@ -488,19 +495,22 @@ MessageBoxTimeoutIndirectW(
488
495
/* Get the default text of the buttons */
489
496
if (Buttons .btnIds [i ])
490
497
{
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 );
492
501
}
493
502
else
494
503
{
504
+ /* No text, use blank */
495
505
ButtonText [i ] = L"" ;
496
- ButtonLen [i ] = 0 ;
506
+ ButtonLen [i ] = 0 ;
497
507
}
498
508
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 );
504
514
}
505
515
506
516
buf = RtlAllocateHeap (GetProcessHeap (), 0 , bufsize );
@@ -520,15 +530,16 @@ MessageBoxTimeoutIndirectW(
520
530
521
531
tpl = (DLGTEMPLATE * )buf ;
522
532
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 ;
524
535
tpl -> dwExtendedStyle = WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT ;
525
536
if (lpMsgBoxParams -> dwStyle & MB_TOPMOST )
526
537
tpl -> dwExtendedStyle |= WS_EX_TOPMOST ;
527
538
if (lpMsgBoxParams -> dwStyle & MB_RIGHT )
528
539
tpl -> dwExtendedStyle |= WS_EX_RIGHT ;
529
540
tpl -> x = 100 ;
530
541
tpl -> y = 100 ;
531
- tpl -> cdit = Buttons .btnCnt + (( Icon != ( HICON ) 0 ) ? 1 : 0 ) + 1 ;
542
+ tpl -> cdit = Buttons .btnCnt + (Icon ? 1 : 0 ) + 1 ;
532
543
533
544
dest = (BYTE * )(tpl + 1 );
534
545
@@ -550,7 +561,7 @@ MessageBoxTimeoutIndirectW(
550
561
/* Create icon */
551
562
if (Icon )
552
563
{
553
- dest = ( BYTE * )((( ULONG_PTR ) dest + 3 ) & ~ 3 );
564
+ dest = ALIGN_UP_POINTER ( dest , DWORD );
554
565
iico = (DLGITEMTEMPLATE * )dest ;
555
566
iico -> style = WS_CHILD | WS_VISIBLE | SS_ICON ;
556
567
iico -> dwExtendedStyle = 0 ;
@@ -569,8 +580,8 @@ MessageBoxTimeoutIndirectW(
569
580
dest += sizeof (WORD );
570
581
}
571
582
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 );
574
585
itxt = (DLGITEMTEMPLATE * )dest ;
575
586
itxt -> style = WS_CHILD | WS_VISIBLE | SS_NOPREFIX ;
576
587
if (lpMsgBoxParams -> dwStyle & MB_RIGHT )
@@ -616,15 +627,16 @@ MessageBoxTimeoutIndirectW(
616
627
units .cy = HIWORD (defUnits );
617
628
}
618
629
619
- /* create buttons */
630
+ /* Create buttons */
620
631
btnsize .cx = BTN_CX ;
621
632
btnsize .cy = BTN_CY ;
622
633
btnrect .left = btnrect .top = 0 ;
623
634
624
635
for (i = 0 ; i < Buttons .btnCnt ; i ++ )
625
636
{
626
- dest = ( BYTE * )((( UINT_PTR ) dest + 3 ) & ~ 3 );
637
+ dest = ALIGN_UP_POINTER ( dest , DWORD );
627
638
ibtn [i ] = (DLGITEMTEMPLATE * )dest ;
639
+
628
640
ibtn [i ]-> style = WS_CHILD | WS_VISIBLE | WS_TABSTOP ;
629
641
if (!defbtn && (i == ((lpMsgBoxParams -> dwStyle & MB_DEFMASK ) >> 8 )))
630
642
{
@@ -651,7 +663,8 @@ MessageBoxTimeoutIndirectW(
651
663
dest += sizeof (WORD );
652
664
653
665
// 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 );
655
668
btnsize .cx = max (btnsize .cx , btnrect .right );
656
669
btnsize .cy = max (btnsize .cy , btnrect .bottom );
657
670
}
@@ -671,7 +684,8 @@ MessageBoxTimeoutIndirectW(
671
684
txtrect .top = txtrect .left = txtrect .bottom = 0 ;
672
685
if (textlen != 0 )
673
686
{
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 );
675
689
}
676
690
else
677
691
{
@@ -770,14 +784,14 @@ MessageBoxTimeoutIndirectW(
770
784
tpl -> cx = RESCALE_X (btnleft , units );
771
785
tpl -> cy = RESCALE_Y (btntop , units );
772
786
773
- /* finally show the messagebox */
787
+ /* Finally show the messagebox */
774
788
mbi .Icon = Icon ;
775
789
mbi .dwContextHelpId = lpMsgBoxParams -> dwContextHelpId ;
776
790
mbi .lpfnMsgBoxCallback = lpMsgBoxParams -> lpfnMsgBoxCallback ;
777
791
mbi .dwStyle = lpMsgBoxParams -> dwStyle ;
778
792
mbi .nButtons = Buttons .btnCnt ;
779
793
mbi .Btns = Buttons .btnIdx ;
780
- mbi .Timeout = Timeout ;
794
+ mbi .Timeout = dwTimeout ;
781
795
782
796
/* Pass on to Justin Case so he can peek the message? */
783
797
mbi .cbSize = lpMsgBoxParams -> cbSize ;
@@ -788,16 +802,17 @@ MessageBoxTimeoutIndirectW(
788
802
mbi .lpszIcon = lpMsgBoxParams -> lpszIcon ;
789
803
mbi .dwLanguageId = lpMsgBoxParams -> dwLanguageId ;
790
804
791
- ret = DialogBoxIndirectParamW (lpMsgBoxParams -> hInstance , tpl , lpMsgBoxParams -> hwndOwner ,
805
+ ret = DialogBoxIndirectParamW (lpMsgBoxParams -> hInstance , tpl ,
806
+ lpMsgBoxParams -> hwndOwner ,
792
807
MessageBoxProc , (LPARAM )& mbi );
793
808
794
809
Quit :
795
810
RtlFreeHeap (GetProcessHeap (), 0 , buf );
796
811
return ret ;
797
812
}
798
813
799
- /* FUNCTIONS *****************************************************************/
800
814
815
+ /* FUNCTIONS *****************************************************************/
801
816
802
817
/*
803
818
* @implemented
0 commit comments