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

📄 dlgsendctrl.cpp

📁 网络文件传输,用于显示屏控制系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Dlgsendctrl.cpp : implementation file
//

#include "stdafx.h"
#include "ctrl.h"
#include "Dlgsendctrl.h"
#include "Dlgsendatt.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "pro_ser.h"
/////////////////////////////////////////////////////////////////////////////
// CDlgsendctrl dialog


CDlgsendctrl::CDlgsendctrl(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgsendctrl::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgsendctrl)
	//}}AFX_DATA_INIT
}


void CDlgsendctrl::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgsendctrl)
	DDX_Control(pDX, IDC_CHECK1, m_checkov);
	DDX_Control(pDX, IDC_DESTPATH, m_destpath);
	DDX_Control(pDX, IDC_LIST1, m_list);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgsendctrl, CDialog)
	//{{AFX_MSG_MAP(CDlgsendctrl)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
	ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
	ON_COMMAND(IDC_DLG22ADD, OnDlg22add)
	ON_COMMAND(IDC_DLG22ATT, OnDlg22att)
	ON_COMMAND(IDC_DLG22CLEAR, OnDlg22clear)
	ON_COMMAND(IDC_DLG22DLE, OnDlg22dle)
	ON_COMMAND(IDC_DLG22DOWN, OnDlg22down)
	ON_COMMAND(IDC_DLG22INSER, OnDlg22inser)
	ON_COMMAND(ID_DLG22UP, OnDlg22up)
	ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
	ON_COMMAND(IDC_RESEND, OnResend)
	ON_COMMAND(ID_MENUITEM32825, OnMenuitem32825)
//	ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgsendctrl message handlers

BOOL CDlgsendctrl::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	 
 	//m_list.SetExtendedStyle(LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT |LVS_EX_CHECKBOXES);
	m_list.SetExtendedStyle(LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT );
	m_list.InsertColumn(0,"序号");
	m_list.SetColumnWidth(0,50);
	m_list.InsertColumn(1,"状态");
	m_list.SetColumnWidth(1,90);
	m_list.InsertColumn(2,"开始时间");
	m_list.SetColumnWidth(2,80); 
	m_list.InsertColumn(3,"完成时间");
	m_list.SetColumnWidth(3,80);
	m_list.InsertColumn(4,"读路径");
	m_list.SetColumnWidth(4,480);
	m_list.InsertColumn(5,"大小");
	m_list.SetColumnWidth(5,60);
	m_list.InsertColumn(6,"写路径");
	m_list.SetColumnWidth(6,480);
	m_list.InsertColumn(7,"覆盖");
	m_list.SetColumnWidth(7,40);
	m_destpath.SetWindowText(add_destpath);
	bit_stop_threa=0;
	//m_list.InsertItem(0,"00"); 
	updatalist();
	 
//	add=(struct send_stru *)malloc(sizeof(struct send_stru));
	 		 	 
//	my=add;
//				::strcpy((char *)my->sour_path,sorpath[i]);
			  //	my->sour_path=sorpath[i];
//				::strcpy((char *)my->der_path,savepath);
			  //	my->der_path=savepath;				
//			 	my->sta=to_be_send;
//			 	my->send_mode=mode;
//				my->p_send_sock=psoc;
//				::strcpy((char *)my->ip_addr,strip);
			 //	my->ip_addr=strip;
