MCPcopy Create free account
hub / github.com/NetHack/NetHack / mswin_message_window_size

Function mswin_message_window_size

win/win32/mhmsgwnd.c:739–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737}
738
739void
740mswin_message_window_size(HWND hWnd, LPSIZE sz)
741{
742 HDC hdc;
743 HGDIOBJ saveFont;
744 TEXTMETRIC tm;
745 PNHMessageWindow data;
746 RECT rt, client_rt;
747
748 data = (PNHMessageWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
749 if (!data)
750 return;
751
752 /* -- Calculate the font size -- */
753 /* Get the handle to the client area's device context. */
754 hdc = GetDC(hWnd);
755 cached_font * font = mswin_get_font(NHW_MESSAGE, ATR_NONE, hdc, FALSE);
756 saveFont = SelectObject(hdc, font->hFont);
757
758 /* Extract font dimensions from the text metrics. */
759 GetTextMetrics(hdc, &tm);
760 data->xChar = tm.tmAveCharWidth;
761 data->xUpper = (tm.tmPitchAndFamily & 1 ? 3 : 2) * data->xChar / 2;
762 data->yChar = tm.tmHeight + tm.tmExternalLeading;
763 data->xPage = 1;
764
765 /* Free the device context. */
766 SelectObject(hdc, saveFont);
767 ReleaseDC(hWnd, hdc);
768
769 /* -- calculate window size -- */
770 GetWindowRect(hWnd, &rt);
771 sz->cx = rt.right - rt.left;
772 sz->cy = rt.bottom - rt.top;
773
774 /* set size to accommodate MSG_VISIBLE_LINES and
775 horizontal scroll bar (difference between window rect and client rect
776 */
777 GetClientRect(hWnd, &client_rt);
778 sz->cy = sz->cy - (client_rt.bottom - client_rt.top)
779 + data->yChar * MSG_VISIBLE_LINES;
780}
781
782/* check if text can be appended to the last line without wrapping */
783BOOL

Callers 2

mswin_layout_main_windowFunction · 0.70
onCreateFunction · 0.70

Calls 1

mswin_get_fontFunction · 0.70

Tested by

no test coverage detected