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

Function NHTextWndProc

win/win32/mhtext.c:76–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76INT_PTR CALLBACK
77NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
78{
79 PNHTextWindow data = (PNHTextWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA);
80
81 switch (message) {
82 case WM_INITDIALOG: {
83 data = (PNHTextWindow)malloc(sizeof(NHTextWindow));
84 if (!data)
85 panic("out of memory");
86
87 ZeroMemory(data, sizeof(NHTextWindow));
88 SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)data);
89 windowdata[NHW_TEXT].address = (genericptr_t) data; // for cleanup at the end
90
91 HWND control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
92 HDC hdc = GetDC(control);
93 cached_font * font = mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE);
94 /* set text control font */
95
96 if (!control) {
97 panic("cannot get text view window");
98 }
99
100 SendMessage(control, WM_SETFONT, (WPARAM) font->hFont, 0);
101 ReleaseDC(control, hdc);
102
103 /* subclass edit control */
104 editControlWndProc =
105 (WNDPROC)GetWindowLongPtr(control, GWLP_WNDPROC);
106 SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR)NHEditHookWndProc);
107
108 SetFocus(control);
109
110 /* Even though the dialog has no caption, you can still set the title
111 which shows on Alt-Tab */
112 TCHAR title[MAX_LOADSTRING];
113 LoadString(GetNHApp()->hApp, IDS_APP_TITLE, title, MAX_LOADSTRING);
114 SetWindowText(hWnd, title);
115 } break;
116
117 case WM_MSNH_COMMAND:
118 onMSNHCommand(hWnd, wParam, lParam);
119 break;
120
121 case WM_SIZE: {
122 RECT rt;
123
124 GetWindowRect(hWnd, &rt);
125 ScreenToClient(GetNHApp()->hMainWnd, (LPPOINT) &rt);
126 ScreenToClient(GetNHApp()->hMainWnd, ((LPPOINT) &rt) + 1);
127 mswin_update_window_placement(NHW_TEXT, &rt);
128
129 LayoutText(hWnd);
130 }
131 return FALSE;
132
133 case WM_MOVE: {

Callers

nothing calls this directly

Calls 8

mswin_get_fontFunction · 0.70
GetNHAppFunction · 0.70
onMSNHCommandFunction · 0.70
LayoutTextFunction · 0.70
mswin_window_mark_deadFunction · 0.70
mswin_winid_from_handleFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected