long CDlgStrategyParamConf::LoadCurExp(WPARAM wParam /*= 0*/, LPARAM lParam /*= 0*/) { m_sSingleSel.m_nType = hx_DefMaxValues; CDlgFormulaMan* pParentDlg = (CDlgFormulaMan*)AfxGetMainWnd(); if( pParentDlg == NULL ) return 0; EnableItem(FALSE); if( wParam == CTreeCtrlFormula::YlsBrowser ) { if(m_nType == 1) { CTreeGroup* pTreeGroup = (CTreeGroup*)lParam; // CString strItem = *(CString*)lParam; /* if( !strItem.CompareNoCase(CTreeCtrlFormula::g_strUnionCondition) ) { m_sSingleSel.m_nType = CExpression::Union; m_sSingleSel.m_strExp.Format("%s",CTreeCtrlFormula::g_strUnionCondition); m_wndPeriod.ShowWindow(SW_HIDE); m_wndPeriodStc.ShowWindow(SW_HIDE); m_wndConNotes.ShowWindow(SW_HIDE); m_wndCon.ShowWindow(SW_HIDE); m_wndStaticCon.ShowWindow(SW_HIDE); m_wndCompare.ShowWindow(SW_HIDE); m_wndData1.ShowWindow(SW_HIDE); m_wndAndOr.ShowWindow(SW_HIDE); m_wndData2.ShowWindow(SW_HIDE); m_wndMiddle.ShowWindow(SW_HIDE); }*/ // else if( !strItem.CompareNoCase(CTreeCtrlFormula::g_strJiben) ) /* else*/ if( pTreeGroup->m_dwID == CExpression::JiBenMian ) { m_sSingleSel.m_nType = CExpression::JiBenMian; m_sSingleSel.m_strExp.Format("%s",CTreeCtrlFormula::g_strJiben); m_wndPeriod.ShowWindow(SW_HIDE); #ifdef _ONLY_SUPPORT_DAYLINE m_wndPeriod.SetCurSel(0); #else m_wndPeriod.SetCurSel(5); #endif m_wndPeriodStc.ShowWindow(SW_HIDE); m_wndConNotes.ShowWindow(SW_SHOW); m_wndConNotes.SetWindowText(HS_LANGUAGE("财务指标")); m_wndCon.ShowWindow(SW_SHOW); m_wndStaticCon.ShowWindow(SW_SHOW); m_wndCompare.ShowWindow(SW_SHOW); m_wndData1.ShowWindow(SW_SHOW); m_wndAndOr.ShowWindow(SW_HIDE); m_wndData2.ShowWindow(SW_HIDE); m_wndMiddle.ShowWindow(SW_HIDE); m_wndData1.ResetContent(); m_wndData2.ResetContent(); m_wndCon.ResetContent(); CDlgCondition::InitCWData(&m_wndCon,YLS_GB_GUBEN_NAME); CDlgCondition::InitCWData(&m_wndCon,YLS_Cj_GUBEN_NAME); CDlgCondition::InitCondition(&m_wndCompare,4); } } } else if( wParam == CCompileEditView::UpdateExpress ) { CDlgFormulaEdit* pDlg = pParentDlg->GetExpDlg(); if( pDlg != NULL ) { if(pDlg->SendMessage(HX_USER_LOADCUR,wParam,lParam)) { pParentDlg->Enable(FALSE); pDlg->ShowWindowEx(SW_SHOWNORMAL); } } } else if( wParam == HX_EXPRESSSENTENCE ) { //EnableItem(FALSE); CExpression* pExpression = (CExpression*)lParam; if( pExpression == NULL ) return 0; // if(m_nType == 1) { m_sSingleSel.m_nType = pExpression->GetExpressType(); m_sSingleSel.m_strExp.Format("%s",pExpression->GetName()); CDlgCondition::InitCondition(&m_wndCompare,-1); switch ( m_sSingleSel.m_nType ) { case CExpression::Tech: { //"选出技术指标数值满足下列条件的股票:"); m_wndPeriod.ShowWindow(SW_SHOW); #ifdef _ONLY_SUPPORT_DAYLINE m_wndPeriod.SetCurSel(0); #else m_wndPeriod.SetCurSel(5); #endif m_wndPeriodStc.ShowWindow(SW_SHOW); m_wndConNotes.ShowWindow(SW_SHOW); m_wndConNotes.SetWindowText(HS_LANGUAGE("指标线")); m_wndCon.ShowWindow(SW_SHOW); m_wndCon.ResetContent(); m_wndStaticCon.ShowWindow(SW_SHOW); m_wndCompare.ShowWindow(SW_SHOW); m_wndData1.ShowWindow(SW_SHOW); CValue* valoare = NULL; if( CExpression::m_pExternExpression->Lookup(pExpression->GetName(),pExpression->GetExpressType(),valoare) ) // over { CExpValue* pExpValue = (CExpValue*)valoare; BOOL bFree = FALSE; CExpression* pCurExpression = pExpValue->GetExp(); if( pCurExpression && pCurExpression == pExpression ) { if( !pCurExpression->IsCompile() ) { if( !pCurExpression->Compile() ) { bFree = TRUE; } } CArray<CFormulaDrawParam*,CFormulaDrawParam*> ayDraw; CString strParam; int nCount = pCurExpression->GetDraw(strParam,ayDraw); CFormulaDrawParam* pParam; if( nCount > 0 ) { for(int i = 0; i < nCount; i++) { pParam = ayDraw.GetAt(i); if( nCount == 1 && CString(pParam->m_strName).IsEmpty() ) { m_wndCon.AddString(CTreeCtrlFormula::g_strFirstTechLine); } else { m_wndCon.AddString(pParam->m_strName); } delete pParam; } } else { m_wndCon.AddString(CTreeCtrlFormula::g_strFirstTechLine); } m_wndCon.SetCurSel(m_wndCon.GetCount()-1); OnSelchangeCompare(); } if( bFree ) { pExpValue->Free(); } } } break; case CExpression::Condition: { //"选出满足下列条件的股票:"); m_sSingleSel.m_SubData.m_cType = FormulaCompareSubData::Condition; m_wndPeriod.ShowWindow(SW_SHOW); #ifdef _ONLY_SUPPORT_DAYLINE m_wndPeriod.SetCurSel(0); #else m_wndPeriod.SetCurSel(5); #endif m_wndPeriodStc.ShowWindow(SW_SHOW); m_wndConNotes.ShowWindow(SW_HIDE); m_wndCon.ShowWindow(SW_HIDE); m_wndStaticCon.ShowWindow(SW_HIDE); m_wndCompare.ShowWindow(SW_HIDE); m_wndData1.ShowWindow(SW_HIDE); m_wndAndOr.ShowWindow(SW_HIDE); m_wndData2.ShowWindow(SW_HIDE); m_wndMiddle.ShowWindow(SW_HIDE); } break; case CExpression::Exchange: { //"选出交易系统发出以下信号的股票:"); m_sSingleSel.m_SubData.m_cType = FormulaCompareSubData::Exchange; m_wndPeriod.ShowWindow(SW_SHOW); #ifdef _ONLY_SUPPORT_DAYLINE m_wndPeriod.SetCurSel(0); #else m_wndPeriod.SetCurSel(5); #endif m_wndPeriodStc.ShowWindow(SW_SHOW); m_wndConNotes.ShowWindow(SW_HIDE); m_wndConNotes.SetWindowText(HS_LANGUAGE("发出")); m_wndCon.ShowWindow(SW_HIDE); m_wndStaticCon.ShowWindow(SW_HIDE); m_wndCompare.ShowWindow(SW_HIDE); m_wndData1.ShowWindow(SW_HIDE); m_wndAndOr.ShowWindow(SW_HIDE); m_wndData2.ShowWindow(SW_HIDE); m_wndMiddle.ShowWindow(SW_HIDE); } break; case CExpression::MoreKLine: { //"选出五彩K线发出指示的股票:"); m_sSingleSel.m_SubData.m_cType = FormulaCompareSubData::MoreKLine; m_wndPeriod.ShowWindow(SW_SHOW); #ifdef _ONLY_SUPPORT_DAYLINE m_wndPeriod.SetCurSel(0); #else m_wndPeriod.SetCurSel(5); #endif m_wndPeriodStc.ShowWindow(SW_SHOW); m_wndConNotes.ShowWindow(SW_HIDE); m_wndCon.ShowWindow(SW_HIDE); m_wndStaticCon.ShowWindow(SW_HIDE); m_wndCompare.ShowWindow(SW_HIDE); m_wndData1.ShowWindow(SW_HIDE); m_wndAndOr.ShowWindow(SW_HIDE); m_wndData2.ShowWindow(SW_HIDE); m_wndMiddle.ShowWindow(SW_HIDE); } break; } } // 注释/参数修改 // CWnd* pWnd = GetDlgItem(IDC_NOTES); // pWnd->ShowWindow(SW_SHOW); m_EditEidolon.ShowWindow(SW_SHOW); CDlgNotesAndEidolon* pDlgNotes = pParentDlg->GetDlgNotes(); CDlgNotesAndEidolon* pDlgParam = pParentDlg->GetDlgParam(); if( pDlgNotes != NULL && pDlgNotes->IsWindowVisible() ) { pDlgNotes->SetNotes(pExpression->GetNotes(), pExpression->GetName()); } if( m_EditEidolon.m_hWnd != NULL ) { CString strText; strText.Format("%s",pExpression->GetEidolon()); if( !strText.IsEmpty() ) { m_EditEidolon.SetText(strText,pExpression->GetParamVar(),FALSE); } else { CStringArray* pArray = pExpression->GetDefEidolon(); if(pArray->GetSize() <= 1) { pArray = NULL; } m_EditEidolon.SetText(pArray,pExpression->GetParamVar(),FALSE); } m_EditEidolon.Invalidate(); } } return 0; }
void CDlgStrategyHQ::OnOK() { if( m_pData == NULL ) goto _Exit; CDlgFormulaMan* pParentDlg = (CDlgFormulaMan*)AfxGetMainWnd(); if( pParentDlg == NULL ) goto _Exit; CTreeCtrlFormula* pCurTree = m_wndTab.GetTree(); if( !pCurTree ) goto _Exit; HTREEITEM hItem = pCurTree->GetSelectedItem(); if( hItem == NULL ) goto _Exit; CTreeGroup* pTreeGroup = (CTreeGroup*)pCurTree->GetItemData(hItem); if( (pTreeGroup == NULL) || (pTreeGroup->GetData() == NULL) || !pTreeGroup->IsStatus(hx_GroupItem) ) goto _Exit; if(m_pData->m_wType & hxShowByExpressType) { CString csCode,csCycle,csBuyTimes,csSellTimes,csTriggertime,csTriggerNum,csGap; int buyTimes,sellTimes,trigTime,trigNum,gap, perType,perNum; m_wndCode.GetWindowText(csCode);//股票代码 m_wndCycle.GetWindowText(csCycle); m_wndBuyTimes.GetWindowText(csBuyTimes); m_wndSellTimes.GetWindowText(csSellTimes); m_wndTriggerTime.GetWindowText(csTriggertime); m_wndTrigerNum.GetWindowText(csTriggerNum); m_wndGap.GetWindowText(csGap); if(csCode.IsEmpty()) { ::MessageBox( m_hWnd,_T(" 请填写代码! "),_T(" 提示 "), MB_OK); m_wndCode.SetFocus(); return ; } if(csCycle.IsEmpty() || csCycle == "多日线") { if (csCycle.IsEmpty()) { ::MessageBox( m_hWnd,_T(" 请选择分析周期! "),_T(" 提示 "), MB_OK); m_wndCycle.SetFocus(); return ; } CString cs; m_wndDay.GetWindowText(cs); if (cs.IsEmpty() || atoi(cs) <= 0) { ::MessageBox( m_hWnd,_T(" 请填写多日天数! "),_T(" 提示 "), MB_OK); m_wndDay.SetFocus(); return ; } perType = AnalisysForMoreDay; perNum = atoi(cs); } else { if (csCycle == "1分钟") { perType = AnalisysFor1; perNum = 0; } else if (csCycle == "5分钟") { perType = AnalisysFor5; } else if (csCycle == "15分钟") { perType = AnalisysFor15; } else if (csCycle == "30分钟") { perType = AnalisysFor30; } else if (csCycle == "60分钟") { perType = AnalisysFor60; } else if (csCycle == "日线") { perType = AnalisysForDay; } else if (csCycle == "周线") { perType = AnalisysForWeek; } else if (csCycle == "月线") { perType = AnalisysForMonth; } perNum = 0; } if(csBuyTimes.IsEmpty()) { ::MessageBox( m_hWnd,_T(" 请填写买入次数! "),_T(" 提示 "), MB_OK); m_wndBuyTimes.SetFocus(); return ; } if(csSellTimes.IsEmpty()) { ::MessageBox( m_hWnd,_T(" 请填写卖出次数! "),_T(" 提示 "), MB_OK); m_wndSellTimes.SetFocus(); return ; } if(csTriggertime.IsEmpty()) { ::MessageBox( m_hWnd,_T(" 请填写持续多少秒触发! "),_T(" 提示 "), MB_OK); m_wndTriggerTime.SetFocus(); return ; } if(csTriggerNum.IsEmpty()) { ::MessageBox( m_hWnd,_T(" 请填写几次达标后触发! "),_T(" 提示 "), MB_OK); m_wndTrigerNum.SetFocus(); return ; } strcpy(m_pStrategy->m_cCode,csCode); buyTimes = atoi(csBuyTimes); if(buyTimes < -1 || buyTimes > SHORT_MAX)// { ::MessageBox( m_hWnd,_T(" 请正确填写买入次数! "),_T(" 提示 "), MB_OK); m_wndBuyTimes.SetFocus(); return ; } sellTimes = atoi(csSellTimes); if( sellTimes < -1 || sellTimes > SHORT_MAX)// { ::MessageBox( m_hWnd,_T(" 请正确填写卖出次数! "),_T(" 提示 "), MB_OK); m_wndSellTimes.SetFocus(); return ; } trigTime = atoi(csTriggertime); if (trigTime < -1 || trigTime > SHORT_MAX)// { ::MessageBox( m_hWnd,_T(" 请正确填写持续多少秒触发! "),_T(" 提示 "), MB_OK); m_wndTriggerTime.SetFocus(); return ; } trigNum = atoi(csTriggerNum); if (trigNum < -1 || trigNum > SHORT_MAX)// { ::MessageBox( m_hWnd,_T(" 请正确填写几次达标后触发! "),_T(" 提示 "), MB_OK); m_wndTrigerNum.SetFocus(); return ; } gap = atoi(csGap); if( gap < -1 || gap > SHORT_MAX)// { ::MessageBox( m_hWnd,_T(" 请正确填写连续委托间隔! "),_T(" 提示 "), MB_OK); m_wndGap.SetFocus(); return ; } m_pStrategy->m_nPeriodType = perType; m_pStrategy->m_nPeriodNumber = perNum; m_pStrategy->m_nMaxBuyTimes = buyTimes; m_pStrategy->m_nMaxSellTimes = sellTimes; m_pStrategy->m_nTrigTimes = trigTime; m_pStrategy->m_nMaxTrigTimes = trigNum; m_pStrategy->m_nGap = gap; if(m_pStrategy->m_nGap == 0)//默认为30秒 { m_pStrategy->m_nGap = 30; } if (m_wndCheck.GetCheck()) { m_pStrategy->m_bFuQuan = 0; } else { m_pStrategy->m_bFuQuan = 1; } if (m_wndXD.GetCheck()) { m_pStrategy->m_bXD = 1; } else { m_pStrategy->m_bXD = 0; } if (m_pStrategy->m_pData == NULL) { m_pStrategy->m_pData = new CLineProperty; } if (!m_pStrategy->m_pData->m_pCurVal) { m_pStrategy->m_pData->m_pCurVal = new CExpValue; } //只保存公式名和变量 CExpression *pNew; if (!((CExpValue*)(m_pStrategy->m_pData->m_pCurVal))->GetExp()) { pNew = new CExpression; } else pNew = ((CExpValue*)(m_pStrategy->m_pData->m_pCurVal))->GetExp(); CExpression *pTreeExp = pTreeGroup->GetData(); if (pTreeExp)//复制参数值 { CMapVariabile *pMv = pTreeExp->GetParamVar(); //---------------------------------------------- if (pMv) { CMapVariabile *pMap = new CMapVariabile; CString key; CValue *cvalue; POSITION pos; pos = pMv->GetStartPosition(); while(pos) { pMv->GetNextAssoc(pos,key,cvalue); CNumericValue *pnum = new CNumericValue; double db = cvalue->GetValue(); pnum->SetValue(db); pnum->SetStyle(cvalue->GetStyle()); pnum->SetMaxValue(((CNumericValue*)cvalue)->GetMaxValue()); pnum->SetMinValue(((CNumericValue*)cvalue)->GetMinValue()); pnum->SetTestStepValue(((CNumericValue*)cvalue)->GetTestStepValue()); pnum->SetDescribe(((CNumericValue*)cvalue)->GetDescribe()); pMap->SetAt(key,pnum); } //=============================================================== pNew->SetParamVar(pMap);//存储变量值 } memcpy(m_pStrategy->m_sExpName,pTreeExp->GetName(),32);//存储公式名 } ((CExpValue*)(m_pStrategy->m_pData->m_pCurVal))->SetValue(pNew); } CWnd* pwnd = GetParent(); if (pwnd && pwnd->IsKindOf(RUNTIME_CLASS(CDlgStrategyMain))) { CDlgStrategyMain *pMain = (CDlgStrategyMain*)pwnd; pMain->m_bHQOK = TRUE; } OnCancel(); return ; _Exit: ::MessageBox( m_hWnd,_T(" 请选择一个公式! "),_T(" 提示 "), MB_OK); return ; }
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; }
long CDlgStrategyHQ::LoadCurExp(WPARAM wParam /*= 0*/, LPARAM lParam /*= 0*/) { CDlgFormulaMan* pParentDlg = (CDlgFormulaMan*)AfxGetMainWnd(); if( pParentDlg == NULL ) return 0; EnableItem(FALSE); if( wParam == CCompileEditView::UpdateExpress ) { CDlgFormulaEdit* pDlg = pParentDlg->GetExpDlg(); if( pDlg != NULL ) { if(pDlg->SendMessage(HX_USER_LOADCUR,wParam,lParam)) { pParentDlg->Enable(FALSE); pDlg->ShowWindow(SW_SHOWNORMAL); } } } else if( wParam == HX_EXPRESSSENTENCE ) { //EnableItem(FALSE); CExpression* pExpression = (CExpression*)lParam; if( pExpression == NULL ) return 0; CString csName = pExpression->GetName(); CString cExpName = m_pStrategy->m_sExpName; if (m_bSetVar && csName == cExpName && m_pStrategy->m_pData->m_pCurVal) { CExpression *pex = ((CExpValue*)(m_pStrategy->m_pData->m_pCurVal))->GetExp(); if (pex)//设置参数 { CMapVariabile *pMap = pExpression->GetParamVar(); CMapVariabile *pMv = pex->GetParamVar(); //-------------------------------------------------- if (pMv && pMap) { CString key; CValue *cvalue; CValue *pval; POSITION pos; pos = pMv->GetStartPosition(); while(pos) { pMv->GetNextAssoc(pos,key,cvalue); if (pMap->Lookup(key,pval)) { ((CNumericValue*)pval)->SetValueOnly(cvalue->GetValue()); } } //===================================================================== } } } CString cs = pExpression->GetName(); m_EditEidolon.ShowWindow(SW_SHOW); CDlgNotesAndEidolon* pDlgNotes = pParentDlg->GetDlgNotes(); CDlgNotesAndEidolon* pDlgParam = pParentDlg->GetDlgParam(); if( pDlgNotes != NULL && pDlgNotes->IsWindowVisible() ) { pDlgNotes->SetNotes(pExpression->GetNotes(), pExpression->GetName()); } if( m_EditEidolon.m_hWnd != NULL ) { CString strText; strText.Format("%s",pExpression->GetEidolon()); if( !strText.IsEmpty() ) { m_EditEidolon.SetText(strText,pExpression->GetParamVar(),FALSE); } else { CStringArray* pArray = pExpression->GetDefEidolon(); if(pArray->GetSize() <= 1) { pArray = NULL; } m_EditEidolon.SetText(pArray,pExpression->GetParamVar(),FALSE); } m_EditEidolon.Invalidate(); } } return 0; }