void CEditorView::OnPopupLoad() { // TODO: Add your command handler code here BOOL endmarker; CString FileName; CString WindowText; CString WindowLine; static char BASED_CODE szFilter[] = "Text Files (*.txt)|*.txt|Data Files (*.dat)|*.dat|All Files (*.*)|*.*||"; CFileDialog* pLoadFile = new CFileDialog(TRUE,NULL,NULL,0,&szFilter[0],NULL); if (IDOK==pLoadFile->DoModal()) { WindowText = ""; FileName = pLoadFile->GetPathName(); delete pLoadFile; CStdioFile* pFile = new CStdioFile(FileName,CFile::modeRead); do { endmarker = pFile->ReadString(WindowLine); WindowText = WindowText+WindowLine+"\r\n"; } while (endmarker); GetEditCtrl().SetSel(-1,0,FALSE); GetEditCtrl().ReplaceSel(WindowText); pFile->Close(); delete pFile; } }
LRESULT COXNotesEditView::OnSetMargins(WPARAM wParam, LPARAM lParam) { if (m_bUpdatingMargins) return Default(); switch (wParam) { case EC_USEFONTINFO: { LRESULT lRslt=Default(); m_bUpdatingMargins=TRUE; m_nMargins=PtrToUint(SendMessage(EM_GETMARGINS,0,0)); switch (m_nSide) { case SIDE_LEFT: GetEditCtrl().SetMargins(LOWORD(m_nMargins)+m_nNotesWidth, HIWORD(m_nMargins)); break; case SIDE_RIGHT: GetEditCtrl().SetMargins(LOWORD(m_nMargins), HIWORD(m_nMargins)+m_nNotesWidth); break; } m_bUpdatingMargins=FALSE; return lRslt; } break; case EC_LEFTMARGIN: m_nMargins=MAKELONG(lParam,HIWORD(m_nMargins)); if (m_nSide==SIDE_LEFT) { m_bUpdatingMargins=TRUE; LPARAM lPrm=MAKELONG(LOWORD(m_nMargins)+m_nNotesWidth, HIWORD(m_nMargins)); LRESULT lRslt=SendMessage(EM_SETMARGINS,wParam,lPrm); m_bUpdatingMargins=FALSE; return lRslt; } else return Default(); break; case EC_RIGHTMARGIN: m_nMargins=MAKELONG(LOWORD(m_nMargins),lParam); if (m_nSide==SIDE_RIGHT) { m_bUpdatingMargins=TRUE; LPARAM lPrm=MAKELONG(LOWORD(m_nMargins), HIWORD(m_nMargins)+m_nNotesWidth); LRESULT lRslt=SendMessage(EM_SETMARGINS,wParam,lPrm); m_bUpdatingMargins=FALSE; return lRslt; } else return Default(); break; default: return Default(); } }
void MsgWndView::DisplayMessage(LPCTSTR msg) { CString strTemp = msg; strTemp += _T("\r\n"); int len = GetEditCtrl().GetWindowTextLength(); GetEditCtrl().SetSel(len, len); GetEditCtrl().ReplaceSel(strTemp); }
void CSynBCGPEditView::OnEditGotoLine() { CGotoLineDlg goDlg(this, GetEditCtrl()->GetLineCount()); if (goDlg.DoModal() != IDOK) { return; } GetEditCtrl()->GoToLine(goDlg.m_nLineNumber); }
BOOL CxEditView::OnEscape(UINT) { BOOL bHandled = FALSE; if (GetEditCtrl().IsSelection()) { GetEditCtrl().SelectNone(); bHandled = TRUE; } return bHandled; }
void CEditView::ReadFromArchive(CArchive& ar, UINT nLen) // Read certain amount of text from the file, assume at least nLen // characters (not bytes) are in the file. { ASSERT_VALID(this); LPVOID hText = LocalAlloc(LMEM_MOVEABLE, (nLen+1)*sizeof(TCHAR)); if (hText == NULL) AfxThrowMemoryException(); LPTSTR lpszText = (LPTSTR)LocalLock(hText); ASSERT(lpszText != NULL); if (ar.Read(lpszText, nLen*sizeof(TCHAR)) != nLen*sizeof(TCHAR)) { LocalUnlock(hText); LocalFree(hText); AfxThrowArchiveException(CArchiveException::endOfFile); } // Replace the editing edit buffer with the newly loaded data lpszText[nLen] = '\0'; #ifndef _UNICODE if (afxData.bWin32s) { // set the text with SetWindowText, then free BOOL bResult = ::SetWindowText(m_hWnd, lpszText); LocalUnlock(hText); LocalFree(hText); // make sure that SetWindowText was successful if (!bResult || ::GetWindowTextLength(m_hWnd) < (int)nLen) AfxThrowMemoryException(); // remove old shadow buffer delete[] m_pShadowBuffer; m_pShadowBuffer = NULL; m_nShadowSize = 0; ASSERT_VALID(this); return; } #endif LocalUnlock(hText); HLOCAL hOldText = GetEditCtrl().GetHandle(); ASSERT(hOldText != NULL); LocalFree(hOldText); GetEditCtrl().SetHandle((HLOCAL)(UINT)(DWORD)hText); Invalidate(); ASSERT_VALID(this); }
BOOL COXNotesEditView::ShowBookmark(UINT nChar) { if (IsMarked(nChar)) { UINT nLine=GetEditCtrl().LineFromChar(nChar); UINT nFirstVisible=GetEditCtrl().GetFirstVisibleLine(); UINT nLastVisible=GetLastVisibleLine(); if (nFirstVisible>nLine || nLastVisible<nLine) GetEditCtrl().LineScroll(nLine-nFirstVisible); return TRUE; } else return FALSE; }
void CxEditView::OnFormatFont() { CxFontDialog dlg(this); dlg.m_sample = GetEditCtrl().GetSelText(); ::FontDialog(this, &m_font, CF_EFFECTS | CF_SCREENFONTS, &dlg); }
// @pymethod |PyCEdit|CreateWindow|Creates the window for a new Edit object. static PyObject * PyCEdit_create_window(PyObject *self, PyObject *args) { int style, id; PyObject *obParent; RECT rect; if (!PyArg_ParseTuple(args, "i(iiii)Oi:CreateWindow", &style, // @pyparm int|style||The style for the Edit. Use any of the win32con.BS_* constants. &rect.left,&rect.top,&rect.right,&rect.bottom, // @pyparm (left, top, right, bottom)|rect||The size and position of the Edit. &obParent, // @pyparm <o PyCWnd>|parent||The parent window of the Edit. Usually a <o PyCDialog>. &id )) // @pyparm int|id||The Edits control ID. return NULL; if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type)) RETURN_TYPE_ERR("parent argument must be a window object"); CWnd *pParent = GetWndPtr( obParent ); if (pParent==NULL) return NULL; CEdit *pEdit = GetEditCtrl(self); if (!pEdit) return NULL; BOOL ok; GUI_BGN_SAVE; ok = pEdit->Create(style, rect, pParent, id ); GUI_END_SAVE; if (!ok) RETURN_ERR("CEdit::Create"); RETURN_NONE; }
// @pymethod |PyCEdit|SetSel|Sets the selection in the edit control. static PyObject *PyCEdit_set_sel(PyObject *self, PyObject *args) { CEdit *pEdit = GetEditCtrl(self); int start=0,end=0; BOOL bNoScroll = FALSE; if (!pEdit) return NULL; if (!PyArg_ParseTuple(args, "i|ii:SetSel", &start, // @pyparm int|start||Specifies the starting position. // If start is 0 and end is -1, all the text in the edit control is selected. // If start is -1, any current selection is removed. &end, // @pyparm int|end|start|Specifies the ending position. &bNoScroll)) { // @pyparm int|bNoScroll|0|Indicates whether the caret should be scrolled into view. If 0, the caret is scrolled into view. If 1, the caret is not scrolled into view. PyErr_Clear(); bNoScroll = FALSE; if (!PyArg_ParseTuple(args, "(ii)|i:SetSel", &start, // @pyparmalt2 (int, int)|start,end)||As for normal start, end args. &end, &bNoScroll)) // @pyparmalt2 int|bNoScroll|0|Indicates whether the caret should be scrolled into view. If 0, the caret is scrolled into view. If 1, the caret is not scrolled into view. return NULL; } if (start!=end && end==0) end=start; GUI_BGN_SAVE; pEdit->SetSel(start,end,bNoScroll); // @pyseemfc CEdit|SetSel GUI_END_SAVE; RETURN_NONE; }
void CBaseView::OutputMsgLine( const char * line ) { BeginNewLine( ); OutputMsgHeader( ); m_astrMsg.Add( line ); GetEditCtrl().ReplaceSel( line ); }
void CBaseView::BeginNewLine( ) { GetEditCtrl().SetSel( -1, -1 ); int nLineCount = GetEditCtrl().GetLineCount(); if( nLineCount >= 1 ) { //int nLineIndex = GetEditCtrl().LineIndex( nLineCount-1 ); //int nLineLen = GetEditCtrl().LineLength( nLineIndex ); CPoint point = GetEditCtrl().PosFromChar( UINT(-1)/*nLineIndex+nLineLen*/ ); GetEditCtrl().SetCaretPos( point ); } CString string = STRING_CRLF; GetEditCtrl().ReplaceSel( string ); }
int COXNotesEditView::ImageFromLine(UINT nLine) const { int nRet=-1; CEdit& edt=GetEditCtrl(); UINT nFirst=edt.LineIndex(nLine); UINT nLast=edt.LineLength(edt.LineIndex(nLine)); if (nLast) nLast=nLast+nFirst-1; else nLast=nFirst; for (int n=0;n<m_arBookmarks.GetSize();n++) { //every value in the m_arBookmarks array //consists of index of the char the bookmark set to //(that is 24 least significant bits in the value) and //8 most significant bits represents image index of //the bookmark in m_imgBookmarks DWORD dwIndex=m_arBookmarks.GetAt(n); DWORD dwChar=0x00FFFFFF & dwIndex; if (dwChar>=nFirst) { if (dwChar<=nLast) nRet=dwIndex>>24; else return nRet; } }
void COXNotesEditView::OnLButtonDblClk(UINT nFlags, CPoint point) { CRect rct; GetNotesRect(&rct); if (rct.PtInRect(point)) { int n=HIWORD(GetEditCtrl().CharFromPos(point)); int nChar=GetEditCtrl().LineIndex(n); if (IsMarked(nChar)) RemoveBookmarks(nChar,nChar); else SetBookmark(nChar); } CEditView::OnLButtonDblClk(nFlags, point); }
void CMsgView::OnContextMenu(CWnd *pWnd, CPoint point) { CFrameWnd *pFrame; CMenu menu; CMenu *pPopupMenu; int nStart; int nEnd; UINT uiEnable; // make sure window is active pFrame = GetParentFrame (); ASSERT (pFrame != NULL); if (pFrame != NULL) { pFrame->ActivateFrame (); }; if (!menu.LoadMenu (IDR_COMPILEVW_POPUP)) { return; } pPopupMenu = menu.GetSubMenu (0); ASSERT (pPopupMenu != NULL); if (pPopupMenu == NULL) { return; } GetEditCtrl().GetSel(nStart, nEnd); uiEnable = (nStart == nEnd) ? MF_DISABLED | MF_GRAYED : MF_ENABLED; pPopupMenu->EnableMenuItem(IDM_MSG_COPY, uiEnable); pPopupMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); }
/** * show previous error. * * selects the previous error message and displays the source location. * * @param - * @return - * @exception - * @see GetLine(), SelectLine(), EvaluateErrorMessage(), ShowSourceLocation() */ void CMsgView::ShowPreviousError() { int iLine; BOOL bFound = FALSE; CString strLine; CString strSourceFile; CString strLocation; CEdit& editCtrl = GetEditCtrl(); iLine = editCtrl.LineFromChar(); --iLine; if(iLine < 0) { iLine = editCtrl.GetLineCount() - 1; } while(GetLine(iLine, strLine)) { if(EvaluateErrorMessage(strLine, strSourceFile, strLocation)) { SelectLine(iLine); GetCDInfo(iLine-1, editCtrl, strSourceFile, dynamic_cast<CMsgFrame*>(GetParentFrame()), GetDocument()); ShowSourceLocation(strSourceFile, strLocation); bFound = TRUE; break; } --iLine; } if(!bFound) { MessageBeep(-1); } }
BOOL CSynBCGPEditView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { ((CCoolFormat3View *)GetParent()->GetParent())->GetDocument()->SetModifiedFlag(GetEditCtrl()->IsModified()); ((CCoolFormat3View *)GetParent()->GetParent())->GetDocument()->CheckTitle(); return CBCGPEditView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); }
BOOL CEditView::InitializeReplace() // helper to do find first if no selection { ASSERT_VALID(this); _AFX_EDIT_STATE* pEditState = _afxEditState; // do find next if no selection int nStartChar, nEndChar; GetEditCtrl().GetSel(nStartChar, nEndChar); if (nStartChar == nEndChar) { if (!FindText(pEditState->strFind, pEditState->bNext, pEditState->bCase)) { // text not found OnTextNotFound(pEditState->strFind); } return FALSE; } if (!SameAsSelected(pEditState->strFind, pEditState->bCase)) { if (!FindText(pEditState->strFind, pEditState->bNext, pEditState->bCase)) { // text not found OnTextNotFound(pEditState->strFind); } return FALSE; } ASSERT_VALID(this); return TRUE; }
/** * show current error. * * selects current line and shows error location in source if possible. * * @param - * @return - * @exception - * @see GetLine(), SelectLine(), EvaluateErrorMessage(), ShowSourceLocation() */ void CMsgView::ShowCurrentError() { int iLine; // line number of current line CString strLine; // current line as string CString strSourceFile; // source file name without path CString strLocation; // location in source file CEdit& editCtrl = GetEditCtrl(); // get current line iLine = editCtrl.LineFromChar(); if(!SelectLine(iLine)) { return; } GetLine(iLine, strLine); if(EvaluateErrorMessage(strLine, strSourceFile, strLocation)) { GetCDInfo(iLine-1, editCtrl, strSourceFile, dynamic_cast<CMsgFrame*>(GetParentFrame()), GetDocument()); ShowSourceLocation(strSourceFile, strLocation); } else { MessageBeep(-1); } }
void EditTxt::OnInitialUpdate() { CFont * f; CEdit & n_edit=GetEditCtrl(); CEditView::OnInitialUpdate(); CMainFrame *pFrm=(CMainFrame *)AfxGetMainWnd(); pFrm->m_edit=(EditTxt*)this; // TODO: Add your specialized code here and/or call the base class pEdit=&n_edit; //设置字体 f = new CFont; f->CreateFont(15, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation 0, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Arial")); // lpszFac pEdit->SetFont(f); //IDC_EDIT_RECEIVE是Edit框标号 }
void CEditView::OnUpdateNeedSel(CCmdUI* pCmdUI) { ASSERT_VALID(this); int nStartChar, nEndChar; GetEditCtrl().GetSel(nStartChar, nEndChar); pCmdUI->Enable(nStartChar != nEndChar); ASSERT_VALID(this); }
void CEditView::SetTabStops(int nTabStops) { ASSERT_VALID(this); m_nTabStops = nTabStops; GetEditCtrl().SetTabStops(m_nTabStops); Invalidate(); ASSERT_VALID(this); }
void CXMLTextView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { CXMLTreeDoc *pDoc = GetDocument(); //从文档类中得到要显示的字符串 m_strContent = pDoc->m_strContent; //显示字符串 GetEditCtrl().SetWindowText(m_strContent); }
void COutputView::OnDestroy() { CEdit &theEdit = GetEditCtrl(); theEdit.GetWindowText(GetDocument()->GetOutputText()); CEditView::OnDestroy(); }
/** * Function name CMsgView::OnCreate * Description * @param LPCREATESTRUCT lpCreateStruct * @return int * @exception * @see */ int CMsgView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate (lpCreateStruct) == -1) { return (-1); }; CFont *pFont; // Set fixed font pFont = CFont::FromHandle((HFONT)GetStockObject (ANSI_FIXED_FONT)); GetEditCtrl().SetFont(pFont); GetEditCtrl().SetReadOnly(); // set text limit to maximum of Windows 95/98 GetEditCtrl().SetLimitText(MSGWND_MAXTEXTLEN); UpdateEditText (); return (0); }
void CServerView::ShowMessage(CString str) { CEdit& Edit=GetEditCtrl(); m_criticalShowMess.Lock(); int len=Edit.GetWindowTextLength(); Edit.SetSel(len,len); Edit.ReplaceSel(str+"\r\n"); m_criticalShowMess.Unlock(); }
LPCTSTR CEditView::LockBuffer() const { ASSERT_VALID(this); ASSERT(m_hWnd != NULL); #ifndef _UNICODE if (afxData.bWin32s) { // under Win32s, it is necessary to maintain a shadow buffer // it is only updated when the control contents have been changed. if (m_pShadowBuffer == NULL || GetEditCtrl().GetModify()) { ASSERT(m_pShadowBuffer != NULL || m_nShadowSize == 0); UINT nSize = GetWindowTextLength()+1; if (nSize > m_nShadowSize) { // need more room for shadow buffer CEditView* pThis = (CEditView*)this; delete[] m_pShadowBuffer; pThis->m_pShadowBuffer = NULL; pThis->m_nShadowSize = 0; pThis->m_pShadowBuffer = new TCHAR[nSize]; pThis->m_nShadowSize = nSize; } // update the shadow buffer with GetWindowText ASSERT(m_nShadowSize >= nSize); ASSERT(m_pShadowBuffer != NULL); GetWindowText(m_pShadowBuffer, nSize); // turn off edit control's modify bit GetEditCtrl().SetModify(FALSE); } return m_pShadowBuffer; } #endif // else -- running under non-subset Win32 system HLOCAL hLocal = GetEditCtrl().GetHandle(); ASSERT(hLocal != NULL); LPCTSTR lpszText = (LPCTSTR)LocalLock(hLocal); ASSERT(lpszText != NULL); ASSERT_VALID(this); return lpszText; }
LRESULT CEditView::OnSetFont(WPARAM, LPARAM) { ASSERT_VALID(this); Default(); #ifndef _MAC GetEditCtrl().SetTabStops(m_nTabStops); #endif ASSERT_VALID(this); return 0; }
int CBaseView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CEditView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here GetEditCtrl().SetReadOnly( ); GetEditCtrl().SetMargins( 20, 20 ); LOGFONT lf; memset( &lf, 0, sizeof(lf) ); AfxGetProfile().GetFontBaseView( &lf ); SetFont( &lf ); // 实时行情刷新 AfxGetStkReceiver().AddRcvDataWnd( GetSafeHwnd() ); return 0; }
void CPadView::OnScrollTo(CDC*, CPrintInfo* pInfo, POINT) { UINT nPage = pInfo->m_nCurPage; ASSERT(nPage < (UINT)m_aPageStart.GetSize()); if (nPage != m_nPreviewPage) { UINT nIndex = m_aPageStart[nPage]; GetEditCtrl().SetSel((int)nIndex, (int)nIndex); } }