⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pppclientdlg.cpp

📁 客户端: 这是一个完整的基于Wince 4.1图形图象,网络通讯(C/S)模式下的商用程序源代码包.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
   {   
	  // MessageBox(L"CTRL+ALT+F11 HOT KEY has been Registed",L"System Error",MB_OK|MB_ICONERROR);
	   //m_demo_hotkey_flag=false;
	   GlobalDeleteAtom(m_atom1);
	   	//再次 获取当前窗口句柄
    HWND handle = GetSafeHwnd();
	//显示主窗体
   // 如果没有存在于原子列表,则创建一个原子
    MY_DEMO_HOTKEY = GlobalAddAtom("Hotkey CTRL+ALT+F11"); 
    //注册全局热键Ctrl + Alt + F12
    if(RegisterHotKey(handle, MY_DEMO_HOTKEY, MOD_ALT|MOD_CONTROL, VK_F11))
		m_demo_hotkey_flag=true;
	else
		m_demo_hotkey_flag=false;
   }
    
    //create demo dialog
     BOOL bResult=m_demo_dlg.Create(IDD_DEMO_DIALOG,NULL);
	 ASSERT(bResult);	 
	 m_demo_dlg.ShowWindow(SW_HIDE);//SW_SHOW); 
	 m_show_demo_flag=false;//true;
	 //m_demo_dlg.ShowWindow(SW_SHOW); 
	 //m_show_demo_flag=true;
	 //
	 m_hSynEvent=CreateEvent(NULL,false,true,_T("PPPLayer2006"));
	 if(!m_hSynEvent) 
	 {
		 MessageBox("Create SynEvent failed","System Error",MB_OK|MB_ICONERROR);
	 }
	  //send set pos size message	
	 m_main_dlg->m_demo_dlg.SetPosSize(m_system_para.m_show_startx,
		                               m_system_para.m_show_starty,
		                               m_system_para.m_show_width,
									   m_system_para.m_show_height,
									   m_show_demo_flag);
	 
