📄 pppserverdlg.cpp
字号:
else
l_SubMenu->ModifyMenu(ID_SHOWHIDE_MAINDLG_CONTROL, MF_STRING,ID_SHOWHIDE_MAINDLG_CONTROL,L"Show Main Window");
}
//
//force menu to be redrawn:
CommandBar_DrawMenuBar(ghCB, 0);
l_Menu.Detach();
}
return 0;
}
void CPPPServerDlg::OnSetposOption()
{
// TODO: Add your command handler code here
CSetPosition m_dlg;
m_dlg.DoModal();
}
void CPPPServerDlg::OnSetsizeOption()
{
// TODO: Add your command handler code here
CSetSize m_dlg;
m_dlg.DoModal();
}
void CPPPServerDlg::OnNewFile()
{
// TODO: Add your command handler code here
CFileDialog filedlg(TRUE,_T("TAB"),NULL,OFN_HIDEREADONLY,L"PlayTable Files(*.TAB)|*.TAB|All Files(*.*)|*.*||");
filedlg.m_ofn.lpstrInitialDir=_T("\\");
filedlg.m_ofn.lpstrTitle=TEXT("New Tab File");
if(filedlg.DoModal()==IDOK)
{
m_save_filename=filedlg.GetPathName();
SetWindowText(L"PPPServer (Ver2.00) for wince.net-"+m_save_filename);
//
//new
// m_item_list.ResetContent();
//type
m_type_combobox.SetCurSel(0);
//filename
m_cur_filename=_T("");
//share file
m_sharefile_flag=FALSE;
//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;
//postion
m_position_combobox.SetCurSel(0);
//
m_edit_type=0;//append ,insert
//clear data
m_cur_pos=-1;
if(m_playtable_data.GetCount()>0)
m_playtable_data.RemoveAll();
//
m_edit_type=0;//Append
SetControlEnable(FALSE);
SetNavigatorButton(m_cur_pos);
UpdateData(FALSE);
//Update list
//clear item list
m_list.DeleteAllItems();
//
m_cur_data.delaytime=1000;
wcscpy(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=16;
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);
}
}
void CPPPServerDlg::OnOpenFile()
{
// TODO: Add your command handler code here
CFileDialog filedlg(TRUE,_T("TAB"),NULL,OFN_HIDEREADONLY,L"PlayTable Files(*.TAB)|*.TAB|All Files(*.*)|*.*||");
filedlg.m_ofn.lpstrInitialDir=_T("\\");
filedlg.m_ofn.lpstrTitle=TEXT("Open Tab File");
CString tmpfile;
if(filedlg.DoModal()==IDOK)
{
tmpfile=filedlg.GetPathName();
///open
//clear item list
// m_list.DeleteAllItems();
//type
m_type_combobox.SetCurSel(0);
//filename
m_cur_filename=_T("");
//share file
m_sharefile_flag=FALSE;
//action in
m_actionin_combobox.SetCurSel(0);
//action out
m_actionout_combobox.SetCurSel(0);
//speed
m_speed=10;
//delaytime
m_delaytime=1000;
//postion
m_position_combobox.SetCurSel(0);
//
m_edit_type=0;//append ,insert
//clear data
m_cur_pos=-1;///////////
if(m_playtable_data.GetCount()>0)
m_playtable_data.RemoveAll();
//
//
m_cur_data.delaytime=1000;
wcscpy(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=16;
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);
//open data file
CFile m_file;
CPlayTableData data;
DWORD dwRead;
ZeroMemory(&data,sizeof(data));
if(m_file.Open(tmpfile,CFile::modeRead|CFile::shareDenyNone))
{
//read data from open file
do
{
dwRead=m_file.Read(&data,sizeof(data));
if(dwRead!=0)
{
m_playtable_data.AddTail(data);
}
}
while(dwRead>0);
//close file
m_file.Close();
//
m_modify_flag=false;
}
else//create file
{
if(!m_file.Open(tmpfile,CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone))
{
m_edit_type=-1;//
AfxMessageBox(L"Create file failed!");
return;
}
m_file.Close();
//
m_modify_flag=true;//
}
//ini ui
if(m_playtable_data.GetCount()>0)
{
data=m_playtable_data.GetHead();
m_cur_pos=0; /////////
//
//type
m_type_combobox.SetCurSel(data.type);
//filename
m_cur_filename=data.filename;// _T("");
//share file
if(data.share_flag==1)
m_sharefile_flag=TRUE;
else
m_sharefile_flag=FALSE;
//action in
m_actionin_combobox.SetCurSel(data.in);
//action out
m_actionout_combobox.SetCurSel(data.out);
//speed
m_speed=data.speed;
//delaytime
m_delaytime=data.delaytime;
//postion
m_position_combobox.SetCurSel(data.position );
//
m_edit_type=2; //modify
//
m_cur_data=data;
}
switch(data.type)//txt,bmp
{
case 0://text
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(FALSE);
break;
case 1://pic
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;
case 2://animation
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;
case 3://video
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(L"PPPServer (Ver2.00) for wince.net-"+m_save_filename);
}
//
//update list...(all)
m_list.DeleteAllItems();
CString tmpstr;
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_list.InsertItem(i,TEXT("TEST2006"));
//#no
tmpstr.Format(L"#%d",i+1);
m_list.SetItemText(i,0,tmpstr);
//type
m_list.SetItemText(i,1,tmp_type_str[data.type] );
//#filename
m_list.SetItemText(i,2,data.filename);
//action in //action out
if(data.type<=1)
{
m_list.SetItemText(i,3,tmp_fun_in_str[data.in]);
m_list.SetItemText(i,4,tmp_fun_out_str[data.out]);
}
else
{
m_list.SetItemText(i,3,tmp_fun_in_str[MAX_ADD_SHOWWAY-1]);//
m_list.SetItemText(i,4,tmp_fun_out_str[MAX_ADD_SHOWWAY-2]);
}
//speed
tmpstr.Format(L"%d",data.speed);
m_list.SetItemText(i,5,tmpstr);
//delaytime
tmpstr.Format(L"%d",data.delaytime);
m_list.SetItemText(i,6,tmpstr);
}
//m_cur_pos==0
m_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 CPPPServerDlg::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(L"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 CPPPServerDlg::OnSaveasFile()
{
// TODO: Add your command handler code here
if(m_edit_type<0) return;
if(m_modify_flag&&MessageBox(L"The content has been modified,Are you sure to save it(Yes/No)?",
L"Save File",
MB_YESNO|MB_ICONQUESTION)==
IDYES)
{
//
OnSaveFile();
}
WCHAR chFilter[]=L"PlayTable Files(*.TAB)|*.TAB|All Files(*.*)|*.*||";
CFileDialog filedlg(false,_T("TAB"),NULL,OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY,chFilter);
filedlg.m_ofn.lpstrInitialDir=_T("\\");
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(L"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(L"PPPServer (Ver2.00) for wince.net-"+m_save_filename);
//其它不变
m_modify_flag=false;//
}
}
void CPPPServerDlg::OnCopyEdit()
{
// TODO: Add your command handler code here
if(m_edit_type<0) return;
if(m_cur_pos<0) return;
// CPlayTableData data;
//ZeroMemory(&data,sizeof(data));
//copy
POSITION pos = m_playtable_data.FindIndex(m_cur_pos);
m_share_playtable_data=m_playtable_data.GetAt(pos);
m_share_data_flag=true;
}
void CPPPServerDlg::OnCutEdit()
{
// TODO: Add your command handler code here
if(m_edit_type<0) return;
if(m_cur_pos<0) return;
CPlayTableData data;
//ZeroMemory(&data,sizeof(data));
//copy
POSITION pos = m_playtable_data.FindIndex(m_cur_pos);
m_share_playtable_data=m_playtable_data.GetAt(pos);
m_share_data_flag=true;
//delete
// if(m_edit_type<0) return;
//if(m_playtable_data.IsEmpty())
//{
// AfxMessageBox(L"The content has been empty!!!");
// return;
// }
pos=m_playtable_data.FindIndex(m_cur_pos);
m_playtable_data.RemoveAt(pos);
// if(m_cur_pos!=0)
// {
m_cur_pos--;
// }
//update ui
if(!m_playtable_data.IsEmpty())
{
pos=m_playtable_data.FindIndex(m_cur_pos);
data=m_playtable_data.GetAt(pos);
//show data
//TYPE
m_type_combobox.SetCurSel(data.type);
//FILE
m_cur_filename=data.filename;
//share file
if(data.share_flag==1)
m_sharefile_flag=TRUE;
else
m_sharefile_flag=FALSE;
//ACTION IN
m_actionin_combobox.SetCurSel(data.in);
//ACTION OUT
m_actionout_combobox.SetCurSel(data.out);
//SPEED
m_speed=data.speed;
//DELAY TIME
m_delaytime=data.delaytime;
//postion
m_position_combobox.SetCurSel(data.position);
//
switch(data.t
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -