MCPcopy Create free account
hub / github.com/ChiyukiGana/Quickinput / _TextEditBoxProc

Function _TextEditBoxProc

source/src/tools/texteditbox.h:19–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17};
18
19static LRESULT CALLBACK _TextEditBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
20{
21 constexpr int edit_id = 100;
22 constexpr int button_id = 200;
23 constexpr int margin = 10;
24 constexpr int edit_height = 32;
25 constexpr int button_width = 75;
26 constexpr int button_height = 23;
27
28 _TextEditBoxParams* pParams = nullptr;
29 if (msg == WM_CREATE)
30 {
31 LPCREATESTRUCT pCreateStruct = (LPCREATESTRUCT)lParam;
32 _TextEditBoxParams* lpParams = (_TextEditBoxParams*)pCreateStruct->lpCreateParams;
33 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)lpParams);
34 pParams = lpParams;
35 }
36 else
37 {
38 pParams = (_TextEditBoxParams*)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
39 }
40
41 const bool& mult = pParams->mult;
42 HWND& hw_edit = pParams->hw_edit;
43 HWND& hw_btn = pParams->hw_btn;
44
45 switch (msg)
46 {
47 case WM_CREATE:
48 {
49 hw_edit = CreateWindowExW(NULL, L"EDIT", L"", mult ? (WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL) : (WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL), 1, 1, 1, 1, hwnd, (HMENU)edit_id, pParams->instance, NULL);
50 hw_btn = CreateWindowExW(NULL, L"BUTTON", L"确认", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 1, 1, 1, 1, hwnd, (HMENU)button_id, pParams->instance, NULL);
51 pParams->font = CreateFontW(18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, L"Microsoft YaHei");
52 SendMessageW(hw_edit, WM_SETFONT, (WPARAM)pParams->font, TRUE);
53 SendMessageW(hw_btn, WM_SETFONT, (WPARAM)pParams->font, TRUE);
54 SetWindowPos(hwnd, NULL, 0, 0, mult ? TEXTEDITBOX_MULT_WIDTH : TEXTEDITBOX_SING_WIDTH, mult ? TEXTEDITBOX_MULT_HEIGHT : TEXTEDITBOX_SING_HEIGHT, SWP_NOMOVE | SWP_NOZORDER);
55 break;
56 }
57 case WM_GETMINMAXINFO:
58 {
59 if (pParams)
60 {
61 MINMAXINFO* mmi = (MINMAXINFO*)lParam;
62 mmi->ptMinTrackSize.x = 300;
63 mmi->ptMinTrackSize.y = mult ? 200 : 150;
64 if (!mult) mmi->ptMaxTrackSize.y = 150;
65 }
66 break;
67 }
68 case WM_SIZE:
69 {
70 RECT client_rect;
71 GetClientRect(hwnd, &client_rect);
72 SetWindowPos(hw_edit, NULL, margin, margin, client_rect.right - margin * 2, mult ? (client_rect.bottom - button_height - margin * 3) : edit_height, SWP_NOZORDER);
73 SetWindowPos(hw_btn, NULL, client_rect.right - button_width - margin, client_rect.bottom - button_height - margin, button_width, button_height, SWP_NOZORDER);
74 break;
75 }
76 case WM_SETTEXT:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected