STDMETHODIMP CConnect::Test(int a) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) // TODO: Add your implementation code here CValue Val; Val=a; AfxMessageBox(Val.GetString()); return S_OK; }
void CCrystalEditView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { CCrystalTextView::OnChar(nChar, nRepCnt, nFlags); if ((::GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0 || (::GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0) return; if (nChar ==32 || nChar == VK_RETURN) if(nCursorColor==COLORINDEX_NORMALTEXT||nCursorColor==COLORINDEX_KEYWORD) {//анализ на предмет использования шаблонов CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); if(ptCursorPos.y>=0&&ptCursorPos.y<GetLineCount()) { CString Str = GetLineChars(ptCursorPos.y); int nLength = GetLineLength(ptCursorPos.y); Str=Str.Left(min(ptCursorPos.x,nLength)); CValue vDeleteText; CValue vInsertText; extern int AfxCallInitProc(CString csName,CValue Param,CValue &vDeleteText,CValue &vInsertText); int nRet=AfxCallInitProc("ПриВыбореШаблона",String(Str),vDeleteText,vInsertText); if(nRet) { int nDeleteCount=vDeleteText.GetString().GetLength(); int nStartPos=max(0,ptCursorPos.x-nDeleteCount); if(nDeleteCount>0) m_pTextBuffer->DeleteText(this, ptCursorPos.y, nStartPos, ptCursorPos.y, ptCursorPos.x, CE_ACTION_TYPING); int x, y; CString csStrInsert=vInsertText.GetString(); m_pTextBuffer->InsertText(this, ptCursorPos.y, nStartPos, csStrInsert, y, x, CE_ACTION_TYPING); CPoint ptEnd; ptEnd.x=x; ptEnd.y=y; ptCursorPos.x=0; SetSelection(ptCursorPos, ptEnd); FormatSelection(0); ptEnd.y-=(csStrInsert.Replace("\r","\r")+1)/2; ptEnd.x=GetLineLength(ptEnd.y); SetSelection(ptEnd, ptEnd); SetAnchor(ptEnd); SetCursorPos(ptEnd); EnsureVisible(ptEnd); MoveEnd(0); } } } BOOL bTranslated = FALSE; if (nChar == VK_RETURN) { if (m_bOvrMode) { CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); if (ptCursorPos.y < GetLineCount() - 1) { ptCursorPos.x = 0; ptCursorPos.y++; ASSERT_VALIDTEXTPOS(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetAnchor(ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); return; } } m_pTextBuffer->BeginUndoGroup(); if (QueryEditable() && m_pTextBuffer != NULL) { DeleteCurrentSelection(); int x, y; CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); const static TCHAR pszText[3] = _T("\r\n"); m_pTextBuffer->InsertText(this, ptCursorPos.y, ptCursorPos.x, pszText, y, x, CE_ACTION_TYPING); // [JRT] int nLenght = GetLineLength(ptCursorPos.y); CString sLineBuf = GetLineChars(ptCursorPos.y); CString sBegin=""; for(int i=0;i<=nLenght;i++) { char cChr; cChr = sLineBuf.GetAt(i); if(!IsLetter(cChr,1)) sBegin+=cChr; else break; } int nPos=ptCursorPos.x; m_pTextBuffer->InsertText(this,y,x, sBegin, y, x, CE_ACTION_TYPING); // [JRT] ptCursorPos.x = x; ptCursorPos.y = y; ASSERT_VALIDTEXTPOS(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetAnchor(ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); /* FormatSelection(-1); if(nPos>0) { MoveEnd(0); } */ } m_pTextBuffer->FlushUndoGroup(this); return; } if (nChar > 31) { if (QueryEditable() && m_pTextBuffer != NULL) { BOOL bUndoBeginGroup=m_pTextBuffer->m_bUndoGroup; if(!bUndoBeginGroup) m_pTextBuffer->BeginUndoGroup(nChar != _T(' ')); CPoint ptSelStart, ptSelEnd; GetSelection(ptSelStart, ptSelEnd); CPoint ptCursorPos; if (ptSelStart != ptSelEnd) { ptCursorPos = ptSelStart; DeleteCurrentSelection(); } else { ptCursorPos = GetCursorPos(); if (m_bOvrMode && ptCursorPos.x < GetLineLength(ptCursorPos.y)) m_pTextBuffer->DeleteText(this, ptCursorPos.y, ptCursorPos.x, ptCursorPos.y, ptCursorPos.x + 1, CE_ACTION_TYPING); // [JRT] } ASSERT_VALIDTEXTPOS(ptCursorPos); char pszText[2]; pszText[0] = (char) nChar; pszText[1] = 0; int x,y; USES_CONVERSION; m_pTextBuffer->InsertText(this, ptCursorPos.y, ptCursorPos.x, A2T(pszText), y, x, CE_ACTION_TYPING); // [JRT] ptCursorPos.x = x; ptCursorPos.y = y; ASSERT_VALIDTEXTPOS(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetAnchor(ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); if(!bUndoBeginGroup) m_pTextBuffer->FlushUndoGroup(this); } } }
void CValueControl::SetValue(CValue &Val) { SetString(Val.GetString()); };