+ // set the right font for GetCharHeight() call below
+ wxWindowBase::SetFont(GetMessageFont());
+
+ // put the new edit control at the same place
+ RECT rc = wxGetWindowRect(hwndStatic);
+ ScreenRectToClient(GetHwnd(), rc);
+
+ // but make it less tall so that the message box fits on the screen: we try
+ // to make the message box take no more than 7/8 of the screen to leave
+ // some space above and below it
+ const int hText = (7*rectDisplay.height)/8 -
+ (
+ 2*::GetSystemMetrics(SM_CYFIXEDFRAME) +
+ ::GetSystemMetrics(SM_CYCAPTION) +
+ 5*GetCharHeight() // buttons + margins
+ );
+ const int dh = (rc.bottom - rc.top) - hText; // vertical space we save
+ rc.bottom -= dh;
+
+ // and it also must be wider as it needs a vertical scrollbar (in order
+ // to preserve the word wrap, otherwise the number of lines would change
+ // and we want the control to look as similar as possible to the original)
+ //
+ // NB: you would have thought that 2*SM_CXEDGE would be enough but it
+ // isn't, somehow, and the text control breaks lines differently from
+ // the static one so fudge by adding some extra space
+ const int dw = ::GetSystemMetrics(SM_CXVSCROLL) +
+ 4*::GetSystemMetrics(SM_CXEDGE);
+ rc.right += dw;
+
+
+ // chop of the trailing new line(s) from the message box text, they are
+ // ignored by the static control but result in extra lines and hence extra
+ // scrollbar position in the edit one
+ wxString text(wxGetWindowText(hwndStatic));
+ for ( wxString::reverse_iterator i = text.rbegin(); i != text.rend(); ++i )
+ {
+ if ( *i != '\n' )
+ {
+ // found last non-newline char, remove everything after it and stop
+ text.erase(i.base() + 1, text.end());
+ break;
+ }
+ }