📄 pppclientdlg.cpp
字号:
GetDlgItem(IDC_ACTIONIN_COMBO)->EnableWindow(!TRUE);
GetDlgItem(IDC_ACTIONOUT_COMBO)->EnableWindow(!TRUE);
GetDlgItem(IDC_SPEED_EDIT)->EnableWindow(!TRUE);
GetDlgItem(IDC_SPEED_SPIN)->EnableWindow(!TRUE);
GetDlgItem(IDC_DELAYTIME_EDIT)->EnableWindow(TRUE);
GetDlgItem(IDC_DELAYTIME_SPIN)->EnableWindow(TRUE);
((CComboBox *)GetDlgItem(IDC_POSITION_COMBO))->EnableWindow(TRUE);
break;
}
UpdateData(FALSE);
m_save_filename=tmpfile;
SetWindowText(TEXT("PPPClient(Ver2.01)-")+m_save_filename);
//
SetMenuItemState(2,ID_DEMOONE_SIMULATION,TRUE);
SetMenuItemState(2,ID_DEMOALL_SIMULATION,TRUE);
SetMenuItemState(2,ID_STOPDEMO_SIMULATION,FALSE);
//
SetToolBarBtnState(ID_DEMOONE_SIMULATION,TRUE);
SetToolBarBtnState(ID_DEMOALL_SIMULATION,TRUE);
SetToolBarBtnState(ID_STOPDEMO_SIMULATION,FALSE);
}
//
//update list...(all)
m_item_list.DeleteAllItems();
TCHAR tmpstr[256];
CPlayTableData data;
POSITION pos;//=m_playtable_data.GetHeadPosition();
for(int i=0;i<m_playtable_data.GetCount();i++)
{
pos=m_playtable_data.FindIndex(i);
data=m_playtable_data.GetAt(pos);
//save data
m_item_list.InsertItem(i,TEXT("TEST2006"));
//#no
_stprintf(tmpstr,_T("#%d"),i+1);
m_item_list.SetItemText(i,0,tmpstr);
//type
m_item_list.SetItemText(i,1,tmp_type_str[data.type] );
//#filename
m_item_list.SetItemText(i,2,data.filename);
//action in //action out
if(data.type<=1)
{
m_item_list.SetItemText(i,3,tmp_fun_in_str[data.in]);
m_item_list.SetItemText(i,4,tmp_fun_out_str[data.out]);
}
else
{
m_item_list.SetItemText(i,3,tmp_fun_in_str[MAX_ADD_SHOWWAY-1]);//
m_item_list.SetItemText(i,4,tmp_fun_out_str[MAX_ADD_SHOWWAY-2]);
}
//speed
_stprintf(tmpstr,_T("%d"),data.speed);
m_item_list.SetItemText(i,5,tmpstr);
//delaytime
_stprintf(tmpstr,_T("%d"),data.delaytime);
m_item_list.SetItemText(i,6,tmpstr);
}
//m_cur_pos==0
m_item_list.SetItemState (m_cur_pos, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
//m_edit_type=2;//modify
SetControlEnable(FALSE);
SetNavigatorButton(m_cur_pos);
}
void CPPPClientDlg::OnSaveFile()
{
// TODO: Add your command handler code here
if(m_edit_type<0) return;
CFile m_file;
if(!m_file.Open(m_save_filename,CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone))
{
// m_edit_type=-1;//
AfxMessageBox(TEXT("save file failed!"));
return;
}
m_file.SeekToBegin( );
//UpdateData();//??? for edit item
CPlayTableData data;
//ZeroMemory(&data,sizeof(data));
if(m_playtable_data.GetCount()>0)
{
POSITION pos = m_playtable_data.GetHeadPosition();
for(int i=0;i<m_playtable_data.GetCount();i++)
{
data=m_playtable_data.GetNext(pos);
//save data
m_file.Write(&data,sizeof(data));
}
//
}
m_file.Close();
m_modify_flag=false;//
}
void CPPPClientDlg::OnSaveasFile()
{
// TODO: Add your command handler code here
if(m_edit_type<0) return;
if(m_modify_flag&&MessageBox(TEXT("The content has been modified,Are you sure to save it(Yes/No)?"),
TEXT("Save File"),
MB_YESNO|MB_ICONQUESTION)==
IDYES)
{
//
OnSaveFile();
}
TCHAR chFilter[]=TEXT("PlayTable Files(*.TAB)|*.TAB|All Files(*.*)|*.*||");
CFileDialog filedlg(false,_T("TAB"),NULL,OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY,chFilter);
filedlg.m_ofn.lpstrInitialDir=GetCurDir();
filedlg.m_ofn.lpstrTitle=TEXT("SaveAs Tab File");
CString tmpfile;
if(filedlg.DoModal()==IDOK)
{
//
tmpfile=filedlg.GetPathName();
// write FILE
CFile m_file;
if(!m_file.Open(tmpfile,CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone))
{
// m_edit_type=-1;//
AfxMessageBox(TEXT("save as file failed!"));
return;
}
m_file.SeekToBegin( );
//UpdateData();//??? for edit item
CPlayTableData data;
//ZeroMemory(&data,sizeof(data));
if(m_playtable_data.GetCount()>0)
{
POSITION pos = m_playtable_data.GetHeadPosition();
for(int i=0;i<m_playtable_data.GetCount();i++)
{
data=m_playtable_data.GetNext(pos);
//save data
m_file.Write(&data,sizeof(data));
}
//
}
m_file.Close();
//
m_save_filename=tmpfile;
SetWindowText(TEXT("PPPClient(Ver2.01)-")+m_save_filename);
//其它不变
m_modify_flag=false;//
}
}
void CPPPClientDlg::OnAppendButton()
{
// TODO: Add your control notification handler code here
if(m_edit_type<0) return;
//type
m_type_combobox.SetCurSel(0);
//SHARE FILE
m_sharefile_flag=FALSE;
//filename
m_cur_filename=_T("");
//action in
m_actionin_combobox.EnableWindow(true);
m_actionin_combobox.SetCurSel(0);
//action out
m_actionout_combobox.EnableWindow(true);
m_actionout_combobox.SetCurSel(0);
//speed
m_speed=10;
//delaytime
m_delaytime=1000;
//position
m_position_combobox.SetCurSel(2);
//
m_edit_type=0;//append :0
UpdateData(FALSE);
//
//
m_cur_data.delaytime=1000;
_tcscpy(m_cur_data.filename,_T(""));
m_cur_data.in=0;
m_cur_data.out=0;
m_cur_data.speed=10;
m_cur_data.type=0;
//
m_cur_data.tp.m_text_font_name=0;
m_cur_data.tp.m_text_font_width=12;
m_cur_data.tp.m_text_font_height=16;
m_cur_data.tp.m_text_fc_color=RGB(255,0,0);
m_cur_data.tp.m_text_bc_color=RGB(0,0,0);
SetControlEnable(TRUE);
// SetNavigatorButton(m_cur_pos);
}
void CPPPClientDlg::OnInsertButton()
{
// TODO: Add your control notification handler code here
if(m_edit_type<0) return;
//type
m_type_combobox.SetCurSel(0);
//SHARE FILE
m_sharefile_flag=FALSE;
//filename
m_cur_filename=_T("");
//action in
m_actionin_combobox.EnableWindow(true);
m_actionin_combobox.SetCurSel(0);
//action out
m_actionout_combobox.EnableWindow(true);
m_actionout_combobox.SetCurSel(0);
//speed
m_speed=10;
//delaytime
m_delaytime=1000;
//position
m_position_combobox.SetCurSel(2);
//
m_edit_type=1;//insert(before)
UpdateData(FALSE);
//
m_cur_data.delaytime=1000;
_tcscpy(m_cur_data.filename,_T(""));
m_cur_data.in=0;
m_cur_data.out=0;
m_cur_data.speed=10;
m_cur_data.type=0;
//
m_cur_data.tp.m_text_font_name=0;
m_cur_data.tp.m_text_font_width=12;
m_cur_data.tp.m_text_font_height=16;
m_cur_data.tp.m_text_fc_color=RGB(255,0,0);
m_cur_data.tp.m_text_bc_color=RGB(0,0,0);
SetControlEnable(TRUE);
}
void CPPPClientDlg::OnSaveButton()
{
// TODO: Add your control notification handler code here
if(m_edit_type<0) return;
//
UpdateData();
//
if(m_cur_filename=="")
{
AfxMessageBox("Please Enter filename!");
return;
}
CPlayTableData data;
ZeroMemory(&data,sizeof(data));
//
//TYPE
data.type= m_type_combobox.GetCurSel();
if(data.type==0)//text
{
data.tp=m_cur_data.tp;
}
//share flag
if(!m_sharefile_flag)
data.share_flag=FALSE;
else
data.share_flag=TRUE;
//FILE
_tcscpy(data.filename,m_cur_filename);
//ACTION IN
data.in= m_actionin_combobox.GetCurSel();
//ACTION OUT
data.out= m_actionout_combobox.GetCurSel();
//SPEED
data.speed = m_speed;
//DELAY TIME
data.delaytime=m_delaytime;
//position
data.position =m_position_combobox.GetCurSel();
//
TCHAR tmpstr[256];
// CPlayTableData data;
POSITION pos;//=m_playtable_data.GetHeadPosition();
int i;
switch(m_edit_type)
{
case 0://append
//update : add tail to list
m_playtable_data.AddTail(data);
//更新当前数据移动指针
m_cur_pos=m_playtable_data.GetCount()-1;
//update list...
//pos=m_playtable_data.FindIndex(m_cur_pos);//GetHeadPosition|GetHead
//data=m_playtable_data.GetAt(pos);
//save data
m_item_list.InsertItem(m_cur_pos,TEXT("TEST2006"));
//#no
_stprintf(tmpstr,_T("#%d"),m_cur_pos+1);
m_item_list.SetItemText(m_cur_pos,0,tmpstr);
//type
m_item_list.SetItemText(m_cur_pos,1,tmp_type_str[data.type] );
//#filename
m_item_list.SetItemText(m_cur_pos,2,data.filename);
//action in //action out
if(data.type<=1)
{
m_item_list.SetItemText(m_cur_pos,3,tmp_fun_in_str[data.in]);
m_item_list.SetItemText(m_cur_pos,4,tmp_fun_out_str[data.out]);
}
else
{
m_item_list.SetItemText(m_cur_pos,3,tmp_fun_in_str[MAX_ADD_SHOWWAY-1]);//
m_item_list.SetItemText(m_cur_pos,4,tmp_fun_out_str[MAX_ADD_SHOWWAY-2]);
}
//speed
_stprintf(tmpstr,_T("%d"),data.speed);
m_item_list.SetItemText(m_cur_pos,5,tmpstr);
//delaytime
_stprintf(tmpstr,_T("%d"),data.delaytime);
m_item_list.SetItemText(m_cur_pos,6,tmpstr);
//高亮度选中最后一项
m_item_list.SetItemState (m_cur_pos, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
//设置控件的有效性
SetControlEnable(FALSE);
//m_cur_pos=m_playtable_data.GetCount()-1;
//设置指针移动的有效性
SetNavigatorButton(m_cur_pos);
break;
case 1://insert
// SetControlEnable(FALSE);
if(m_cur_pos<0)
{
m_playtable_data.AddTail(data);
m_cur_pos=m_playtable_data.GetCount()-1;
}
else
{
m_playtable_data.InsertBefore(m_playtable_data.FindIndex(m_cur_pos),data);
//m_cur_pos应该不变,但对应的数据内容已改变
}
//update list...(all)
m_item_list.DeleteAllItems();
//show data
for( i=0;i<m_playtable_data.GetCount();i++)
{
pos=m_playtable_data.FindIndex(i);
data=m_playtable_data.GetAt(pos);
//save data
m_item_list.InsertItem(i,TEXT("TEST2006"));
//#no
_stprintf(tmpstr,_T("#%d"),i+1);
m_item_list.SetItemText(i,0,tmpstr);
//type
m_item_list.SetItemText(i,1,tmp_type_str[data.type] );
//#filename
m_item_list.SetItemText(i,2,data.filename);
//action in //action out
if(data.type<=1)
{
m_item_list.SetItemText(i,3,tmp_fun_in_str[data.in]);
m_item_list.SetItemText(i,4,tmp_fun_out_str[data.out]);
}
else
{
m_item_list.SetItemText(i,3,tmp_fun_in_str[MAX_ADD_SHOWWAY-1]);//
m_item_list.SetItemText(i,4,tmp_fun_out_str[MAX_ADD_SHOWWAY-2]);
}
//speed
_stprintf(tmpstr,_T("%d"),data.speed);
m_item_list.SetItemText(i,5,tmpstr);
//delaytime
_stprintf(tmpstr,_T("%d"),data.delaytime);
m_item_list.SetItemText(i,6,tmpstr);
}
//高亮度选中最后一项,m_cur_pos 不变
m_item_list.SetItemState (m_cur_pos, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
//设置控件的有效性
SetControlEnable(FALSE);
//设置指针移动的有效性
SetNavigatorButton(m_cur_pos);
break;
case 2://modify
m_playtable_data.SetAt(m_playtable_data.FindIndex(m_cur_pos),data);
//update list...
//save data
// m_list.InsertItem(m_cur_pos,TEXT("TEST2006"));
//#no
_stprintf(tmpstr,_T("#%d"),m_cur_pos+1);
m_item_list.SetItemText(m_cur_pos,0,tmpstr);
//type
m_item_list.SetItemText(m_cur_pos,1,tmp_type_str[data.type] );
//#filename
m_item_list.SetItemText(m_cur_pos,2,data.filename);
//action in //action out
if(data.type<=1)
{
m_item_list.SetItemText(m_cur_pos,3,tmp_fun_in_str[data.in]);
m_item_list.SetItemText(m_cur_pos,4,tmp_fun_out_str[data.out]);
}
else
{
m_item_list.SetItemText(m_cur_pos,3,tmp_fun_in_str[MAX_ADD_SHOWWAY-1]);//
m_item_list.SetItemText(m_cur_pos,4,tmp_fun_out_str[MAX_ADD_SHOWWAY-2]);
}
//speed
_stprintf(tmpstr,_T("%d"),data.speed);
m_item_list.SetItemText(m_cur_pos,5,tmpstr);
//delaytime
_stprintf(tmpstr,_T("%d"),data.delaytime);
m_item_list.SetItemText(m_cur_pos,6,tmpstr);
//高亮度选中最后一项
m_item_list.SetItemState (m_cur_pos, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
//设置控件的有效性
SetControlEnable(FALSE);
//设置指针移动的有效性
SetNavigatorButton(m_cur_pos);
break;
}
//
m_modify_flag=true;
//....
}
void CPPPClientDlg::OnCanc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -