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

Function mswin_display_RIP_window

win/win32/mhrip.c:63–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void
64mswin_display_RIP_window(HWND hWnd)
65{
66 MSG msg;
67 RECT rt;
68 PNHRIPWindow data;
69 HWND mapWnd;
70 RECT riprt;
71 RECT clientrect;
72 RECT textrect;
73 HFONT OldFont;
74 MonitorInfo monitorInfo;
75
76 win10_monitor_info(hWnd, &monitorInfo);
77
78 data = (PNHRIPWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
79
80 data->x = (int)(RIP_OFFSET_X * monitorInfo.scale);
81 data->y = (int)(RIP_OFFSET_Y * monitorInfo.scale);
82 data->width = (int)(RIP_WIDTH * monitorInfo.scale);
83 data->height = (int)(RIP_HEIGHT * monitorInfo.scale);
84 data->graveX = (int)(RIP_GRAVE_X * monitorInfo.scale);
85 data->graveY = (int)(RIP_GRAVE_Y * monitorInfo.scale);
86 data->graveWidth = (int)(RIP_GRAVE_WIDTH * monitorInfo.scale);
87 data->graveHeight = (int)(RIP_GRAVE_HEIGHT * monitorInfo.scale);
88
89 GetNHApp()->hPopupWnd = hWnd;
90 mapWnd = mswin_hwnd_from_winid(WIN_MAP);
91 if (!IsWindow(mapWnd))
92 mapWnd = GetNHApp()->hMainWnd;
93 GetWindowRect(mapWnd, &rt);
94 GetWindowRect(hWnd, &riprt);
95 GetClientRect(hWnd, &clientrect);
96 textrect = clientrect;
97 textrect.top += data->y;
98 textrect.left += data->x;
99 textrect.right -= data->x;
100 if (data->window_text) {
101 HDC hdc = GetDC(hWnd);
102 OldFont = SelectObject(hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE)->hFont);
103 DrawText(hdc, data->window_text, strlen(data->window_text), &textrect,
104 DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
105 SelectObject(hdc, OldFont);
106 ReleaseDC(hWnd, hdc);
107 }
108 if (textrect.right - textrect.left > data->width)
109 clientrect.right = textrect.right + data->y - clientrect.right;
110 else
111 clientrect.right =
112 textrect.left + 2 * data->x + data->width - clientrect.right;
113 clientrect.bottom =
114 textrect.bottom + data->height + data->y - clientrect.bottom;
115 GetWindowRect(GetDlgItem(hWnd, IDOK), &textrect);
116 textrect.right -= textrect.left;
117 textrect.bottom -= textrect.top;
118 clientrect.bottom += textrect.bottom + data->y;
119 riprt.right -= riprt.left;
120 riprt.bottom -= riprt.top;

Callers 1

mswin_display_nhwindowFunction · 0.70

Calls 4

win10_monitor_infoFunction · 0.85
GetNHAppFunction · 0.70
mswin_hwnd_from_winidFunction · 0.70
mswin_get_fontFunction · 0.70

Tested by

no test coverage detected