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

Function GetlinDlgProc

outdated/sys/wince/mhdlg.c:47–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47LRESULT CALLBACK
48GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
49{
50 struct getlin_data *data;
51 RECT main_rt, text_rt, dlg_rt, edit_rt;
52 SIZE dlg_sz;
53 TCHAR wbuf[BUFSZ];
54 HDC hdc;
55 HWND control;
56 HWND hwndMap;
57
58#if defined(WIN_CE_POCKETPC)
59 SHInputDialog(hWnd, message, wParam);
60#endif
61
62 switch (message) {
63 case WM_INITDIALOG:
64 data = (struct getlin_data *) lParam;
65 SetWindowText(hWnd, NH_A2W(data->question, wbuf, sizeof(wbuf)));
66 SetWindowLong(hWnd, GWL_USERDATA, lParam);
67
68 /* get title text width */
69 SetRect(&text_rt, 0, 0, 100, 50);
70 hdc = GetWindowDC(hWnd);
71 DrawText(hdc, wbuf, _tcslen(wbuf), &text_rt,
72 DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX | DT_LEFT
73 | DT_VCENTER);
74 ReleaseDC(hWnd, hdc);
75
76 /* center dialog in the main window */
77 GetWindowRect(hWnd, &dlg_rt);
78 hwndMap = mswin_hwnd_from_winid(WIN_MAP);
79 GetWindowRect(IsWindow(hwndMap) ? hwndMap : GetNHApp()->hMainWnd,
80 &main_rt);
81 dlg_sz.cx = max(
82 dlg_rt.right - dlg_rt.left,
83 min(text_rt.right - text_rt.left + GetSystemMetrics(SM_CXICON),
84 main_rt.right - main_rt.left));
85 dlg_sz.cy =
86 min(dlg_rt.bottom - dlg_rt.top, main_rt.bottom - main_rt.top);
87 dlg_rt.left = (main_rt.left + main_rt.right - dlg_sz.cx) / 2;
88 dlg_rt.right = dlg_rt.left + dlg_sz.cx;
89 dlg_rt.top = (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2;
90 dlg_rt.bottom = dlg_rt.top + dlg_sz.cy;
91 MoveWindow(hWnd, (main_rt.left + main_rt.right - dlg_sz.cx) / 2,
92 (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2, dlg_sz.cx,
93 dlg_sz.cy, TRUE);
94
95 /* change layout of controls */
96 GetClientRect(hWnd, &dlg_rt);
97
98 control = GetDlgItem(hWnd, IDC_GETLIN_EDIT);
99 GetWindowRect(control, &edit_rt);
100 MoveWindow(control, 0, 0, dlg_rt.right - dlg_rt.left,
101 edit_rt.bottom - edit_rt.top, TRUE);
102
103 control = GetDlgItem(hWnd, IDOK);
104 GetWindowRect(control, &text_rt);

Callers

nothing calls this directly

Calls 3

NHSPhoneDialogSetupFunction · 0.85
mswin_hwnd_from_winidFunction · 0.70
GetNHAppFunction · 0.70

Tested by

no test coverage detected