BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { #ifndef WINCE switch (pMsg->message) { case WM_XBUTTONUP: { // IntelliMouseのサイドキーボタン switch (GET_XBUTTON_WPARAM(pMsg->wParam)) { case XBUTTON1: // first X button OnBackButton(); return TRUE; case XBUTTON2: // second X button OnForwardButton(); return TRUE; } } break; } #endif #ifdef WINCE // WM Standard 端末でESC/BACKキーで前のアプリに戻ってしまうのを防ぐ if (pMsg->message == WM_HOTKEY) { if (HIWORD(pMsg->lParam )== VK_TBACK) { SHSendBackToFocusWindow(WM_HOTKEY, pMsg->wParam, pMsg->lParam); return TRUE; } } #endif return CFrameWnd::PreTranslateMessage(pMsg); }
LRESULT CGetURLDialog::OnHotKey(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { if (VK_TBACK == HIWORD(lParam)) // Smartphone-only { SHSendBackToFocusWindow(uMsg, wParam, lParam); } return 0; }
LRESULT CGetURLDialog::OnHotKey(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { #if defined(_WIN32_WCE) if (VK_TBACK == HIWORD(lParam)) // Smartphone-only { SHSendBackToFocusWindow(uMsg, wParam, lParam); } #endif //_WIN32_WCE return 0; }
bool wxTopLevelWindowMSW::MSWShouldPreProcessMessage(WXMSG* pMsg) { MSG *msg = (MSG *)pMsg; // Process back key to be like backspace. if (msg->message == WM_HOTKEY) { if (HIWORD(msg->lParam) == VK_TBACK) SHSendBackToFocusWindow(msg->message, msg->wParam, msg->lParam); } return wxTopLevelWindowBase::MSWShouldPreProcessMessage(pMsg); }
bool MenuDialog::handleBackKey(UINT msg, WPARAM wParam, LPARAM lParam) { bool keyUp = (0 != (UINT(LOWORD(lParam)) & MOD_KEYUP)); HWND wnd = GetFocus(); if (NULL == wnd) { if (keyUp) { PostMessage(handle(), WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0); return true; } else return true; } char_t name[8]; int res = GetClassName(wnd, name, 5); if (0 == res || !(equalsIgnoreCase(name, WINDOW_CLASS_EDITBOX) || equalsIgnoreCase(name, _T("CAPEDIT")))) { if (keyUp) { //SHNavigateBack(); PostMessage(handle(), WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0); return true; } else return true; } #ifdef SHELL_TPCSHELL SHSendBackToFocusWindow(msg, wParam, lParam); return true; #else return false; #endif }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CCUI dialog INT_PTR CALLBACK CCUI(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { TCHAR tzStr[MAX_STR]; STATIC CeleMenuBar s_mb; _HandleActivate(hWnd, uMsg, wParam, lParam); switch (uMsg) { case WM_INITDIALOG: g_hWnd = hWnd; s_mb = CeleCtrl::InitDlgBar(hWnd, IDR_MainMenu, TRUE); SetDlgItemText(hWnd, IDC_Path, (PCTSTR) lParam); return TRUE; case WM_SIZE: CeleCtrl::ReSize(hWnd, IDC_Log, lParam); CeleCtrl::ReWidth(hWnd, IDC_Tip, LOWORD(lParam)); CeleCtrl::ReWidth(hWnd, IDC_Path, CeleCtrl::ReLeft(hWnd, IDC_Browse, LOWORD(lParam))); break; case WM_HOTKEY: if (HIWORD(lParam) == VK_TBACK) { HWND hCtrl = GetDlgItem(hWnd, IDC_Path); if (hCtrl != GetFocus()) { SetFocus(hCtrl); SetWindowText(hCtrl, NULL); } else { SHSendBackToFocusWindow(uMsg, wParam, lParam); } } break; case WM_INITMENUPOPUP: if (LOWORD(lParam) == IDCANCEL) { CeleMenu m; HKEY hKey; m = (HMENU) wParam; if (RegOpenKeyEx(HKEY_CLASSES_ROOT, STR_AppName, 0, KEY_ALL_ACCESS, &hKey) == S_OK) { RegCloseKey(hKey); m.Check(IDM_Assoc, TRUE); } else { m.Check(IDM_Assoc, FALSE); } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_Browse: CeleCtrl::BrowseFile(hWnd, _MakeIntRes(IDC_Path), IDS_Filter); break; case IDC_Path: if (HIWORD(wParam) == EN_CHANGE) { s_mb.EnableButton(IDOK, GetWindowTextLength(GetDlgItem(hWnd, IDC_Path))); } else if (HIWORD(wParam) == EN_SETFOCUS) { DWORD dwConversion, dwSentence; ImmGetConversionStatus(NULL, &dwConversion, &dwSentence); ImmSetConversionStatus(NULL, dwConversion & ~IME_CMODE_NATIVE, NULL); } break; case IDM_Clear: SetDlgItemText(g_hWnd, IDC_Log, NULL); break; case IDM_Assoc: if (TRUE) { CeleMenu m; m = s_mb.GetMenu(IDCANCEL); if (m.IsChecked(IDM_Assoc)) { ASOC(TEXT("!")); ASOC(TEXT("!.reg")); ASOC(TEXT("!.ccs")); ASOC(TEXT("!.provxml")); CeleCtrl::ShowCmdMsg(IDM_Assoc, hWnd, _MakeIntRes(IDS_UnAssoc)); } else { ASOC(TEXT(".ccs")); ASOC(TEXT(".reg")); ASOC(TEXT(".provxml")); CeleCtrl::ShowCmdMsg(IDM_Assoc, hWnd, _MakeIntRes(IDS_Assoc)); } } break; case IDM_Help: return CeleCtrl::DlgBox(hWnd, HELP); case IDM_About: CeleAbout::Show(hWnd); break; case IDOK: if (HIWORD(wParam) == 0) { GetDlgItemText(hWnd, IDC_Path, tzStr, MAX_PATH); Process(tzStr, g_ptzCurFile); break; } case IDCANCEL: case IDM_Exit: EndDialog(hWnd, S_OK); break; } break; } return FALSE; }
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; }