Ignore:
Timestamp:
Mar 18, 2000, 5:13:41 PM (25 years ago)
Author:
cbratschi
Message:

merged with Corel 20000317, small icon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/msgbox.c

    r2804 r3153  
    1 /* $Id: msgbox.c,v 1.2 2000-02-16 14:34:24 sandervl Exp $ */
     1/* $Id: msgbox.c,v 1.3 2000-03-18 16:13:37 cbratschi Exp $ */
    22/*
    33 * Message boxes (based on Wine code)
     
    55 * Copyright 1995 Bernd Schmidt
    66 *
     7 * Corel WINE version: 20000317
    78 *
    89 */
     
    1415#include <heapstring.h>
    1516
    16 #define DBG_LOCALLOG    DBG_msgbox
     17#define DBG_LOCALLOG    DBG_msgbox
    1718#include "dbglocal.h"
    1819
     
    3132    LPCSTR lpszText;
    3233    char buf[256];
    33 
    34 ////    if (TWEAK_WineLook >= WIN95_LOOK) {
    35         NONCLIENTMETRICSA nclm;
    36 ////    INT i;
    37         nclm.cbSize = sizeof(NONCLIENTMETRICSA);
    38         SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
    39         hFont = CreateFontIndirectA (&nclm.lfMessageFont);
    40         /* set button font */
    41         for (i=1; i < 8; i++)
    42             SendDlgItemMessageA (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0);
    43         /* set text font */
    44         SendDlgItemMessageA (hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)hFont, 0);
    45 ////    }
     34    NONCLIENTMETRICSA nclm;
     35    BOOL hasIcon = TRUE;
     36
     37    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
     38    SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
     39    hFont = CreateFontIndirectA (&nclm.lfMessageFont);
     40    /* set button font */
     41    for (i=1; i < 8; i++)
     42        SendDlgItemMessageA (hwnd, i, WM_SETFONT, (WPARAM)hFont, 0);
     43    /* set text font */
     44    SendDlgItemMessageA (hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)hFont, 0);
     45
    4646    if (HIWORD(lpmb->lpszCaption)) {
    4747       SetWindowTextA(hwnd, lpmb->lpszCaption);
    4848    } else {
    4949       if (LoadStringA(lpmb->hInstance, LOWORD(lpmb->lpszCaption), buf, sizeof(buf)))
    50           SetWindowTextA(hwnd, buf);
     50          SetWindowTextA(hwnd, buf);
    5151    }
    5252    if (HIWORD(lpmb->lpszText)) {
     
    5555       lpszText = buf;
    5656       if (!LoadStringA(lpmb->hInstance, LOWORD(lpmb->lpszText), buf, sizeof(buf)))
    57           *buf = 0;     /* FIXME ?? */
     57          *buf = 0;     /* FIXME ?? */
    5858    }
    5959    SetWindowTextA(GetDlgItem(hwnd, MSGBOX_IDTEXT), lpszText);
     
    6262    switch(lpmb->dwStyle & MB_TYPEMASK) {
    6363    case MB_OK:
    64         ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
    65         /* fall through */
     64        ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
     65        /* fall through */
    6666    case MB_OKCANCEL:
    67         ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
    68         ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE);
    69         ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
    70         ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
    71         ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
    72         break;
     67        ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
     68        ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE);
     69        ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
     70        ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
     71        ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
     72        break;
    7373    case MB_ABORTRETRYIGNORE:
    74         ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
    75         ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
    76         ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
    77         ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
    78         break;
     74        ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
     75        ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
     76        ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
     77        ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
     78        break;
    7979    case MB_YESNO:
    80         ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
    81         /* fall through */
     80        ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
     81        /* fall through */
    8282    case MB_YESNOCANCEL:
    83         ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
    84         ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
    85         ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE);
    86         ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
    87         break;
     83        ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
     84        ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
     85        ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE);
     86        ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
     87        break;
    8888    case MB_RETRYCANCEL:
    89         ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
    90         ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
    91         ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
    92         ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
    93         ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
    94         break;
     89        ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
     90        ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
     91        ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
     92        ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
     93        ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
     94        break;
    9595    }
    9696    /* Set the icon */
    9797    switch(lpmb->dwStyle & MB_ICONMASK) {
    9898    case MB_ICONEXCLAMATION:
    99         SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
    100                            (WPARAM)LoadIconA(0, IDI_EXCLAMATIONA), 0);
    101         break;
     99        SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
     100                           (WPARAM)LoadIconA(0, IDI_EXCLAMATIONA), 0);
     101        break;
    102102    case MB_ICONQUESTION:
    103         SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
    104                              (WPARAM)LoadIconA(0, IDI_QUESTIONA), 0);
    105         break;
     103        SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
     104                             (WPARAM)LoadIconA(0, IDI_QUESTIONA), 0);
     105        break;
    106106    case MB_ICONASTERISK:
    107         SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
    108                              (WPARAM)LoadIconA(0, IDI_ASTERISKA), 0);
    109         break;
     107        SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
     108                             (WPARAM)LoadIconA(0, IDI_ASTERISKA), 0);
     109        break;
    110110    case MB_ICONHAND:
     111        SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
     112                             (WPARAM)LoadIconA(0, IDI_HANDA), 0);
     113        break;
    111114    default:
    112         SendDlgItemMessageA(hwnd, stc1, STM_SETICON,
    113                              (WPARAM)LoadIconA(0, IDI_HANDA), 0);
    114         break;
    115     }
    116    
     115      /* By default, Windows 95/98/NT do not associate an icon to message boxes.
     116       * So wine should do the same.
     117       */
     118        hasIcon = FALSE;
     119        ShowWindow(GetDlgItem(hwnd,stc1),SW_HIDE);
     120        break;
     121    }
     122
    117123    /* Position everything */
    118124    GetWindowRect(hwnd, &rect);
     
    122128    borheight -= rect.bottom - rect.top;
    123129    borwidth  -= rect.right - rect.left;
    124    
     130
    125131    /* Get the icon height */
    126     GetWindowRect(GetDlgItem(hwnd, MSGBOX_IDICON), &rect);
    127     MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2);
    128     iheight = rect.bottom - rect.top;
    129     ileft = rect.left;
    130     iwidth = rect.right - ileft;
    131    
     132    if (hasIcon)
     133    {
     134      GetWindowRect(GetDlgItem(hwnd, MSGBOX_IDICON), &rect);
     135      MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2);
     136      iheight = rect.bottom - rect.top;
     137      ileft = rect.left;
     138      iwidth = rect.right - ileft;
     139    } else
     140    {
     141      iheight = 0;
     142      ileft = 0;
     143      iwidth = 0;
     144    }
     145
    132146    hdc = GetDC(hwnd);
    133147    if (hFont)
    134         hPrevFont = SelectObject(hdc, hFont);
    135    
     148        hPrevFont = SelectObject(hdc, hFont);
     149
    136150    /* Get the number of visible buttons and their size */
    137151    bh = bw = 1; /* Minimum button sizes */
    138152    for (buttons = 0, i = 1; i < 8; i++)
    139153    {
    140         hItem = GetDlgItem(hwnd, i);
    141         if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE)
    142         {
    143             char buttonText[1024];
    144             int w, h;
    145             buttons++;
    146             if (GetWindowTextA(hItem, buttonText, sizeof buttonText))
    147             {
    148                 DrawTextA( hdc, buttonText, -1, &rect, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT);
    149                 h = rect.bottom - rect.top;
    150                 w = rect.right - rect.left;
    151                 if (h > bh) bh = h;
    152                 if (w > bw)  bw = w ;
    153             }
    154         }
     154        hItem = GetDlgItem(hwnd, i);
     155        if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE)
     156        {
     157            char buttonText[1024];
     158            int w, h;
     159            buttons++;
     160            if (GetWindowTextA(hItem, buttonText, sizeof buttonText))
     161            {
     162                DrawTextA( hdc, buttonText, -1, &rect, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT);
     163                h = rect.bottom - rect.top;
     164                w = rect.right - rect.left;
     165                if (h > bh) bh = h;
     166                if (w > bw)  bw = w ;
     167            }
     168        }
    155169    }
    156170    bw = MAX(bw, bh * 2);
     
    159173    bw = bw * 2;
    160174    bspace = bw/3; /* Space between buttons */
    161    
     175
    162176    /* Get the text size */
    163177    GetClientRect(GetDlgItem(hwnd, MSGBOX_IDTEXT), &rect);
    164178    rect.top = rect.left = rect.bottom = 0;
    165179    DrawTextA( hdc, lpszText, -1, &rect,
    166                DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
     180               DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
    167181    /* Min text width corresponds to space for the buttons */
    168182    tleft = 2 * ileft + iwidth;
    169183    twidth = MAX((bw + bspace) * buttons + bspace - tleft, rect.right);
    170184    theight = rect.bottom;
    171    
     185
    172186    if (hFont)
    173         SelectObject(hdc, hPrevFont);
     187        SelectObject(hdc, hPrevFont);
    174188    ReleaseDC(hItem, hdc);
    175    
     189
    176190    tiheight = 16 + MAX(iheight, theight);
    177191    wwidth  = tleft + twidth + ileft + borwidth;
    178192    wheight = 8 + tiheight + bh + borheight;
    179    
     193
    180194    /* Resize the window */
    181195    SetWindowPos(hwnd, 0, 0, 0, wwidth, wheight,
    182                 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
    183    
     196                SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
     197
    184198    /* Position the icon */
    185199    SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDICON), 0, ileft, (tiheight - iheight) / 2, 0, 0,
    186                 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
    187    
     200                SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
     201
    188202    /* Position the text */
    189203    SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDTEXT), 0, tleft, (tiheight - theight) / 2, twidth, theight,
    190                 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
    191    
     204                SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
     205
    192206    /* Position the buttons */
    193207    bpos = (wwidth - (bw + bspace) * buttons + bspace) / 2;
    194208    for (buttons = i = 0; i < 7; i++) {
    195         /* some arithmetic to get the right order for YesNoCancel windows */
    196         hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
    197         if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE) {
    198             if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) {
    199                 SetFocus(hItem);
    200                 SendMessageA( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
    201             }
    202             SetWindowPos(hItem, 0, bpos, tiheight, bw, bh,
    203                         SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
    204             bpos += bw + bspace;
    205         }
     209        /* some arithmetic to get the right order for YesNoCancel windows */
     210        hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
     211        if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE) {
     212            if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) {
     213                SetFocus(hItem);
     214                SendMessageA( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
     215            }
     216            SetWindowPos(hItem, 0, bpos, tiheight, bw, bh,
     217                        SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
     218            bpos += bw + bspace;
     219        }
    206220    }
    207221    return hFont;
     
    216230static LRESULT CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
    217231                                        WPARAM wParam, LPARAM lParam )
    218 { 
     232{
    219233  static HFONT hFont;
    220234  switch(message) {
     
    222236    hFont = MSGBOX_OnInit(hwnd, (LPMSGBOXPARAMSA)lParam);
    223237    return 0;
    224    
     238
    225239   case WM_COMMAND:
    226240    switch (wParam)
     
    235249      EndDialog(hwnd, wParam);
    236250      if (hFont)
    237           DeleteObject(hFont);
     251          DeleteObject(hFont);
    238252      break;
    239253    }
     
    287301    LPSTR textA  = HEAP_strdupWtoA( GetProcessHeap(), 0, text );
    288302    INT ret;
    289    
     303
    290304    ret = MessageBoxA( hwnd, textA, titleA, type );
    291305    HeapFree( GetProcessHeap(), 0, titleA );
     
    333347    return DialogBoxIndirectParamA( msgbox->hInstance, lpTemplate,
    334348                                      msgbox->hwndOwner, (DLGPROC)MSGBOX_DlgProc,
    335                                       (LPARAM)msgbox );
     349                                      (LPARAM)msgbox );
    336350}
    337351
     
    341355INT WINAPI MessageBoxIndirectW( LPMSGBOXPARAMSW msgbox )
    342356{
    343     MSGBOXPARAMSA       msgboxa;
     357    MSGBOXPARAMSA       msgboxa;
    344358
    345359    memcpy(&msgboxa,msgbox,sizeof(msgboxa));
    346     if (msgbox->lpszCaption)   
     360    if (msgbox->lpszCaption)
    347361      lstrcpyWtoA((LPSTR)msgboxa.lpszCaption,msgbox->lpszCaption);
    348     if (msgbox->lpszText)       
     362    if (msgbox->lpszText)
    349363      lstrcpyWtoA((LPSTR)msgboxa.lpszText,msgbox->lpszText);
    350364
    351365    return MessageBoxIndirectA(&msgboxa);
     366}
     367
     368/**************************************************************************
     369 *           FatalAppExit32A   (KERNEL32.108)
     370 */
     371void WINAPI FatalAppExitA( UINT action, LPCSTR str )
     372{
     373    //WARN("AppExit\n");
     374    MessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK );
     375    ExitProcess(0);
     376}
     377
     378
     379/**************************************************************************
     380 *           FatalAppExit32W   (KERNEL32.109)
     381 */
     382void WINAPI FatalAppExitW( UINT action, LPCWSTR str )
     383{
     384    //WARN("AppExit\n");
     385    MessageBoxW( 0, str, NULL, MB_SYSTEMMODAL | MB_OK );
     386    ExitProcess(0);
    352387}
    353388
Note: See TracChangeset for help on using the changeset viewer.