qq_23935107 2015-05-12 11:52 采纳率: 78.6%
浏览 2680
已采纳

vc++6.0 中teechart不懂之处

BOOL CCccDlg::OnInitDialog()
{
CDialog::OnInitDialog();
AfxEnableControlContainer();
COleDateTime now=COleDateTime::GetCurrentTime();//得到当前的时间
CString strDate=now.Format("%Y-%m-%d");//得到日期
CString strTime=now.Format("%H:%M:%S");//得到时间
SetDlgItemText(IDC_EDIT1,strDate);
SetDlgItemText(IDC_EDIT2,strTime);
SetTimer(1,1000,NULL);//计置计时器

m_Grid1.SetExtendedStyle(LVS_EX_FLATSB
    |LVS_EX_FULLROWSELECT
    |LVS_EX_HEADERDRAGDROP
    |LVS_EX_ONECLICKACTIVATE
    |LVS_EX_GRIDLINES);
m_Grid1.InsertColumn(0,"日期",LVCFMT_LEFT,130,0);
m_Grid1.InsertColumn(1,"时间",LVCFMT_LEFT,130,1);
m_Grid1.InsertColumn(2,"炉号",LVCFMT_LEFT,130,2); 
m_Grid1.InsertColumn(3,"钢种",LVCFMT_LEFT,130,3);
m_Grid1.InsertColumn(4,"班组",LVCFMT_LEFT,130,4);
m_Grid1.InsertColumn(5,"炉龄",LVCFMT_LEFT,130,5);

m_Grid1.InsertColumn(6,"计算动态吹氧量",LVCFMT_LEFT,130,6);
m_Grid1.InsertColumn(7,"计算冷却剂加入量",LVCFMT_LEFT,130,7);
m_Grid1.InsertColumn(8,"钢水碳含量推定值",LVCFMT_LEFT,130,8);
m_Grid1.InsertColumn(9,"钢水温度推定值",LVCFMT_LEFT,130,9);

m_Grid1.InsertColumn(10,"实际动态吹氧量",LVCFMT_LEFT,130,10);
m_Grid1.InsertColumn(11,"实际冷却剂加入量",LVCFMT_LEFT,130,11);
m_Grid1.InsertColumn(12,"实际终点碳含量",LVCFMT_LEFT,130,12);
m_Grid1.InsertColumn(13,"实际终点钢水温度",LVCFMT_LEFT,130,13);

m_Grid1.InsertColumn(14,"脱碳系数α",LVCFMT_LEFT,130,14);
m_Grid1.InsertColumn(15,"脱碳系数β",LVCFMT_LEFT,130,15);
m_Grid1.InsertColumn(16,"升温系数γ",LVCFMT_LEFT,130,16);
m_Grid1.InsertColumn(17,"升温系数δ",LVCFMT_LEFT,130,17);


ADO m_Ado;
m_Ado.OnInitADOConn();//连接数据库
CString SQL = "select * from Dynamic order by 日期 desc"; //设置查询字符串
m_Ado.m_pRecordset = m_Ado.OpenRecordset(SQL);//打开记录集
while(!m_Ado.m_pRecordset->adoEOF)
{
    m_Grid1.InsertItem(0,"");
    m_Grid1.SetItemText(0,0,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("日期"));
    m_Grid1.SetItemText(0,1,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("时间"));
    m_Grid1.SetItemText(0,2,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("炉号"));      
    m_Grid1.SetItemText(0,3,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("钢种"));
    m_Grid1.SetItemText(0,4,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("班组"));
    m_Grid1.SetItemText(0,5,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("炉龄"));

    m_Grid1.SetItemText(0,6,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("计算动态吹氧量"));
    m_Grid1.SetItemText(0,7,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("计算冷却剂加入量"));
    m_Grid1.SetItemText(0,8,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("钢水碳含量推定值"));
    m_Grid1.SetItemText(0,9,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("钢水温度推定值"));

    m_Grid1.SetItemText(0,10,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("实际动态吹氧量"));
    m_Grid1.SetItemText(0,11,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("实际冷却剂加入量"));
    m_Grid1.SetItemText(0,12,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("实际终点碳含量"));
    m_Grid1.SetItemText(0,13,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("实际终点钢水温度"));

    m_Grid1.SetItemText(0,14,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("脱碳系数α"));
    m_Grid1.SetItemText(0,15,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("脱碳系数β"));
    m_Grid1.SetItemText(0,16,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("升温系数γ"));
    m_Grid1.SetItemText(0,17,(char*)(_bstr_t)m_Ado.m_pRecordset->GetCollect("升温系数δ"));

    m_Ado.m_pRecordset->MoveNext();//将记录集指针移动到下一条记录
}
AddToGrid();
m_Ado.CloseRecordset();
m_Ado.CloseConn();//断开数据库连接
// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
    CString strAboutMenu;
    strAboutMenu.LoadString(IDS_ABOUTBOX);
    if (!strAboutMenu.IsEmpty())
    {
        pSysMenu->AppendMenu(MF_SEPARATOR);
        pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
}

// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);         // Set big icon
SetIcon(m_hIcon, FALSE);        // Set small icon

//m_ctrlChart.Create("",WS_VISIBLE, CRect(0, 0, 0, 0), this, 1234) ;
m_ctrlChart.GetAspect().SetView3D(FALSE);
m_ctrlChart1.GetAspect().SetView3D(FALSE);
m_ctrlChart.GetAxis().GetLeft().GetTitle().SetCaption("数值");
m_ctrlChart1.GetAxis().GetLeft().GetTitle().SetCaption("值");
m_ctrlChart.AddSeries(0);
m_ctrlChart.Series(0).SetVerticalAxis(0);
m_ctrlChart.Series(0).SetHorizontalAxis(1);
m_ctrlChart.Series(0).GetXValues().SetDateTime(true);
m_ctrlChart1.AddSeries(0);
m_ctrlChart.Series(0).SetColor(RGB(0,0,5));
m_ctrlChart1.Series(0).SetColor(RGB(0,255,255));
m_ctrlChart.Series(0).SetName("ZongFengGuan");
m_ctrlChart.Series(0).Clear();
m_ctrlChart1.Series(0).Clear();
/////////////////////////////////
m_ctrlChart.AddSeries(1);
m_ctrlChart.Series(1).SetVerticalAxis(0);
m_ctrlChart.Series(1).SetHorizontalAxis(1);
m_ctrlChart.Series(1).GetXValues().SetDateTime(true);
m_ctrlChart1.AddSeries(1);
m_ctrlChart.Series(1).SetColor(RGB(255,0,0));
m_ctrlChart1.Series(1).SetColor(RGB(0,0,255));
m_ctrlChart.Series(1).Clear();

m_ctrlChart1.Series(1).Clear();
//m_ctrlChart.GetPage().SetMaxPointsPerPage(100);
//m_ctrlChart1.GetPage().SetMaxPointsPerPage(8000);//横坐标的范围
srand((int)time(0));
char strTime2[25],strTime8[25];
int k=10;
int l=10;
do
{
itoa(k,strTime2,10);
itoa(l,strTime8,10);
int dTemper = k+20;
int dTemper1 = rand()%10;
m_ctrlChart.Series(0).AddXY(k,dTemper,strTime2,RGB(0,0,255));
m_ctrlChart1.Series(0).AddXY(l,dTemper1,strTime8,RGB(0,0,255));
k=k+10;
l=l+10;
}
while(k<100&&l<100);
m_ctrlChart.GetAxis().GetLeft().SetMinMax(0, 100);//纵坐标的范围
m_ctrlChart1.GetAxis().GetLeft().SetMinMax(0, 10);
}
void CCccDlg::OnButton1()
{
// TODO: Add your control notification handler code here

char o1[12],o2[12],o3[12],o4[12],o5[12],o6[12],o7[12],o8[12],o9[12],o10[12],o11[12],o12[12],o13[12],o14[12],o15[12],o16[12],o17[12],o18[12];
GetDlgItem(IDC_EDIT6)->GetWindowText(o1,12);
GetDlgItem(IDC_EDIT7)->GetWindowText(o2,12);
GetDlgItem(IDC_EDIT8)->GetWindowText(o3,12);
GetDlgItem(IDC_EDIT9)->GetWindowText(o4,12);
GetDlgItem(IDC_EDIT10)->GetWindowText(o5,12);
GetDlgItem(IDC_EDIT11)->GetWindowText(o6,12);
GetDlgItem(IDC_EDIT12)->GetWindowText(o7,12);
GetDlgItem(IDC_EDIT13)->GetWindowText(o8,12);
GetDlgItem(IDC_EDIT14)->GetWindowText(o9,12);
GetDlgItem(IDC_EDIT15)->GetWindowText(o10,12);
GetDlgItem(IDC_EDIT16)->GetWindowText(o11,12);
GetDlgItem(IDC_EDIT17)->GetWindowText(o12,12);
GetDlgItem(IDC_EDIT18)->GetWindowText(o13,12);
GetDlgItem(IDC_EDIT19)->GetWindowText(o14,12);
GetDlgItem(IDC_EDIT21)->GetWindowText(o15,12);
GetDlgItem(IDC_EDIT22)->GetWindowText(o16,12);
GetDlgItem(IDC_EDIT25)->GetWindowText(o17,12);
GetDlgItem(IDC_EDIT26)->GetWindowText(o18,12);

a1=atof(o1);//钢水重量Wst
a2=atof(o2);//副枪开始测定时的送氧量Oxm
a3=atof(o3);//从吹炼开始算起的送氧量
a4=atof(o4);//极限碳含量
a5=atof(o5);//冷却剂的含氧量
a6=atof(o6);//冷却剂的冷却能力
a7=atof(o7);//α
a8=atof(o8);//β
a9=atof(o9);//γ
a10=atof(o10);//δ
a11=atof(o11);//副枪测定的碳含量
a12=atof(o12);//副枪测定的温度
a13=atof(o13);//目标温度
a14=atof(o14);//目标碳含量
a15=atof(o15);//实际动态吹氧量
a16=atof(o16);//实际冷却剂加入量
a17=atof(o17);//实际终点碳含量
a18=atof(o18);//实际终点温度
long double Oxe,Rore;
Oxe=((a8*a1*log((exp((a11-a4)/a8)-1)/(exp((a14-a4)/a8)-1))*0.1/a7+a2+a5*(a13-a12-a10+a9*a2/a1)/a6))/(1+(a5*a9)/(a6*a1));
Rore=-1*(a13-a12-a10*(Oxe-a2)/a1-a10)/a6;
CString str1,str2;
str1.Format("%.3f",Oxe);
str2.Format("%.3f",Rore);
GetDlgItem(IDC_EDIT5)->SetWindowText(str1);
GetDlgItem(IDC_EDIT20)->SetWindowText(str2);
//计算碳温曲线()
long double wc,t;
wc=0;
t=0;
m_ctrlChart.GetAspect().SetView3D(FALSE);
m_ctrlChart1.GetAspect().SetView3D(FALSE); 
m_ctrlChart.GetAxis().GetLeft().GetTitle().SetCaption("碳含量/%"); 
m_ctrlChart1.GetAxis().GetLeft().GetTitle().SetCaption("温度/℃"); 

//m_ctrlChart.GetPage().SetMaxPointsPerPage(20);
//m_ctrlChart1.GetPage().SetMaxPointsPerPage(20);
srand((int)time(0));
char strTime3[25],strTime4[25];
long double  i=100;
if (Rore>0)
{
    do 
    {
    itoa(i,strTime3,10);
    itoa(i,strTime4,10);
    wc=a4+a8*log(1+(exp((a11-a4)/a8)-1)*exp(-10*a7*((i+a5*Rore)/a1)/a8));
    t=a12+a9*i/a1+a10-a6*Rore;
    m_ctrlChart.Series(1).AddXY(i,wc,strTime3,RGB(0,100,110));
    m_ctrlChart1.Series(1).AddXY(i,t,strTime4,RGB(255,0,0));
    i=i+100;
    }
    while(fabs(wc-a14)<0.0002||fabs(t-a13)<12||i>1400);
    m_ctrlChart.GetAxis().GetLeft().SetMinMax(0,100);
    m_ctrlChart1.GetAxis().GetLeft().SetMinMax(0,100);
}
else if(Rore<=0)
{
    int j=100;
    do
    {
    itoa(j,strTime3,10);
    itoa(j,strTime4,10);
    Rore=0;
    wc=a4+a8*log(1+(exp((a11-a4)/a8)-1)*exp(-10*a7*((j+a5*Rore)/a1)/a8));
    t=a12+a9*j/a1+a10-a6*Rore;
    m_ctrlChart.Series(1).AddXY(j,wc,strTime3,RGB(0,255,0));
    m_ctrlChart1.Series(1).AddXY(j,t,strTime4,RGB(255,0,0));
    j=j+100;
    }
    while(fabs(wc-a14)<0.0002||fabs(t-a13)<12||j>1400);
    m_ctrlChart.GetAxis().GetLeft().SetMinMax(0,100);
    m_ctrlChart1.GetAxis().GetLeft().SetMinMax(0,100);
}
CString str3,str4,str5;
str3.Format("%.5f",wc);
str4.Format("%.1f",t);
str5.Format("%f",i);
GetDlgItem(IDC_EDIT23)->SetWindowText(str3);
GetDlgItem(IDC_EDIT24)->SetWindowText(str4);
GetDlgItem(IDC_EDIT21)->SetWindowText(str5);

}
怎么在运行的时候 只显示随机数的曲线 我点button1 不显示我想要的series1的曲线

  • 写回答

2条回答 默认 最新

  • threenewbee 2015-05-12 11:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ansys electronics 2021 R1安装报错,错误代码2,如图
  • ¥30 搭建面包板由NE555N和SN74LS90N组成的计时电路时出了问题
  • ¥15 无源定位系统的时差估计误差标准差
  • ¥15 请问这个代码哪里有问题啊
  • ¥20 python--version在命令端输入结果Python is not defined怎么办?还有pip不是exe格式是不是没安装成功?
  • ¥15 通过GaussianView进行结构微调消除虚频
  • ¥15 调用transformers库
  • ¥15 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
  • ¥15 新硬盘安装的程序总是崩溃,提示遇到错误
  • ¥15 openpcdet自制数据集评估bev精度和3d精度相同