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

📄 filesenddlg.cpp

📁 一个采用VC编写的
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CFilesendDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	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 CFilesendDlg::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 CFilesendDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CFilesendDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void CFilesendDlg::OnBtliulan() 
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(true);
	if(dlg.DoModal()==IDOK)//如果测试到键被按下,则执行如下程序:
	{
		//sprintf(buffer+L+12,"%s",dlg.GetFileName());
		m_filename=dlg.GetPathName();
		UpdateData(false);//变量向控间复职
	}
	UpdateData(true);
	if(m_rate==0)
	{
		m_send.EnableWindow(0);
		m_stop.EnableWindow(0);
	}
	else
	{
		m_send.EnableWindow(1);
		m_stop.EnableWindow(0);
	}
}

void CFilesendDlg::OnBtlistadd() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
				
	if(m_filename=="")
	{
		AfxMessageBox("请先填入要添加的文件!");
		return;
	}
	if(m_filelist.GetCount()>=34)
	{
		AfxMessageBox("超出文件个数");
		return;
	}
	if((m_filelist.FindStringExact(-1,m_filename)!=LB_ERR))
	{
		AfxMessageBox("文件已经存在!"); 
		return;
	}
	
	m_filelist.AddString(m_filename);
	m_filename.Empty();
}

void CFilesendDlg::OnBtlistdelete() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);	
	if(m_filelist.GetCount()==0)
	{
		AfxMessageBox("请添加一个文件!");
		return;
	}
	if(m_filelist.GetCurSel()==LB_ERR)
	{
		AfxMessageBox("未选择文件!");
		return;
	}
	m_filelist.DeleteString(m_filelist.GetCurSel());
}

void CFilesendDlg::OnBtsend() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	file_num=m_filelist.GetCount();	//获取文件的个数
	if(file_num==0)
	{
		AfxMessageBox("未添加任何文件。");		
		return;
	}
	int temp;//定义temp的循环来给文件数组添加文件名
	for(temp=0;temp<file_num;temp++)
	{	
		m_filelist.GetText(temp,filename[temp]);
	} 
	while(temp<MAX_FILE_NUM)
	{
		filename[temp]="";
		temp++;
	}

	rate=m_rate;
	//UpdateData(FALSE);    //设定速率
	
	for(temp=0;temp<file_num;temp++)
	{
		fileid[temp]=temp;
	}
	while(temp<MAX_FILE_NUM)
	{	
		fileid[temp]=0;
		temp++;
	}
	
	m_send.EnableWindow(0);
	m_stop.EnableWindow(1);
	
	HWND hwnd=GetSafeHwnd();//获得一个句柄值
	AfxBeginThread(filefasong,hwnd,THREAD_PRIORITY_NORMAL);//进入线程
}
void  CFilesendDlg::filetotalpacket(WPARAM wParam,LPARAM lParam) 
{	
	long int k;//定义局部变量来存储文件大小,并转换为包数
	int temp;
	WIN32_FIND_DATA  FindFileData;
	for(temp=0;temp<file_num;temp++)
	{
		FindClose(FindFirstFile(filename[temp],&FindFileData));//根据文件的路径名MidString查找源文件的信息,                                                   //并把结果放到FindFileData中
		k=FindFileData.nFileSizeLow;
		totalpacket[temp]=k/L+1;  //这样就把每个文件的总包数存储进了数组中
	}
}
void CFilesendDlg::filesendpacket(WPARAM wParam,LPARAM lParam) 
{	
	sprintf(ch1,"%d",num);
	sprintf(ch2,"%d",ts_sendpacket);
	 
	m_packetsend.Empty();
	m_packetsend="文件";
	m_packetsend+=ch1;
	m_packetsend+="当前传送包:";
	m_packetsend+=ch2;//m_FilePath对应的控件中显示字符串“【文件发送中…】当前传送包:XX”
	m_packetsend+="\r\n";                  //(XX代表m_PacketSerialNum的值)
	m_beizhu.SetWindowText(m_packetsend);

	//UpdateData(false);
}
void CFilesendDlg::cardinitfail(WPARAM wParam,LPARAM lParam) //卡初始化失败调用的消息
{  	
	m_beizhu.SetWindowText("\r\n发送卡初始化失败!\r\n");
	m_send.EnableWindow(1);
	m_stop.EnableWindow(0);
} 
void CFilesendDlg::cardinitsuccess(WPARAM wParam,LPARAM lParam) //卡初始化成功调用的消息
{  	
	

	m_beizhu.SetWindowText("发送卡初始化成功!");	

	m_send.EnableWindow(0);
	m_stop.EnableWindow(1);
} 
void CFilesendDlg::cardtraminit(WPARAM wParam,LPARAM lParam)
{
	m_beizhu.SetWindowText("发送前初始化失败!\r\n");
	m_send.EnableWindow(1);
	m_stop.EnableWindow(0);
}
/*void CFilesendDlg::cardtranmitsuccess(WPARAM wParam,LPARAM lParam)
{       
		CString stri_sendpacket="\r\n已经发送:";
		_itoa(yijingfasong,ch3,10);
		stri_sendpacket+=ch3;
		stri_sendpacket+="\r\n";
		m_beizhu.SetWindowText(stri_sendpacket);
	    m_send.EnableWindow(0);
		m_stop.EnableWindow(1);		
}*/
void CFilesendDlg::cardtranmitfail(WPARAM wParam,LPARAM lParam)
{   
		m_beizhu.SetWindowText("\r\n发送失败!\r\n");
	    m_send.EnableWindow(1);
		m_stop.EnableWindow(0);//	m_liulan.EnableWindow(1);	
}
void CFilesendDlg::cardend(WPARAM wParam,LPARAM lParam)
{ 
	    bst_stop_transmit(cardnumber);
		bst_fini(cardnumber);
		m_send.EnableWindow(1);
		m_stop.EnableWindow(0);
		m_beizhu.SetWindowText("\r\n已停止发送!\r\n");
}

void CFilesendDlg::OnBtstop() 
{
	// TODO: Add your control notification handler code here
	stop=TRUE;
}
/*void CFilesendDlg::pbufferwrite(WPARAM wParam,LPARAM lParam)
{
            
				CFile pbufferfile("e:\\pbuffer",CFile::modeReadWrite); 
				pbufferfile.SeekToEnd();
				pbufferfile.Write(pbuffer,24064);
				pbufferfile.Close();

}*/

void CFilesendDlg::OnBtuclinfo() 
{
	// TODO: Add your control notification handler code here
	int temp;
		if(m_filelist.GetCurSel()==LB_ERR)
	{
		AfxMessageBox("未选择文件!");
		return;
	}
	temp=m_filelist.GetCurSel();

	m_filelist.GetText(temp,filename[temp]);
	CUclDlg ucldlg;
	ucldlg.m_fileaddr=filename[temp];
	ucldlg.DoModal();
}

⌨️ 快捷键说明

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