//	if(m_system_para.m_auto_run_flag==1)
//	{
//		PostMessage(WM_AUTORUN,(WPARAM)m_system_para.m_autorun_tabfile,0); 
//	}
	 m_startup_dlg.ShowWindow(SW_HIDE); 
	 m_startup_dlg.DestroyWindow(); 
	ShowMessage("System Ready.");
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CPPPClientDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	// 截获系统菜单关闭消息
	
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else if ((nID & 0xFFF0)==SC_CLOSE)///!!!
	{
        PostMessage(WM_CLOSE);///
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CPPPClientDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CPPPClientDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CPPPClientDlg::OnExitFile() 
{
	// TODO: Add your command handler code here
	PostMessage(WM_CLOSE);
	//EndDialog(0);
}

void CPPPClientDlg::OnAbout() 
{
	// TODO: Add your command handler code here
	CAboutDlg m_dlg;
	m_dlg.DoModal();
}
void CPPPClientDlg::ShowMessage(CString mess)
{	
	
    CString tmp_str;
	CTime m_time=CTime::GetCurrentTime();
	
	tmp_str.Format("[%04d-%02d-%02d %02d:%02d:%02d]:",
		m_time.GetYear(),m_time.GetMonth(),m_time.GetDay(),
		m_time.GetHour(),m_time.GetMinute(),m_time.GetSecond());
	
	//strcat(tmp_str,mess);
	if(m_mess_list.GetCount()<1000)
	{
		m_mess_list.AddString(tmp_str+mess);
	}
	else
	{
		m_mess_list.DeleteString(0);
		m_mess_list.AddString(tmp_str+mess);
	}
	//
	m_mess_list.SetCurSel(m_mess_list.GetCount()-1);
	
}
//设置按纽的有效性
void CPPPClientDlg::SetControlEnable(bool value)
{
	//输入控件的有效性
    ((CComboBox *)GetDlgItem(IDC_TYPE_COMBO))->EnableWindow(value);
	((CComboBox *)GetDlgItem(IDC_ACTIONIN_COMBO))->EnableWindow(value);
	((CComboBox *)GetDlgItem(IDC_ACTIONOUT_COMBO))->EnableWindow(value);
	//SHARE FILE
	GetDlgItem(IDC_SHAREFILE_CHECK)->EnableWindow(value);
	//OPEN
	((CButton *)GetDlgItem(IDC_OPENFILE_BUTTON))->EnableWindow(value);
	((CEdit *)GetDlgItem(IDC_CURFILENAME_EDIT))->EnableWindow(value);
	
	//SPEED
	((CEdit *)GetDlgItem(IDC_SPEED_EDIT))->EnableWindow(value);
	((CSpinButtonCtrl *)GetDlgItem(IDC_SPEED_SPIN))->EnableWindow(value);
	//DELAYTIME
    ((CEdit *)GetDlgItem(IDC_DELAYTIME_EDIT))->EnableWindow(value);
	((CComboBox *)GetDlgItem(IDC_POSITION_COMBO))->EnableWindow(value);
	//
	((CSpinButtonCtrl *)GetDlgItem(IDC_DELAYTIME_SPIN))->EnableWindow(value); 
	//设置指针移动按纽的有效性
      ((CButton*) GetDlgItem(IDC_FIRST_BUTTON))->EnableWindow(!value);
	  ((CButton*) GetDlgItem(IDC_PREV_BUTTON))->EnableWindow(!value);
	  ((CButton*) GetDlgItem(IDC_NEXT_BUTTON))->EnableWindow(!value);
	  ((CButton*) GetDlgItem(IDC_LAST_BUTTON))->EnableWindow(!value);
	//设置操作按纽的有效性
	  ((CButton*) GetDlgItem(IDC_APPEND_BUTTON))->EnableWindow(!value);
	  ((CButton*) GetDlgItem(IDC_INSERT_BUTTON))->EnableWindow(!value);
	  ((CButton*) GetDlgItem(IDC_DELALL_BUTTON))->EnableWindow(value);
	  ((CButton*) GetDlgItem(IDC_SAVE_BUTTON))->EnableWindow(value);
	  ((CButton*) GetDlgItem(IDC_CANCEL_BUTTON))->EnableWindow(value);
	  ((CButton*) GetDlgItem(IDC_DELONE_BUTTON))->EnableWindow(value);

}
	//设置指针移动按纽的有效性
void CPPPClientDlg::SetNavigatorButton(int value)
{
	 //<2
	if(m_playtable_data.GetCount()<2)
	{
      ((CButton*) GetDlgItem(IDC_FIRST_BUTTON))->EnableWindow(FALSE);
	  ((CButton*) GetDlgItem(IDC_PREV_BUTTON))->EnableWindow(FALSE);
	  ((CButton*) GetDlgItem(IDC_NEXT_BUTTON))->EnableWindow(FALSE);
	  ((CButton*) GetDlgItem(IDC_LAST_BUTTON))->EnableWindow(FALSE);
	  
	}
	//指针移动首部
	if(value==0)
	{
       ((CButton*) GetDlgItem(IDC_FIRST_BUTTON))->EnableWindow(FALSE);
	   ((CButton*) GetDlgItem(IDC_PREV_BUTTON))->EnableWindow(FALSE);
	   if(m_playtable_data.GetCount()>=2)
	   {
        ((CButton*) GetDlgItem(IDC_NEXT_BUTTON))->EnableWindow(!FALSE);
		((CButton*) GetDlgItem(IDC_LAST_BUTTON))->EnableWindow(!FALSE);
	   }
	}//指针移动尾部
	else if(value==m_playtable_data.GetCount()-1)
	{
     ((CButton*) GetDlgItem(IDC_LAST_BUTTON))->EnableWindow(FALSE);
	 ((CButton*) GetDlgItem(IDC_NEXT_BUTTON))->EnableWindow(FALSE);
     if(m_playtable_data.GetCount()>=2)
	   {
        ((CButton*) GetDlgItem(IDC_FIRST_BUTTON))->EnableWindow(!FALSE);
		((CButton*) GetDlgItem(IDC_PREV_BUTTON))->EnableWindow(!FALSE);
	   }
	}
	else//指针移动列表中间
	{
      
        ((CButton*) GetDlgItem(IDC_FIRST_BUTTON))->EnableWindow(!FALSE);
		((CButton*) GetDlgItem(IDC_NEXT_BUTTON))->EnableWindow(!FALSE);	   
        ((CButton*) GetDlgItem(IDC_PREV_BUTTON))->EnableWindow(!FALSE);
		((CButton*) GetDlgItem(IDC_LAST_BUTTON))->EnableWindow(!FALSE);
	   
	}

}

void CPPPClientDlg::OnNewFile() 
{
	// TODO: Add your command handler code here	
	CFileDialog filedlg(TRUE,_T("TAB"),NULL,OFN_HIDEREADONLY,TEXT("PlayTable Files(*.TAB)|*.TAB|All Files(*.*)|*.*||"));
	filedlg.m_ofn.lpstrInitialDir=GetCurDir();//_T("\\");  
	filedlg.m_ofn.lpstrTitle=TEXT("New TAB File"); 
	if(filedlg.DoModal()==IDOK)
	{
	 m_save_filename=filedlg.GetPathName();	
	 SetWindowText(TEXT("PPPClient(Ver2.01)-")+m_save_filename);
	 //
	 //new 	  
	
//   m_item_list.ResetContent();
	 //stop all demo
     m_all_run_flag=false;
	 
	 //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 ,insert
	 //clear data
	 m_cur_pos=-1;
     m_playtable_data.RemoveAll();
	 //
	 m_edit_type=0;//Append
     SetControlEnable(FALSE);
	 SetNavigatorButton(m_cur_pos);
	 UpdateData(FALSE);
	 //Update list
	 //clear item list
	 m_item_list.DeleteAllItems();
	 //
	 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);

	 //
	 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);

	}
}

