/* Copyright (C) 2001 by Alex Kompel */
/* NetHack may be freely redistributed. See license for details. */
+#include "win10.h"
#include "winMS.h"
#include "resource.h"
#include "mhrip.h"
HANDLE rip_bmp;
TCHAR *window_text;
TCHAR *rip_text;
+ int x;
+ int y;
+ int width;
+ int height;
+ int graveX;
+ int graveY;
+ int graveHeight;
+ int graveWidth;
} NHRIPWindow, *PNHRIPWindow;
INT_PTR CALLBACK NHRIPWndProc(HWND, UINT, WPARAM, LPARAM);
RECT riprt;
RECT clientrect;
RECT textrect;
- HDC hdc;
HFONT OldFont;
+ MonitorInfo monitorInfo;
+
+ win10_monitor_info(hWnd, &monitorInfo);
data = (PNHRIPWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ data->x = (int)(RIP_OFFSET_X * monitorInfo.scale);
+ data->y = (int)(RIP_OFFSET_Y * monitorInfo.scale);
+ data->width = (int)(RIP_WIDTH * monitorInfo.scale);
+ data->height = (int)(RIP_HEIGHT * monitorInfo.scale);
+ data->graveX = (int)(RIP_GRAVE_X * monitorInfo.scale);
+ data->graveY = (int)(RIP_GRAVE_Y * monitorInfo.scale);
+ data->graveWidth = (int)(RIP_GRAVE_WIDTH * monitorInfo.scale);
+ data->graveHeight = (int)(RIP_GRAVE_HEIGHT * monitorInfo.scale);
+
GetNHApp()->hPopupWnd = hWnd;
mapWnd = mswin_hwnd_from_winid(WIN_MAP);
if (!IsWindow(mapWnd))
GetWindowRect(hWnd, &riprt);
GetClientRect(hWnd, &clientrect);
textrect = clientrect;
- textrect.top += RIP_OFFSET_Y;
- textrect.left += RIP_OFFSET_X;
- textrect.right -= RIP_OFFSET_X;
+ textrect.top += data->y;
+ textrect.left += data->x;
+ textrect.right -= data->x;
if (data->window_text) {
- hdc = GetDC(hWnd);
- OldFont = SelectObject(hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
+ HDC hdc = GetDC(hWnd);
+ OldFont = SelectObject(hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE)->hFont);
DrawText(hdc, data->window_text, strlen(data->window_text), &textrect,
DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
SelectObject(hdc, OldFont);
ReleaseDC(hWnd, hdc);
}
- if (textrect.right - textrect.left > RIP_WIDTH)
- clientrect.right = textrect.right + RIP_OFFSET_X - clientrect.right;
+ if (textrect.right - textrect.left > data->width)
+ clientrect.right = textrect.right + data->y - clientrect.right;
else
clientrect.right =
- textrect.left + 2 * RIP_OFFSET_X + RIP_WIDTH - clientrect.right;
+ textrect.left + 2 * data->x + data->width - clientrect.right;
clientrect.bottom =
- textrect.bottom + RIP_HEIGHT + RIP_OFFSET_Y - clientrect.bottom;
+ textrect.bottom + data->height + data->y - clientrect.bottom;
GetWindowRect(GetDlgItem(hWnd, IDOK), &textrect);
textrect.right -= textrect.left;
textrect.bottom -= textrect.top;
- clientrect.bottom += textrect.bottom + RIP_OFFSET_Y;
+ clientrect.bottom += textrect.bottom + data->y;
riprt.right -= riprt.left;
riprt.bottom -= riprt.top;
riprt.right += clientrect.right;
GetClientRect(hWnd, &clientrect);
MoveWindow(GetDlgItem(hWnd, IDOK),
(clientrect.right - clientrect.left - textrect.right) / 2,
- clientrect.bottom - textrect.bottom - RIP_OFFSET_Y,
+ clientrect.bottom - textrect.bottom - data->y,
textrect.right, textrect.bottom, TRUE);
ShowWindow(hWnd, SW_SHOW);
INT_PTR CALLBACK
NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- HDC hdc;
- PNHRIPWindow data;
-
- data = (PNHRIPWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ PNHRIPWindow data = (PNHRIPWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
switch (message) {
- case WM_INITDIALOG:
+ case WM_INITDIALOG: {
+ HDC hdc = GetDC(hWnd);
+ cached_font * font = mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE);
+
/* set text control font */
- hdc = GetDC(hWnd);
- SendMessage(hWnd, WM_SETFONT,
- (WPARAM) mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE),
- 0);
+ SendMessage(hWnd, WM_SETFONT, (WPARAM)font->hFont, 0);
ReleaseDC(hWnd, hdc);
SetFocus(GetDlgItem(hWnd, IDOK));
- return FALSE;
+ } break;
case WM_MSNH_COMMAND:
onMSNHCommand(hWnd, wParam, lParam);
HANDLE OldBitmap;
PAINTSTRUCT ps;
HFONT OldFont;
+ HDC hdc = BeginPaint(hWnd, &ps);
+ cached_font * font = mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE);
- hdc = BeginPaint(hWnd, &ps);
- OldFont = SelectObject(hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
+ OldFont = SelectObject(hdc, font->hFont);
hdcBitmap = CreateCompatibleDC(hdc);
SetBkMode(hdc, TRANSPARENT);
GetClientRect(hWnd, &clientrect);
textrect = clientrect;
- textrect.top += RIP_OFFSET_Y;
- textrect.left += RIP_OFFSET_X;
- textrect.right -= RIP_OFFSET_X;
+ textrect.top += data->y;
+ textrect.left += data->x;
+ textrect.right -= data->x;
if (data->window_text) {
DrawText(hdc, data->window_text, strlen(data->window_text),
&textrect, DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
}
OldBitmap = SelectObject(hdcBitmap, GetNHApp()->bmpRip);
SetBkMode(hdc, OPAQUE);
- bitmap_offset = (textrect.right - textrect.left - RIP_WIDTH) / 2;
- BitBlt(hdc, textrect.left + bitmap_offset, textrect.bottom, RIP_WIDTH,
- RIP_HEIGHT, hdcBitmap, 0, 0, SRCCOPY);
+ bitmap_offset = (textrect.right - textrect.left - data->width) / 2;
+ StretchBlt(hdc, textrect.left + bitmap_offset, textrect.bottom,
+ data->width, data->height,
+ hdcBitmap, 0, 0, RIP_WIDTH, RIP_HEIGHT, SRCCOPY);
SetBkMode(hdc, TRANSPARENT);
if (data->rip_text) {
- textrect.left += RIP_GRAVE_X + bitmap_offset;
- textrect.top = textrect.bottom + RIP_GRAVE_Y;
- textrect.right = textrect.left + RIP_GRAVE_WIDTH;
- textrect.bottom = textrect.top + RIP_GRAVE_HEIGHT;
+ textrect.left += data->graveX + bitmap_offset;
+ textrect.top = textrect.bottom + data->graveY;
+ textrect.right = textrect.left + data->graveWidth;
+ textrect.bottom = textrect.top + data->graveHeight;
DrawText(hdc, data->rip_text, strlen(data->rip_text), &textrect,
DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK);
}
data->window_text = NULL;
break;
}
+
+ case MSNH_MSG_RANDOM_INPUT:
+ nhassert(0); // unexpected
+ break;
+
}
}