不开机自运行,手动双击运行,读取时间参数,执行faceenergy()函数,进入ontimer()后只响应一次就停住了;开机自运行则执行正确,是否逻辑上有问题,差了好久,没有进展,还请大家帮帮忙!!!void CDlgSet::InitDataSet()//对话框初始化中的函数
{
WriteLogString("进入initdataset ");
CFileFind filefind_init;
int Last_Pos;
CFile MyFile_init;
Absolute_EnergyPath();
if(filefind_init.FindFile(absolute_dir))//为自运行提供关显示器、待机、休眠的时间
{ MyFile_init.Open(absolute_dir,CFile::modeReadWrite);
MyFile_init.Read(&Custom_Plan,sizeof(Plan));
Current_Plan.LCD_time=Custom_Plan.LCD_time;
Current_Plan.Wait_time=Custom_Plan.Wait_time;
Current_Plan.Off_Or_Sleep=Custom_Plan.Off_Or_Sleep;
Current_Plan.Sleep_time=Custom_Plan.Sleep_time;
Last_Pos=Custom_Plan.Slider_Pos; if (Last_Pos==4)
{
WriteLogString("进入自定义初始化");
m_Slider.SetPos(Last_Pos);//////////////////////////////////cslider控件
GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO2)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO3)->EnableWindow(TRUE); m_combo1.SetCurSel(Custom_Plan.Combo1_Pos);
m_combo2.SetCurSel(Custom_Plan.Combo2_Pos);
m_combo3.SetCurSel(Custom_Plan.Combo3_Pos);
if (Current_Plan.Off_Or_Sleep==1)
{
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
}
if (Current_Plan.Off_Or_Sleep==0)
{
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(TRUE);
}
}
else
{
if(Last_Pos==1)
{
m_Slider.SetPos(Last_Pos);
m_combo1.SetCurSel(5);
m_combo2.SetCurSel(9);
m_combo3.SetCurSel(15);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE); } if(Last_Pos==2)
{
m_Slider.SetPos(Last_Pos);
m_combo1.SetCurSel(4);
m_combo2.SetCurSel(8);
m_combo3.SetCurSel(13);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
} if(Last_Pos==3)
{
m_Slider.SetPos(Last_Pos);
m_combo1.SetCurSel(3);
m_combo2.SetCurSel(6);
m_combo3.SetCurSel(10);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE); }
} MyFile_init.Close();
WriteLogString("开机自运行或用户手动运行-读取配置方案文件");
FaceEnergy();/////////////////////////////////////////////////获取时间参数进行节能,响应ontimer(); }
else
{
m_Slider.SetPos(1);//此动作是否和slider消息函数有冲突啊?具体不知道!
m_combo1.SetCurSel(5);
m_combo2.SetCurSel(9);
m_combo3.SetCurSel(15);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
}
}void CDlgSet::OnCustomdrawSlider(NMHDR* pNMHDR, LRESULT* pResult) ////////slider消息响应函数
{
// TODO: Add your control notification handler code here
switch (m_Slider.GetPos())
{
case 1:
{
m_combo1.SetCurSel(5);
m_combo2.SetCurSel(9);
m_combo3.SetCurSel(15);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
}
break;
case 2:
{
m_combo1.SetCurSel(4);
m_combo2.SetCurSel(8);
m_combo3.SetCurSel(13);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
}
break;
case 3:
{
m_combo1.SetCurSel(3);
m_combo2.SetCurSel(6);
m_combo3.SetCurSel(10);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
}
break;
case 4:
{
GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO2)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO3)->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
CFileFind filefind_slider;
CFile MyFile_slider;
Absolute_EnergyPath();
if(filefind_slider.FindFile(absolute_dir))
{
WriteLogString("find in slider 4 ");
MyFile_slider.Open(absolute_dir,CFile::modeReadWrite);
MyFile_slider.Read(&Custom_Plan,sizeof(Plan));
MyFile_slider.Close();
WriteLogString("Custom_Plan.Combo1_Pos=%d",Custom_Plan.Combo1_Pos);
WriteLogString("Custom_Plan.Combo2_Pos=%d",Custom_Plan.Combo2_Pos);
WriteLogString("Custom_Plan.Combo3_Pos=%d",Custom_Plan.Combo3_Pos);
m_combo1.SetCurSel(Custom_Plan.Combo1_Pos);
m_combo2.SetCurSel(Custom_Plan.Combo2_Pos);
m_combo3.SetCurSel(Custom_Plan.Combo3_Pos);
}
else
{
m_combo1.SetCurSel(0);
m_combo2.SetCurSel(1);
m_combo3.SetCurSel(2);
}
}
break;
}
// *pResult = 0;
}
{
WriteLogString("进入initdataset ");
CFileFind filefind_init;
int Last_Pos;
CFile MyFile_init;
Absolute_EnergyPath();
if(filefind_init.FindFile(absolute_dir))//为自运行提供关显示器、待机、休眠的时间
{ MyFile_init.Open(absolute_dir,CFile::modeReadWrite);
MyFile_init.Read(&Custom_Plan,sizeof(Plan));
Current_Plan.LCD_time=Custom_Plan.LCD_time;
Current_Plan.Wait_time=Custom_Plan.Wait_time;
Current_Plan.Off_Or_Sleep=Custom_Plan.Off_Or_Sleep;
Current_Plan.Sleep_time=Custom_Plan.Sleep_time;
Last_Pos=Custom_Plan.Slider_Pos; if (Last_Pos==4)
{
WriteLogString("进入自定义初始化");
m_Slider.SetPos(Last_Pos);//////////////////////////////////cslider控件
GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO2)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO3)->EnableWindow(TRUE); m_combo1.SetCurSel(Custom_Plan.Combo1_Pos);
m_combo2.SetCurSel(Custom_Plan.Combo2_Pos);
m_combo3.SetCurSel(Custom_Plan.Combo3_Pos);
if (Current_Plan.Off_Or_Sleep==1)
{
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
}
if (Current_Plan.Off_Or_Sleep==0)
{
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(TRUE);
}
}
else
{
if(Last_Pos==1)
{
m_Slider.SetPos(Last_Pos);
m_combo1.SetCurSel(5);
m_combo2.SetCurSel(9);
m_combo3.SetCurSel(15);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE); } if(Last_Pos==2)
{
m_Slider.SetPos(Last_Pos);
m_combo1.SetCurSel(4);
m_combo2.SetCurSel(8);
m_combo3.SetCurSel(13);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
} if(Last_Pos==3)
{
m_Slider.SetPos(Last_Pos);
m_combo1.SetCurSel(3);
m_combo2.SetCurSel(6);
m_combo3.SetCurSel(10);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE); }
} MyFile_init.Close();
WriteLogString("开机自运行或用户手动运行-读取配置方案文件");
FaceEnergy();/////////////////////////////////////////////////获取时间参数进行节能,响应ontimer(); }
else
{
m_Slider.SetPos(1);//此动作是否和slider消息函数有冲突啊?具体不知道!
m_combo1.SetCurSel(5);
m_combo2.SetCurSel(9);
m_combo3.SetCurSel(15);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
}
}void CDlgSet::OnCustomdrawSlider(NMHDR* pNMHDR, LRESULT* pResult) ////////slider消息响应函数
{
// TODO: Add your control notification handler code here
switch (m_Slider.GetPos())
{
case 1:
{
m_combo1.SetCurSel(5);
m_combo2.SetCurSel(9);
m_combo3.SetCurSel(15);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
}
break;
case 2:
{
m_combo1.SetCurSel(4);
m_combo2.SetCurSel(8);
m_combo3.SetCurSel(13);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
}
break;
case 3:
{
m_combo1.SetCurSel(3);
m_combo2.SetCurSel(6);
m_combo3.SetCurSel(10);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
GetDlgItem(IDC_COMBO3)->EnableWindow(FALSE);
}
break;
case 4:
{
GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO2)->EnableWindow(TRUE);
GetDlgItem(IDC_COMBO3)->EnableWindow(TRUE);
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(Current_Plan.Off_Or_Sleep);
((CButton *)GetDlgItem(IDC_RADIO2))->SetCheck(1-Current_Plan.Off_Or_Sleep);
CFileFind filefind_slider;
CFile MyFile_slider;
Absolute_EnergyPath();
if(filefind_slider.FindFile(absolute_dir))
{
WriteLogString("find in slider 4 ");
MyFile_slider.Open(absolute_dir,CFile::modeReadWrite);
MyFile_slider.Read(&Custom_Plan,sizeof(Plan));
MyFile_slider.Close();
WriteLogString("Custom_Plan.Combo1_Pos=%d",Custom_Plan.Combo1_Pos);
WriteLogString("Custom_Plan.Combo2_Pos=%d",Custom_Plan.Combo2_Pos);
WriteLogString("Custom_Plan.Combo3_Pos=%d",Custom_Plan.Combo3_Pos);
m_combo1.SetCurSel(Custom_Plan.Combo1_Pos);
m_combo2.SetCurSel(Custom_Plan.Combo2_Pos);
m_combo3.SetCurSel(Custom_Plan.Combo3_Pos);
}
else
{
m_combo1.SetCurSel(0);
m_combo2.SetCurSel(1);
m_combo3.SetCurSel(2);
}
}
break;
}
// *pResult = 0;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货