// OperationVlaueDlg.cpp : implementation file // #include "stdafx.h" #include "KBEditors.h" #include "KBEditorsDoc.h" #include "OperationVlaueDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // OperationVlaueDlg dialog OperationVlaueDlg::OperationVlaueDlg(CWnd* pParent /*=NULL*/) : CDialog(OperationVlaueDlg::IDD, pParent) { //{{AFX_DATA_INIT(OperationVlaueDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void OperationVlaueDlg::SeeDoc(CKBEditorsDoc* Doc,CString Atrb,BOOL ComeFromResult) { m_Doc = Doc; Attribute =Atrb; FromResult = ComeFromResult; } void OperationVlaueDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(OperationVlaueDlg) DDX_Control(pDX, IDC_CobVlaList, m_ValueListCtrl); DDX_Control(pDX, IDC_CobOPList, m_OpListCtrl); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(OperationVlaueDlg, CDialog) //{{AFX_MSG_MAP(OperationVlaueDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // OperationVlaueDlg message handlers BOOL OperationVlaueDlg::OnInitDialog() { CDialog::OnInitDialog(); CString Cpt,Prop; Cpt = GetCpt(Attribute,'.'); Prop = GetProp(Attribute,'.'); CConcept * CptObj; // AfxMessageBox(Cpt); if(!m_Doc->m_CptList.Lookup(Cpt,CptObj)) return TRUE; // AfxMessageBox("BB"); CProperty * PropObj; CptObj->m_PropList.Lookup(Prop,PropObj); m_OpListCtrl.AddString("=="); if (!FromResult) m_OpListCtrl.AddString("!="); else m_OpListCtrl.SelectString(0,"=="); CString strVal=strIn; strVal.Delete(0,2); if(PropObj->Type =="nominal" || PropObj->Type =="Multi-Value") { POSITION pos = PropObj->m_LegalValueList.GetStartPosition(); CString nKey,Val; while (pos != NULL) { PropObj->m_LegalValueList.GetNextAssoc( pos, nKey, Val ); m_ValueListCtrl.AddString(nKey); } if(m_ValueListCtrl.GetCount() > 0) m_ValueListCtrl.SelectString(0,strVal); else{ m_ValueListCtrl.AddString(strVal); m_ValueListCtrl.SetCurSel(0); } } else { m_ValueListCtrl.AddString(strVal); m_ValueListCtrl.SetCurSel(0); if (!FromResult){ m_OpListCtrl.AddString(">="); m_OpListCtrl.AddString("<="); m_OpListCtrl.AddString("> "); m_OpListCtrl.AddString("< "); } } int len=strIn.GetLength(); if (!FromResult){ CString strOp=strIn; strOp.Delete(2,len-2); m_OpListCtrl.SelectString(0,strOp); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } CString OperationVlaueDlg::GetCpt(CString Att,char a) { CString Temp; int x = Att.Find(a); Temp = Att.Left(x); return Temp; } CString OperationVlaueDlg::GetProp(CString Attr,char a) { CString Temp; int x = Attr.Find(a); Temp = Attr.Right(Attr.GetLength()-x-1); return Temp; } void OperationVlaueDlg::OnOK() { strOut = strIn; int Sel = m_OpListCtrl.GetCurSel(); if (Sel < 0) { CDialog::OnOK(); return; } CString Value ; m_ValueListCtrl.GetWindowText(Value); if(Value.IsEmpty()) { CDialog::OnOK(); return; } CString OP; m_OpListCtrl.GetLBText(Sel,OP); strOut = OP + "-" + Value; CDialog::OnOK(); }