//				::strcpy((char *)my->port,strport);
			 //	my->port=strport;				 
 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgsendctrl::OnButton1() //添加
{
	// TODO: Add your control notification handler code here
	 
	CFileDialog filedlg( TRUE,NULL, NULL,OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_OVERWRITEPROMPT, szFilter,  this ); 	  	 
	if(filedlg.DoModal()==IDOK)
	{
		add=(struct send_stru *)malloc(sizeof(struct send_stru));
		 memset(add,0,sizeof(send_stru));
		unsigned short pdat=1;
		CString str;
		CString m_upfilepath1=filedlg.GetPathName(); 	 
		if(head==NULL)
		{
			head=add;
		}
		else
		{
			my=head;	   	  
			while(my->next!=NULL)
			{	 
				my=my->next;
				pdat++;
			}	   
			pdat++;
			my->next=add;
		}
		add->pnum=pdat;
		add->sta=to_be_send;
        if(m_checkov.GetCheck())
		{			 
			add->send_mode=overwrite;
		}
		strcpy((char *)add->sour_path,m_upfilepath1);
		strcpy((char *)add->der_path,add_destpath);
        strcpy((char *)add->ip_addr,strip);
		strcpy((char *)add->port,strport);
        add->p_send_sock=psock;
		str.Format("%u",pdat);		 
		int item=m_list.InsertItem(pdat,str);
		CFile fil;
		fil.Open(m_upfilepath1,CFile::modeRead);
		 int len=fil.GetLength();
		 add->fil_len=len;
		 fil.Close();
		str=changsize(len);
		m_list.SetItemText(item,5,str);
		m_list.SetItemData(item,pdat);	 
		m_list.SetItemText(item,4,m_upfilepath1);
		m_list.SetItemText(item,1,"等待发送");
		m_list.SetItemText(item,6,add_destpath);
		add->next=NULL;
		updatalist();
	} 	 		  
}

void CDlgsendctrl::OnButton2() //插入
{
	// TODO: Add your control notification handler code here
	CFileDialog filedlg( TRUE,NULL, NULL,OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_OVERWRITEPROMPT, szFilter,  this ); 	  	 
	
	CString str;
	int getitem=m_list.GetSelectionMark();
	unsigned short getdat=(unsigned short)m_list.GetItemData(getitem);
	if(getdat)
	{	 
		if(filedlg.DoModal()==IDOK)
		{		 
			add=(struct send_stru *)malloc(sizeof(struct send_stru));
			 memset(add,0,sizeof(send_stru));
			CString m_upfilepath1=filedlg.GetPathName();
			add->pnum=getdat;
			add->sta=to_be_send;
			if(m_checkov.GetCheck())
			{				 
			  add->send_mode=overwrite;
			}
			strcpy((char *)add->sour_path,m_upfilepath1);
		    strcpy((char *)add->der_path,add_destpath);
			strcpy((char *)add->ip_addr,strip);
		    strcpy((char *)add->port,strport);
			add->p_send_sock=psock;
			str.Format("%u",getdat);
			int item=m_list.InsertItem(getdat,str);
			CFile fil;
		    fil.Open(m_upfilepath1,CFile::modeRead);
		    int len=fil.GetLength();
			add->fil_len=len;
		    fil.Close();
		    str=changsize(len);
		    m_list.SetItemText(item,5,str);
			m_list.SetItemData(item,getdat);
			m_list.SetItemText(item,4,m_upfilepath1);
			m_list.SetItemText(item,1,"等待发送");
			m_list.SetItemText(item,6,add_destpath);
			struct send_stru *buf;
		//	unsigned short pdat=1;
		//	CString str;			 
			if(getdat==1) 
			{
				my=head;
				add->next=head;	
				head->pnum++;
				if(my->next==NULL)
				{				    
				}
				else
				{
					//循环                       	  
				   while(my->next!=NULL)
				   {					    
					   my=my->next;
					   my->pnum++;
				   }		
				   
				}
				head=add; 
			}
			/*
			if(head==NULL)
			{
				//head=add;
			}
			*/
			else
			{
				my=head;	   	  
				while(my->next!=NULL)
				{					
					if((my->pnum)<getdat)
					{
						buf=my;						 
					}
					else if((my->pnum)==getdat)
					{
					//	CString st;
					//	st.Format("%x",getdat);
					//	::AfxMessageBox(st);
						/*
						if(getdat==1)
						{
							 head->pnum++;
							 add->next=head;
							 head=add;
						}
						else
						{
						*/
						buf->next=add;
						add->next=my;
						my->pnum++;
					//	}
					}
					else
					{
						my->pnum++;
					}
					my=my->next;
				}
				 
				if((my->pnum)<getdat)
					{
						buf=my;						 
					}
					else if((my->pnum)==getdat)
					{
						//CString st;
						//st.Format("%x",getdat);
						//::AfxMessageBox(st);
						buf->next=add;
						add->next=my;
						my->pnum++;
					}
					else
					{
						my->pnum++;
					}
				 
			}
		}
	}
	updatalist();
	//	add->next=NULL;
}

void CDlgsendctrl::OnButton3() //上移
{
	// TODO: Add your control notification handler code here
		CString str;
	int getitem=m_list.GetSelectionMark();
	unsigned short getdat=(unsigned short)m_list.GetItemData(getitem);
	struct send_stru *buf1;
     add=(struct send_stru *)malloc(sizeof(struct send_stru));
	 add->next=NULL;
	if(getdat==2)
	{		
		buf1=head->next;
		head->pnum++;
		buf1->pnum--;
		head->next=buf1->next;
		buf1->next=head;
		head=buf1;
	}
	else if(getdat>2)
	{	 		 		
			struct send_stru *buf=head;			
			if(head==NULL)
			{
				//head=add;
			}
			else
			{
				my=head;	   	  
				while(my->next!=NULL)
				{			 
					buf1=my->next;
					if((buf1->pnum)<getdat)
					{	
						buf=my;
						my=my->next;
					}
					else if((buf1->pnum)==getdat)
					{			
						my->pnum++;
						buf1->pnum--;
                        buf->next=buf1;
                        my->next=buf1->next;						
						buf1->next=my;    
						my=add;
					}				 
				}		 
			}		 
	}
		free(add);
	updatalist();
}

void CDlgsendctrl::OnButton4() //下移
{
	// TODO: Add your control notification handler code here
	CString str;
	int getitem=m_list.GetSelectionMark();
	unsigned short getdat=(unsigned short)m_list.GetItemData(getitem);
	struct send_stru *buf1;
     add=(struct send_stru *)malloc(sizeof(struct send_stru));
	 add->next=NULL;
	  
	if(getdat==1)
	{		
	  if((head->next)==NULL)
	  {
	  }
	  else
	  {
		  buf1=head->next;
		  head->pnum++;
		  buf1->pnum--;
		  head->next=buf1->next;
		  buf1->next=head;
		  head=buf1;           
	  }
	}
	else if(getitem)
	{	 		 		
			struct send_stru *buf=head;			
			if(head==NULL)
			{
				//head=add;
			}
			else
			{
				my=head;	   	  
				while(my->next!=NULL)
				{			 
					buf1=my->next;
					if((buf1->pnum)<getdat)
					{	
					//	buf=my;
						my=my->next;
					}
					else if((buf1->pnum)==getdat)
					{			
						if((buf1->next)==NULL)
						{
							my=add;
						}
						else
                        {
							buf=buf1->next;
				 
						buf1->pnum++;
						buf->pnum--;
                        my->next=buf;
						buf1->next=buf->next;
                        buf->next=buf1;
						my=add;
						}
					}				 
				}		 
			}		 
	}
	free(add);
	updatalist();
}

void CDlgsendctrl::OnButton5() //删除
{
		CString str;
	int getitem=m_list.GetSelectionMark(); 	 
	unsigned short getdat=(unsigned short)m_list.GetItemData(getitem);
 	 
//	add=(struct send_stru *)malloc(sizeof(struct send_stru));
	if(getdat)
	{
		struct send_stru *buf,*buf1;
    if(getdat==1)
	{		 
		 buf1=head;
		 head=head->next;	
		if(head==NULL)
		{			 
		}
		else
		{
		my=head;
		while(my->next!=NULL) 
		{		
			my->pnum--;
			my=my->next;
		}		 
		if(my->pnum!=1)
		{
           my->pnum--;	
		}
		}
	 //	free(buf1);
	}
	else
	{
		my=head;
        while(my->next!=NULL) 
		{			 
		//	my=my->next;	 
		    if((my->pnum)<getdat)
			{				
				buf=my;				 
			}
			else if((my->pnum)==getdat)
			{			   
				buf1=my;
				buf->next=my->next;
			}
			else

⌨️ 快捷键说明

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