Index: messagebox.c =================================================================== --- messagebox.c (revision 50934) +++ messagebox.c (working copy) @@ -34,7 +34,11 @@ #include #include +#include +static LPCTSTR s_szRegistryKey = _T("Software\\Microsoft\\User32"); +BOOL UseEditControl; + WINE_DEFAULT_DEBUG_CHANNEL(user32); /* DEFINES *******************************************************************/ @@ -180,6 +184,46 @@ return 0; } +HRESULT RegGetDWord(HKEY hKey, LPCTSTR szValueName, DWORD * lpdwResult) +{ + LONG lResult; + DWORD dwDataSize = sizeof(DWORD); + DWORD dwType = 0; + + // Check input parameters... + if (hKey == NULL || lpdwResult == NULL) return E_INVALIDARG; + + // Get dword value from the registry... + lResult = RegQueryValueEx(hKey, szValueName, 0, &dwType, (LPBYTE) lpdwResult, &dwDataSize ); + + // Check result and make sure the registry value is a DWORD(REG_DWORD)... + if (lResult != ERROR_SUCCESS) return HRESULT_FROM_WIN32(lResult); + else if (dwType != REG_DWORD) return DISP_E_TYPEMISMATCH; + + return NOERROR; +} + +void LoadSettings(void) +{ + HKEY hKey = NULL; + DWORD dwValue; + + if (RegOpenKey(HKEY_CURRENT_USER, s_szRegistryKey, &hKey) == ERROR_SUCCESS) + { + RegGetDWord(hKey, TEXT("blUseEditControl"), &dwValue); + if (dwValue == 1) + { + UseEditControl = TRUE; + } + else + { + UseEditControl = FALSE; + } + + RegCloseKey(hKey); + } +} + static int MessageBoxTimeoutIndirectW( CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT Timeout) @@ -190,7 +234,8 @@ WCHAR capbuf[32]; LPVOID buf; BYTE *dest; - LPCWSTR caption, text; + LPCWSTR caption; + LPWSTR text; HFONT hFont; HICON Icon; HDC hDC; @@ -203,6 +248,8 @@ MSGBOXINFO mbi; BOOL defbtn = FALSE; DWORD units = GetDialogBaseUnits(); + + LoadSettings(); if(!lpMsgBoxParams->lpszCaption || !HIWORD((LPWSTR)lpMsgBoxParams->lpszCaption)) { @@ -215,9 +262,24 @@ if(!lpMsgBoxParams->lpszText || !HIWORD(lpMsgBoxParams->lpszText)) text = L""; else - text = lpMsgBoxParams->lpszText; + { + text = (LPWSTR)lpMsgBoxParams->lpszText; + + if (UseEditControl == TRUE) + { + while (text[strlenW(text) - 1] == '\n') + { + text[strlenW(text) - 2] = '\0'; + } + while (text[strlenW(text) - 1] == '\r') + { + text[strlenW(text) - 2] = '\0'; + } + } + + } - caplen = strlenW(caption); + caplen = strlenW(caption); textlen = strlenW(text); /* Create selected buttons */ @@ -422,10 +484,19 @@ dest += sizeof(WORD); } - /* create static for text */ + /*Create static/edit control for text */ dest = (BYTE*)(((UINT_PTR)dest + 3) & ~3); itxt = (DLGITEMTEMPLATE *)dest; - itxt->style = WS_CHILD | WS_VISIBLE | SS_NOPREFIX; + + if (UseEditControl == TRUE) + { + itxt->style = WS_VISIBLE | ES_READONLY | ES_MULTILINE; + } + else + { + itxt->style = WS_VISIBLE | WS_CHILD | SS_NOPREFIX; + } + if(lpMsgBoxParams->dwStyle & MB_RIGHT) itxt->style |= SS_RIGHT; else @@ -435,14 +506,25 @@ dest += sizeof(DLGITEMTEMPLATE); *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); - *(WORD*)dest = 0x0082; /* static control */ - dest += sizeof(WORD); - memcpy(dest, text, textlen * sizeof(WCHAR)); + + if (UseEditControl == TRUE) + { + *(WORD*)dest = 0x0081; /* static control = 0x0082, edit control = 0x0081 */ + } + else + { + *(WORD*)dest = 0x0082; + } + + dest += sizeof(WORD); + memcpy(dest, text, textlen * sizeof(WCHAR)); dest += textlen * sizeof(WCHAR); *(WCHAR*)dest = 0; dest += sizeof(WCHAR); + *(WCHAR*)dest = '\0'; /* Need to terminate it for edit control */ *(WORD*)dest = 0; - dest += sizeof(WORD); + dest += sizeof(WORD); + *(WORD*)dest = '\0'; /* create buttons */ btnsize.cx = BTN_CX; @@ -579,14 +661,26 @@ btnleft = max(btnleft - MSGBOXEX_BUTTONSPACING, rc.left + txtrect.right); btnleft += MSGBOXEX_MARGIN; btntop += btnsize.cy + MSGBOXEX_MARGIN; - /* set size and position of the message static */ + /* set size and position of the message static/edit */ itxt->x = (rc.left * 4) / LOWORD(units); itxt->y = (rc.top * 8) / HIWORD(units); - itxt->cx = (((btnleft - rc.left - MSGBOXEX_MARGIN) * 4) / LOWORD(units)); - itxt->cy = ((txtrect.bottom * 8) / HIWORD(units)); - /* set size of the window */ - tpl->cx = (btnleft * 4) / LOWORD(units); - tpl->cy = (btntop * 8) / HIWORD(units); + + if (UseEditControl == TRUE) + { + itxt->cx = ((((btnleft - rc.left - MSGBOXEX_MARGIN) * 4)+50) / LOWORD(units)); /* +50 for edit control */ + /* set size of the window */ + tpl->cx = ((btnleft * 4)+60) / LOWORD(units); /* +60 for edit control */ + itxt->cy = (((txtrect.bottom * 8)+50) / HIWORD(units)); + tpl->cy = ((btntop * 8)+60) / HIWORD(units); + } + else + { + itxt->cx = (((btnleft - rc.left - MSGBOXEX_MARGIN) * 4) / LOWORD(units)); + tpl->cx = (btnleft * 4) / LOWORD(units); + itxt->cy = ((txtrect.bottom * 8) / HIWORD(units)); + tpl->cy = (btntop * 8) / HIWORD(units); + } + /* finally show the messagebox */ mbi.Icon = Icon;