Example #1
0
void CvSqlQueryRichEditView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	int nHint = (int)lHint;
	CdSqlQueryRichEditDoc* pDoc =(CdSqlQueryRichEditDoc*)GetDocument();
	switch (nHint)
	{
	case UPDATE_HINT_LOAD:
		if (pHint && pHint == pDoc)
		{
			// Load document from the serialization:
			if (!pDoc->IsLoadedDoc())
				return;
			//
			// Put the global statement.
			CRichEditCtrl& redit = GetRichEditCtrl();
			LONG oldEventMask = redit.SetEventMask(ENM_NONE); // Do not send EN_CHANGE.
			redit.SetWindowText (pDoc->m_strStatement);
			// Set the highlight statement.
			if (pDoc->m_bHighlight)
			{
				redit.SetSel (0, -1);
				OnColorPick (pDoc->m_crColorText);
				redit.SetSel (pDoc->m_nStart, pDoc->m_nEnd);
				OnColorPick (pDoc->m_crColorSelect);
				redit.SetSel (-1, 0);
			}
			redit.SetEventMask(oldEventMask);// Restore the old event mask
			pDoc->SetTitle (pDoc->m_strTitle);
			//
			// Splitbar placement
			CfSqlQueryFrame* pFrame  = (CfSqlQueryFrame*)GetParentFrame();
			CSplitterWnd* pNestSplitter = pFrame->GetNestSplitterWnd();
			ASSERT (pNestSplitter); 
			CSplitterWnd* pMainSplitter = pFrame->GetMainSplitterWnd();
			ASSERT (pMainSplitter); 
			if (!(pMainSplitter && pNestSplitter))
				return;

			pMainSplitter->SetRowInfo(0, pDoc->GetSplitterCyCurMainSplit(), pDoc->GetSplitterCyMinMainSplit());
			pMainSplitter->RecalcLayout();
			pNestSplitter->SetRowInfo(0, pDoc->GetSplitterCyCurNestSplit(), pDoc->GetSplitterCyMinNestSplit());
			pNestSplitter->RecalcLayout();
		}
		break;
	case UPDATE_HINT_SETTINGCHANGE:
/*UKS
		if (pHint && pHint == pDoc && pDoc->GetSetting().GetFont())
		{
			long nStart;
			long nEnd;
			GetRichEditCtrl().GetSel(nStart, nEnd);
			//
			// The control simply uses the WM_SETFONT message to change the font.
			// There is no need to use the member:
			//    SetSelectionCharFormat,
			//    SetDefaultCharFormat,
			//    SetParaFormat,
			//    SetCharFormat,
			// because the control does not manage the text in different font.
			CString strText;
			GetRichEditCtrl().GetWindowText (strText);
			LONG oldEventMask = GetRichEditCtrl().SetEventMask(ENM_NONE); // Do not send EN_CHANGE.
			GetRichEditCtrl().Clear();
			SendMessage(WM_SETFONT, (WPARAM)pDoc->GetSetting().GetFont());
			Invalidate();
			GetRichEditCtrl().SetWindowText(strText);
			if (pDoc->m_bHighlight)
			{
				GetRichEditCtrl().SetSel (pDoc->m_nStart, pDoc->m_nEnd);
				OnColorPick (pDoc->m_crColorSelect);
				GetRichEditCtrl().SetSel (nStart, nEnd);
			}
			GetRichEditCtrl().SetEventMask(oldEventMask); 
		}
*/
		break;

	default:
		break;
	}
}
Example #2
0
long CCompileEditView::OnSendAddStr(WPARAM wParam /*= 0*/, LPARAM lParam /*= 0*/)
{
	if(lParam == NULL) 
		return 0;
		
	if( IsCompileEdit(COMPILE) )
	{
		HSAddStrCompileEdit* pData = (HSAddStrCompileEdit*)lParam;
		CString strRep;
		long nStartChar;
		long nEndChar;
		GetRichEditCtrl().GetSel( nStartChar, nEndChar );
		if(wParam == HX_EXPRESSSENTENCE)
		{
			CExpression* pExpression = (CExpression*)pData->m_strText;
			pData->m_strText = NULL;
						
			strRep.Format(_T("\n\n{ 插入%s公式体开始 }\n\n %s \n\n{ 插入%s公式体结束 }\n"),
				pExpression->GetName(),pExpression->GetSource(),pExpression->GetName());
			GetRichEditCtrl().SetSel (-1,-1); // 插入到最后
			GetRichEditCtrl().ReplaceSel(strRep,TRUE);

			if( m_pParentDlg->m_WndGridCtrl.GetSafeHwnd() )
			{
				//m_pParentDlg->m_WndGridCtrl.SetParamer(pExpression->GetParamVar(),TRUE);

				CMapVariabile* pVarsMap = pExpression->GetParamVar();
				int nRow = m_pParentDlg->m_WndGridCtrl.GetFixedRowCount();
				if ( pVarsMap ==NULL )
				{
					for(;nRow < m_pParentDlg->m_WndGridCtrl.GetRowCount(); nRow++)
					{
						m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,1,"");
						m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,2,"");
						m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,3,"");
						m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,4,"");
						m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,5,"");
					}
				}
				CNumericValue* pValue;
				CArray<class CValue*,class CValue*>* pArray = pVarsMap->GetObjArray();
				CString sName;
				CString strRetName;
				for(int nObj = 0; pArray != NULL && nObj < pArray->GetSize(); nObj++)
				{
					pValue = (CNumericValue*)pArray->GetAt(nObj);
					if( !pValue->IsStyle(HX_EXPRESSNUMBER) )
						continue;
					CString strValue;
					sName = pVarsMap->GetObjectName(pValue);			
					strRetName.Format("%s",sName);
					m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,1,strRetName);
					strValue.Format("%d", pValue->GetMinValue());
					m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,2,strValue);
					strValue.Format("%d", pValue->GetMaxValue());
					m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,3,strValue);
					strValue.Format("%d", pValue->GetValue());
					m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,4,strValue);
					strValue.Format("%d", pValue->GetTestStepValue());
					m_pParentDlg->m_WndGridCtrl.SetItemText(nRow,5,strValue);
		
					nRow++;
				}
				m_pParentDlg->m_WndGridCtrl.Invalidate();
			}
		}
		else
		{
			strRep.Format("%s",*pData->m_strText);
			GetRichEditCtrl().ReplaceSel(strRep,FALSE);
			GetRichEditCtrl().SetSel( nStartChar+pData->m_nCharPos, nStartChar+pData->m_nCharPos );
		}		
		SetFocus();
	}
	else if( IsCompileEdit(HELP) )
	{
		CString* str = (CString*)lParam;

		GetRichEditCtrl().SetWindowText(*str);
		int nCount = GetRichEditCtrl().GetLineCount();
		CDC* pDC = GetRichEditCtrl().GetDC();
		if(pDC != NULL)
		{
			nCount = pDC->GetTextExtent("A").cy * (nCount + 1);
			GetRichEditCtrl().ReleaseDC(pDC);
		}

		CSplitterWnd* pWnd = (CSplitterWnd*)this->GetParent();
		if( pWnd != NULL && pWnd->IsKindOf(RUNTIME_CLASS(CSplitterWnd)) )
		{	
			CRect rect;
			pWnd->GetClientRect(rect);
			int nHeight = rect.Height() - nCount;
			if(nHeight < 0) nHeight = rect.Height();
			pWnd->SetRowInfo(0,nHeight,0);
			pWnd->SetRowInfo(1,nCount,0);
			pWnd->RecalcLayout();
		}
	}
	return 0;
}