MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / InputBoxProc

Function InputBoxProc

source/script2.cpp:5089–5325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5087
5088
5089INT_PTR CALLBACK InputBoxProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
5090// MSDN:
5091// Typically, the dialog box procedure should return TRUE if it processed the message,
5092// and FALSE if it did not. If the dialog box procedure returns FALSE, the dialog
5093// manager performs the default dialog operation in response to the message.
5094{
5095 // See GuiWindowProc() for details about this first part:
5096 LRESULT msg_reply;
5097 if (g_MsgMonitor.Count() // Count is checked here to avoid function-call overhead.
5098 && (!g->CalledByIsDialogMessageOrDispatch || g->CalledByIsDialogMessageOrDispatchMsg != uMsg) // v1.0.44.11: If called by IsDialog or Dispatch but they changed the message number, check if the script is monitoring that new number.
5099 && MsgMonitor(hWndDlg, uMsg, wParam, lParam, NULL, msg_reply))
5100 return (BOOL)msg_reply; // MsgMonitor has returned "true", indicating that this message should be omitted from further processing.
5101 g->CalledByIsDialogMessageOrDispatch = false; // v1.0.40.01.
5102
5103 switch(uMsg)
5104 {
5105 case WM_INITDIALOG:
5106 {
5107 SetWindowLongPtr(hWndDlg, DWLP_USER, lParam); // Store it for later use.
5108 auto &CURR_INPUTBOX = *(InputBoxType *)lParam;
5109 CURR_INPUTBOX.hwnd = hWndDlg;
5110
5111 if (CURR_INPUTBOX.password_char)
5112 SendDlgItemMessage(hWndDlg, IDC_INPUTEDIT, EM_SETPASSWORDCHAR, CURR_INPUTBOX.password_char, 0);
5113
5114 SetWindowText(hWndDlg, CURR_INPUTBOX.title);
5115 SetDlgItemText(hWndDlg, IDC_INPUTPROMPT, CURR_INPUTBOX.text);
5116
5117 // Use the system's current language for the button names:
5118 typedef LPCWSTR(WINAPI*pfnUser)(int);
5119 HMODULE hMod = GetModuleHandle(_T("user32.dll"));
5120 pfnUser mbString = (pfnUser)GetProcAddress(hMod, "MB_GetString");
5121 if (mbString)
5122 {
5123 SetDlgItemTextW(hWndDlg, IDOK, mbString(0));
5124 SetDlgItemTextW(hWndDlg, IDCANCEL, mbString(1));
5125 }
5126
5127 // Don't do this check; instead allow the MoveWindow() to occur unconditionally so that
5128 // the new button positions and such will override those set in the dialog's resource
5129 // properties:
5130 //if (CURR_INPUTBOX.width != INPUTBOX_DEFAULT || CURR_INPUTBOX.height != INPUTBOX_DEFAULT
5131 // || CURR_INPUTBOX.xpos != INPUTBOX_DEFAULT || CURR_INPUTBOX.ypos != INPUTBOX_DEFAULT)
5132 RECT rect;
5133 GetClientRect(hWndDlg, &rect);
5134 if (CURR_INPUTBOX.width != INPUTBOX_DEFAULT) rect.right = CURR_INPUTBOX.width;
5135 if (CURR_INPUTBOX.height != INPUTBOX_DEFAULT) rect.bottom = CURR_INPUTBOX.height;
5136 AdjustWindowRect(&rect, GetWindowLong(hWndDlg, GWL_STYLE), FALSE);
5137 int new_width = rect.right - rect.left;
5138 int new_height = rect.bottom - rect.top;
5139
5140 // If a non-default size was specified, the box will need to be recentered; thus, we can't rely on
5141 // the dialog's DS_CENTER style in its template. The exception is when an explicit xpos or ypos is
5142 // specified, in which case centering is disabled for that dimension.
5143 int new_xpos, new_ypos;
5144 if (CURR_INPUTBOX.xpos != INPUTBOX_DEFAULT && CURR_INPUTBOX.ypos != INPUTBOX_DEFAULT)
5145 {
5146 new_xpos = CURR_INPUTBOX.xpos;

Callers

nothing calls this directly

Calls 6

MsgMonitorFunction · 0.85
CenterWindowFunction · 0.85
SetForegroundWindowExFunction · 0.85
swapFunction · 0.85
UpdateResultMethod · 0.80
CountMethod · 0.45

Tested by

no test coverage detected