From ce931eec108e83cedc54f5f0ce28a19efb70e5bb Mon Sep 17 00:00:00 2001 From: Eric Mullins Date: Sat, 10 Oct 2009 14:21:12 -0600 Subject: [PATCH] Added width updates to ICS client on font and window size changes What still needs to be done is placing an update call after login to initialize with the correct width. I didn't see where to put that. --- winboard/winboard.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/winboard/winboard.c b/winboard/winboard.c index 5fda158..e6fcb8b 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -5456,6 +5456,29 @@ LoadGameDialog(HWND hwnd, char* title) } } +void UpdateICSWidth(HWND hText) +{ + HDC hdc; + TEXTMETRIC tm; + RECT rc; + HFONT hfont, hold_font; + + // get the text metrics + hdc = GetDC(hText); + hfont = CreateFontIndirect(&font[boardSize][CONSOLE_FONT]->lf); + hold_font = SelectObject(hdc, hfont); + GetTextMetrics(hdc, &tm); + SelectObject(hdc, hold_font); + DeleteObject(hfont); + ReleaseDC(hText, hdc); + + // get the rectangle + SendMessage(hText, EM_GETRECT, 0, (LPARAM)&rc); + + // update the width + ics_update_width((rc.right-rc.left) / tm.tmAveCharWidth); +} + VOID ChangedConsoleFont() { @@ -5495,6 +5518,7 @@ ChangedConsoleFont() paraf.dxOffset = WRAP_INDENT; SendMessage(hText, EM_SETPARAFORMAT, 0, (LPARAM) ¶f); SendMessage(hText, EM_EXSETSEL, 0, (LPARAM)&sel); + UpdateICSWidth(hText); } /*---------------------------------------------------------------------------*\ @@ -8239,6 +8263,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return OnMoving( &sd, hDlg, wParam, lParam ); case WM_EXITSIZEMOVE: + UpdateICSWidth(hText); return OnExitSizeMove( &sd, hDlg, wParam, lParam ); } -- 1.7.0.4