MCPcopy Index your code
hub / github.com/NetHack/NetHack / NHMenuTextWndProc

Function NHMenuTextWndProc

win/win32/mhmenu.c:1725–1816  ·  view source on GitHub ↗

-----------------------------------------------------------------------------*/ Text control window proc - implements scrolling without a cursor */

Source from the content-addressed store, hash-verified

1723/*-----------------------------------------------------------------------------*/
1724/* Text control window proc - implements scrolling without a cursor */
1725LRESULT CALLBACK
1726NHMenuTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
1727{
1728 HWND hWndParent = GetParent(hWnd);
1729 HDC hDC;
1730 RECT rc;
1731
1732 switch (message) {
1733 case WM_ERASEBKGND:
1734 hDC = (HDC) wParam;
1735 GetClientRect(hWnd, &rc);
1736 FillRect(hDC, &rc, text_bg_brush
1737 ? text_bg_brush
1738 : SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
1739 return 0;
1740
1741 case WM_KEYDOWN:
1742 switch (wParam) {
1743 /* close on space in Windows mode
1744 page down on space in NetHack mode */
1745 case VK_SPACE: {
1746 SCROLLINFO si;
1747
1748 si.cbSize = sizeof(SCROLLINFO);
1749 si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
1750 GetScrollInfo(hWnd, SB_VERT, &si);
1751 /* If nethackmode and not at the end of the list */
1752 if (GetNHApp()->regNetHackMode
1753 && (si.nPos + (int) si.nPage) <= (si.nMax - si.nMin))
1754 SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0);
1755 else
1756 PostMessage(hWndParent, WM_COMMAND, MAKELONG(IDOK, 0), 0);
1757 return 0;
1758 }
1759 case VK_NEXT:
1760 SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0);
1761 return 0;
1762 case VK_PRIOR:
1763 SendMessage(hWnd, EM_SCROLL, SB_PAGEUP, 0);
1764 return 0;
1765 case VK_UP:
1766 SendMessage(hWnd, EM_SCROLL, SB_LINEUP, 0);
1767 return 0;
1768 case VK_DOWN:
1769 SendMessage(hWnd, EM_SCROLL, SB_LINEDOWN, 0);
1770 return 0;
1771 }
1772 break;
1773
1774 case WM_CHAR:
1775 switch(wParam) {
1776 case MENU_FIRST_PAGE:
1777 SendMessage(hWnd, EM_SCROLL, SB_TOP, 0);
1778 return 0;
1779 case MENU_LAST_PAGE:
1780 SendMessage(hWnd, EM_SCROLL, SB_BOTTOM, 0);
1781 return 0;
1782 case MENU_NEXT_PAGE:

Callers

nothing calls this directly

Calls 2

randomkeyFunction · 0.85
GetNHAppFunction · 0.70

Tested by

no test coverage detected