void CCgxDlg::_append2script( TCHAR* buff ) { CEdit* edit = (CEdit *)GetDlgItem(IDC_SCRIPT); // get the initial text length int nLength = edit->GetWindowTextLength(); // put the selection at the end of text edit->SetSel(nLength, nLength); // replace the selection edit->ReplaceSel(buff); nLength = edit->GetWindowTextLength(); edit->SetSel(nLength, nLength); edit->ReplaceSel(TEXT("\n")); }
void CSystemTestDlg::_out(PTSTR pszText) { CEdit* edit = (CEdit*)GetDlgItem(IDC_OUT); // get the initial text length int nLength = edit->GetWindowTextLength(); // put the selection at the end of text edit->SetSel(nLength, nLength); // replace the selection edit->ReplaceSel(pszText); nLength = edit->GetWindowTextLength(); edit->SetSel(nLength, nLength); edit->ReplaceSel(TEXT("\n")); }
LRESULT CSaveArgs::OnNameChanged(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CEdit name = GetDlgItem(IDC_FILENAME); CButton ok = GetDlgItem(IDOK); ok.EnableWindow(name.GetWindowTextLength() > 0); return 0; }
/** * @brief Add new result to end of result edit box. * @param [in] result Result text to add. */ void CTestFilterDlg::AppendResult(CString result) { CEdit * edit = (CEdit *)GetDlgItem(IDC_RESULTS); if (edit->GetWindowTextLength()>0) result = (CString)_T("\r\n") + result; AppendToEditBox(*edit, result); }
void CyuchuandemoDlg::WriteLog(int hd,CString WriteLog) { CEdit *pEdit; pEdit = (CEdit *)GetDlgItem(IDC_EDITLOG); int nLen=0; nLen = pEdit->GetWindowTextLength (); pEdit->SetFocus (); pEdit->SetSel(nLen, nLen); if (hd==DAS_OK) WriteLog=WriteLog+" 数据接收正常"; else if (hd==Comm_Init_Err) WriteLog=WriteLog+" 错误原因:串口初始化错误!"; else if (hd==CommPort_Err) WriteLog=WriteLog+" 错误原因:端口错误!"; else if (hd==CommPort_Err) WriteLog=WriteLog+" 错误原因:端口错误!"; else if (hd==Chksum_Err) WriteLog=WriteLog+" 错误原因:通讯数据效验错误!"; else if (hd==Rev_Data_Err) WriteLog=WriteLog+" 错误原因:接收数据失败!"; else if (hd==TIME_OUT_Err) WriteLog=WriteLog+" 错误原因:通讯超时错误!"; else if (hd==Para_Err) WriteLog=WriteLog+" 错误原因:参数错误!"; else if (hd==Send_Data_Err) WriteLog=WriteLog+" 错误原因:发送数据失败!"; else if (hd==Get_status_Err) WriteLog=WriteLog+" 错误原因:接收状态位错误!"; else if ((hd==No_Data_Return)||(hd==No_BIN_Files)||(hd==Read_Files_ERR)) WriteLog=WriteLog+" 错误原因:没有数据返回!"; else if (hd==CRC_ERR) WriteLog=WriteLog+" 错误原因:CRC效验错误!"; else if (hd==Rev_LEN_Err) WriteLog=WriteLog+" 错误原因:接收长度溢出!"; else if (hd==Password_Err) WriteLog=WriteLog+" 错误原因:授权密码错误!"; else if (hd==Password_Para_Err) WriteLog=WriteLog+" 错误原因:密码格式错误!"; else if (hd==Encrypt_Err) WriteLog=WriteLog+" 错误原因:数据加密错误!"; else if (hd==Wrong_DEV_Err) WriteLog=WriteLog+" 错误原因:设备物理ID号不符!"; else if (hd==No_Record_Err) WriteLog=WriteLog+" 错误原因:没有流水!"; else WriteLog=WriteLog+" "; WriteLog = WriteLog+"\r\n"; pEdit->ReplaceSel (WriteLog); nLen = pEdit->GetLineCount(); //pEdit->LineScroll(nLen, nLen); //pEdit->SendMessage(WM_VSCROLL, MAKEWPARAM(SB_BOTTOM,0),0); if( nLen >= 150 ) { pEdit->SetWindowText(""); } }
void CMy2DGaitRecognitionDlg::gr_write_log(CString &strLogMsg) { //获取当前系统时间 COleDateTime time = COleDateTime::GetCurrentTime(); CString strTime; strTime.Format(_T("%d-%d-%d %d:%d:%d"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond()); CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_LOG); pEdit->SetSel(pEdit->GetWindowTextLength(), -1); pEdit->ReplaceSel(strTime + _T(" ") + strLogMsg + _T("\r\n")); }
void AccountDlg::OnNMClickSyslinkDisplayPasswod(NMHDR *pNMHDR, LRESULT *pResult) { GetDlgItem(IDC_SYSLINK_DISPLAY_PASSWORD)->ShowWindow(SW_HIDE); CEdit* edit = (CEdit*)GetDlgItem(IDC_EDIT_PASSWORD); edit->SetPasswordChar(0); edit->Invalidate(); edit->SetFocus(); int nLength = edit->GetWindowTextLength(); edit->SetSel(nLength,nLength); *pResult = 0; }
static LRESULT CALLBACK ControlProc(HWND control, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_KEYDOWN) { if ((LOWORD(wParam)== 'A' || LOWORD(wParam) == 'a') && GetKeyState(VK_CONTROL) < 0) { CEdit *pEdit = (CEdit*)CWnd::FromHandle(control); pEdit->SetSel(0, pEdit->GetWindowTextLength(), TRUE); return 0; } } return CallWindowProc(OldControlProc, control, message, wParam, lParam); }
static void AppendTextToEditCtrl(CEdit& edit, string text) { util::StringReplace(text, "\n", "\r\n"); // add CR/LF to text CString strLine; strLine.Format(_T("%s\r\n"), text.c_str()); // get the initial text length int nLength = edit.GetWindowTextLength(); // put the selection at the end of text edit.SetSel(nLength, nLength); // replace the selection edit.ReplaceSel(strLine); }
static LRESULT CALLBACK ControlProc(HWND control, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_KEYDOWN) { if (LOWORD(wParam)==VK_ESCAPE) { return 0; // just ignore ESCAPE in edit control } if ((LOWORD(wParam)== 'A' || LOWORD(wParam) == 'a') &&(GetKeyState(VK_CONTROL) < 0)) { CEdit *pEdit = (CEdit*)CWnd::FromHandle(control); pEdit->SetSel(0, pEdit->GetWindowTextLength(),TRUE); return 0; } } return CallWindowProc(OldControlProc, control, message, wParam, lParam); // call edit control's own windowproc }
void CSmartCommunicationDlg::AddString(CString csAppend,bool bFlag) { if( m_check_stop.GetCheck()) return ; if( csAppend.IsEmpty() ) return ; CEdit *pEdit; pEdit = (CEdit *)GetDlgItem(IDC_EDIT1); int nLen=0; nLen = pEdit->GetWindowTextLength (); pEdit->SetFocus (); pEdit->SetSel(nLen, nLen); csAppend = csAppend+"\r\n"; pEdit->ReplaceSel (csAppend); nLen = pEdit->GetLineCount(); if( nLen >= 150 ) { pEdit->SetWindowText(""); } }
/** * @brief Add text to end of edit control. * @param [in] edit Edit contror into which the text is added. * @param [in] text Text to add to edit control. */ void AppendToEditBox(CEdit & edit, LPCTSTR text) { int len = edit.GetWindowTextLength(); edit.SetSel(len, len); edit.ReplaceSel(text); }
//type: //0: text collector //11: filter //12: page //13: img void CTxtDropTarget::SaveText(CString str, int type) { CString strTime; if (pmf->m_bOutputSaveTime) { SYSTEMTIME time; ::GetLocalTime(&time); strTime.Format("[%02d/%02d-%02d:%02d:%02d] ",time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond); } if (type==0) { if (strTime.GetLength()) str = strTime + "\r\n" + str; } else { str = strTime + str; pmf->SetMessageText(str); } // str += "\r\n"; CEdit *edit; CString strfile; // if (type==0) { edit = &(pmf->m_pCollectDlg->m_txt); strfile = theApp.m_strUser+"CollectorText.txt"; if(pmf->m_pCollectDlg) pmf->m_pCollectDlg->OnCollectorTxt(); } else { if (type==11 && !pmf->m_bOutputSaveFilter) return; else if (type==12 && !pmf->m_bOutputSavePage) return; else if (type==13 && !pmf->m_bOutputSaveImg) return; else if (type==14 && !pmf->m_bOutputSaveText) return; else if (type==15 && !pmf->m_bOutputSaveUrlFilter) return; edit = &(pmf->m_pCollectDlg->m_output); strfile = theApp.m_strUser+"CollectorOutput.txt"; if(pmf->m_pCollectDlg) pmf->m_pCollectDlg->OnCollectorOutput(); } // if(pmf->m_pCollectDlg) { int len = edit->GetWindowTextLength( ); if (len>=MAX_COLLECTOR) { if (type==0) MSGBOX(IDS_MAX_COLLECTOR_TXT); else if (type==1) MSGBOX(IDS_MAX_COLLECTOR_OUTPUT); else MSGBOX(IDS_MAX_COLLECTOR_SCRIPT); return; } else { if (pmf->m_bCollectorAddtoBottom) edit->SetSel(len, len); else edit->SetSel(0,0); edit->ReplaceSel(str); } } else { CFile f; if(f.Open(strfile, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite|CFile::shareDenyNone)) { f.SeekToBegin(); f.Write((void*)(LPCSTR)str, str.GetLength()); f.Close(); } } }
void CBibitemView::OnUpdateEditSelectAll(CCmdUI* pCmdUI) { CEdit* edit = GetFocusEdit(); pCmdUI->Enable(edit && edit->GetWindowTextLength() > 0); }
void ExtFrame::ScrollEnd(CEdit& edit) { int length = edit.GetWindowTextLength(); edit.PostMessage(EM_SETSEL, length, length); }
void ExtFrame::AdjustEdit(CSpinButtonCtrl& spin, CEdit& edit, bool two) { int rangeMin; int rangeMax; spin.GetRange32(rangeMin, rangeMax); if(rangeMin <= rangeMax) { int length = edit.GetWindowTextLength(); char* temp = new char[length + 1]; edit.GetWindowText(temp, length + 1); int value; bool changed = false; if(length == 0) { value = rangeMin; changed = true; } else { value = atoi(temp); if(value < rangeMin) { value = rangeMin; changed = true; } else if(value > rangeMax) { value = rangeMax; changed = true; } } char numValue[33]; _itoa_s(value, numValue, 10); length = (int)strlen(numValue); if(length == 0) { edit.SetWindowText(two ? "00" : "0"); } else if(two) { if(length == 1) { char num[33]; *num = '0'; strcpy_s(num + 1, sizeof(num) - 1, numValue); edit.SetWindowText(num); } else if(changed) { edit.SetWindowText(numValue); } } else { if(length == 2) { if(*numValue == '0') { edit.SetWindowText(numValue + 1); } else if(changed) { edit.SetWindowText(numValue); } } else if(changed) { edit.SetWindowText(numValue); } } delete[] temp; } }
void CAddFieldDlg::OnUpdateOK(CCmdUI* pCmdUI) { CEdit *pEdit = (CEdit *)GetDlgItem(IDC_NAME); pCmdUI->Enable(pEdit->GetWindowTextLength()); }