void CWindowFind::SetTestChildEditText(HWND hwnd,int iIndex) { HWND hwndChind = NULL; CString strTemp = ""; TCHAR szClassName[256]={0}; int i = 1; hwndChind = GetWindow(hwnd,GW_CHILD); CWnd *pWnd = CWnd::FromHandle(hwndChind); while (pWnd) { memset(szClassName,0,sizeof(szClassName)); hwndChind = pWnd->GetSafeHwnd(); GetClassName(hwndChind,(LPTSTR)&szClassName,256); if ((CString)szClassName == "Edit") { if (iIndex == 0) { strTemp.Format("test%d",i); } else { if (i == iIndex) { strTemp.Format("te11111111st%d",i); } } CopyStringToClipboard(NULL,strTemp); CEdit *pCob = (CEdit *)CWnd::FromHandle(hwndChind); if (pCob) { //先删除原有号码后向号码输入框发送复制消息 if (iIndex == 0) { pCob->SetSel(0, -1); pCob->Clear(); ::PostMessage(hwndChind,WM_PASTE,0,0); } else { if (i == iIndex) { pCob->SetSel(0, -1); pCob->Clear(); ::PostMessage(hwndChind,WM_PASTE,0,0); } } } } pWnd = pWnd->GetNextWindow(GW_HWNDNEXT); i++; } }
BOOL CVenusDlg::PreTranslateMessage(MSG* pMsg) { // TODO: 在此添加专用代码和/或调用基类 if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE) { // 隐藏窗体 SetShowStatus(false); CString txt; GetDlgItemText(IDC_EDIT1, txt); if (pMsg->wParam == VK_RETURN) { // ctrl + enter 百度搜索输入的关键字 if (GetAsyncKeyState(VK_CONTROL)<0) { CString url; url.Format("www.baidu.com/s?wd=%s", txt); ShellExecute(NULL, _T("open"), _T(url), NULL, NULL, SW_SHOWNORMAL); } // shift + enter 查询DICT字典 else if (GetAsyncKeyState(VK_SHIFT)<0) { CString url; url.Format("dict.cn/%s", txt); ShellExecute(NULL, _T("open"), _T(url), NULL, NULL, SW_SHOWNORMAL); } // 仅回车时执行当前匹配到快捷程序 else { if (!lastKey.IsEmpty()) { CString exePath = myIndex->GetLocalPath(lastKey); if (lastKey == ";lnk") { system(exePath); } else { RunLnkFile((LPSTR)(LPCSTR)exePath); } } } } // 清空输入内容 CEdit *myInput = (CEdit *)GetDlgItem(IDC_EDIT1); myInput->SetSel(0, -1); myInput->Clear(); return FALSE; } return CDialogEx::PreTranslateMessage(pMsg); }
// @pymethod int|PyCEdit|Clear|Clears all text in an edit control. static PyObject * PyCEdit_clear(PyObject *self, PyObject *args) { CHECK_NO_ARGS(args); CEdit *pEdit = GetEditCtrl(self); if (!pEdit ) return NULL; GUI_BGN_SAVE; pEdit->Clear(); // @pyseemfc CEdit|Clear GUI_END_SAVE; RETURN_NONE; }
void CWindowFind::SetEditText(HWND hwnd,CString strValue) { TCHAR szClassName[256]={0}; GetClassName(hwnd,(LPTSTR)&szClassName,256); if ((CString)szClassName == "Edit") { CopyStringToClipboard(NULL,strValue); CEdit *pCob = (CEdit *)CWnd::FromHandle(hwnd); if (pCob) { pCob->SetSel(0, -1); pCob->Clear(); ::PostMessage(hwnd,WM_PASTE,0,0); } } }
BOOL CXTComboBoxEx::PreTranslateMessage(MSG* pMsg) { CEdit* pEditCtrl = GetEditCtrl(); if (pEditCtrl && ::IsWindow(pEditCtrl->m_hWnd)) { if (pMsg->message == WM_KEYDOWN) { if (::GetKeyState(VK_CONTROL) < 0) { switch (pMsg->wParam) { case 'a': case 'A': pEditCtrl->SetSel(0, -1); return TRUE; case 'c': case 'C': pEditCtrl->Copy(); return TRUE; case 'x': case 'X': pEditCtrl->Cut(); return TRUE; case 'v': case 'V': pEditCtrl->Paste(); return TRUE; } } else { if (::GetKeyState(VK_CLEAR)) { pEditCtrl->Clear(); return TRUE; } } } } return CComboBox::PreTranslateMessage(pMsg); }