BOOL CDlgInput::PreTranslateMessage(MSG* pMsg) { #ifndef DESKTOP if ( pMsg->message == WM_KEYDOWN ) PressedKey = pMsg->wParam; if ( pMsg->message == WM_KEYUP && pMsg->wParam == PressedKey && pMsg->wParam == 13 ) { if ( !Multiline || GetDlgItem( IDC_EDIT ) != CWnd::GetFocus() ) { CDialog::PreTranslateMessage(pMsg); OnOK(); } return 1; } SHInputDialog (m_hWnd, pMsg->message, pMsg->wParam); #endif return CDialog::PreTranslateMessage(pMsg); }
LRESULT CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { struct getlin_data *data; RECT main_rt, text_rt, dlg_rt, edit_rt; SIZE dlg_sz; TCHAR wbuf[BUFSZ]; HDC hdc; HWND control; HWND hwndMap; #if defined(WIN_CE_POCKETPC) SHInputDialog(hWnd, message, wParam); #endif switch (message) { case WM_INITDIALOG: data = (struct getlin_data *) lParam; SetWindowText(hWnd, NH_A2W(data->question, wbuf, sizeof(wbuf))); SetWindowLong(hWnd, GWL_USERDATA, lParam); /* get title text width */ SetRect(&text_rt, 0, 0, 100, 50); hdc = GetWindowDC(hWnd); DrawText(hdc, wbuf, _tcslen(wbuf), &text_rt, DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX | DT_LEFT | DT_VCENTER); ReleaseDC(hWnd, hdc); /* center dialog in the main window */ GetWindowRect(hWnd, &dlg_rt); hwndMap = mswin_hwnd_from_winid(WIN_MAP); GetWindowRect(IsWindow(hwndMap) ? hwndMap : GetNHApp()->hMainWnd, &main_rt); dlg_sz.cx = max( dlg_rt.right - dlg_rt.left, min(text_rt.right - text_rt.left + GetSystemMetrics(SM_CXICON), main_rt.right - main_rt.left)); dlg_sz.cy = min(dlg_rt.bottom - dlg_rt.top, main_rt.bottom - main_rt.top); dlg_rt.left = (main_rt.left + main_rt.right - dlg_sz.cx) / 2; dlg_rt.right = dlg_rt.left + dlg_sz.cx; dlg_rt.top = (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2; dlg_rt.bottom = dlg_rt.top + dlg_sz.cy; MoveWindow(hWnd, (main_rt.left + main_rt.right - dlg_sz.cx) / 2, (main_rt.top + main_rt.bottom - dlg_sz.cy) / 2, dlg_sz.cx, dlg_sz.cy, TRUE); /* change layout of controls */ GetClientRect(hWnd, &dlg_rt); control = GetDlgItem(hWnd, IDC_GETLIN_EDIT); GetWindowRect(control, &edit_rt); MoveWindow(control, 0, 0, dlg_rt.right - dlg_rt.left, edit_rt.bottom - edit_rt.top, TRUE); control = GetDlgItem(hWnd, IDOK); GetWindowRect(control, &text_rt); MoveWindow(control, 0, edit_rt.bottom - edit_rt.top, (dlg_rt.right - dlg_rt.left) / 2, text_rt.bottom - text_rt.top, TRUE); control = GetDlgItem(hWnd, IDCANCEL); GetWindowRect(control, &text_rt); MoveWindow(control, (dlg_rt.right - dlg_rt.left) / 2, edit_rt.bottom - edit_rt.top, (dlg_rt.right - dlg_rt.left) / 2, text_rt.bottom - text_rt.top, TRUE); #if defined(WIN_CE_SMARTPHONE) NHSPhoneDialogSetup(hWnd, IDC_SPHONE_DIALOGBAR, TRUE, FALSE); #endif /* set focus to the edit control */ SetFocus(GetDlgItem(hWnd, IDC_GETLIN_EDIT)); /* tell windows that we've set the focus */ return FALSE; break; case WM_COMMAND: { TCHAR wbuf[BUFSZ]; switch (LOWORD(wParam)) { /* OK button was pressed */ case IDOK: data = (struct getlin_data *) GetWindowLong(hWnd, GWL_USERDATA); SendDlgItemMessage(hWnd, IDC_GETLIN_EDIT, WM_GETTEXT, (WPARAM) sizeof(wbuf), (LPARAM) wbuf); NH_W2A(wbuf, data->result, data->result_size); /* Fall through. */ /* cancel button was pressed */ case IDCANCEL: EndDialog(hWnd, wParam); return TRUE; } } break; #if defined(WIN_CE_SMARTPHONE) case WM_HOTKEY: if (VK_TBACK == HIWORD(lParam)) { SHSendBackToFocusWindow(message, wParam, lParam); } break; #endif } /* end switch (message) */ return FALSE; }