void CPPPClientDlg::OnOpenFile() 
{
	// TODO: Add your command handler code here
	CFileDialog filedlg(TRUE,_T("TAB"),NULL,OFN_HIDEREADONLY,TEXT("PlayTable Files(*.TAB)|*.TAB|All Files(*.*)|*.*||"));
	filedlg.m_ofn.lpstrInitialDir=GetCurDir();//_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();
	 //stop all demo
	 m_all_run_flag=false;

	 //type
	 m_type_combobox.SetCurSel(0);
	 //share file
	m_sharefile_flag=FALSE;
	 //filename
	 m_cur_filename=_T("");
	 //action in
	 m_actionin_combobox.SetCurSel(0);
	 //action out
	 m_actionout_combobox.SetCurSel(0);
	 //speed
	 m_speed=10;
	 //delaytime
	 m_delaytime=1000;
	 //position
	 m_position_combobox.SetCurSel(2);
	 //
	 m_edit_type=0;//append ,insert
	 //clear data
	 m_cur_pos=-1;///////////

     m_playtable_data.RemoveAll();
	 //
	 //
	 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);

	 //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(TEXT("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);
	   //share file
	   if(data.share_flag==1)
         m_sharefile_flag=TRUE;
	   else
	     m_sharefile_flag=FALSE;
	   //filename
	   m_cur_filename=data.filename;// _T("");
	   //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; 
	   //position
	   m_position_combobox.SetCurSel(data.position);
		//	 
		m_edit_type=2; //modify
		//
		m_cur_data=data;
	 }
     
	 
	 switch(data.type)//txt,bmp
			{
	            case 0://text
            	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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -