多谢
解决方案 »
- 关于mfc分割窗口文档和视图
- 如何对另外一程序进行操作?如打开记事本的About Notepad这个按钮
- 请高手进来指点一二: 怎么用系统找不到的资源ID?
- 能不能不写代码实现程序启动任务栏图标的隐藏啊,
- 使用CSocket 进行create的问题
- 一个关于二进制文件问题?
- 高分求TAPI源代码。
- 菜单和对话框是否只能一一对应呢?两个对话框公用一个菜单行不行?
- 怎样在对话框中使用工具栏?
- Windows2000 Advanced Server 有中文版吗?
- 类似CButton* p = (CButton*)GetDlgItem(IDC_BUTTON1);p指向的对象是什么时候生成的?
- 结构化存储的及时刷新问题?why?
要将它转换为CString类型。首先你要确认发送过来的是CString类型数据,然后接收:
CString str = *(CString*)lParam;
......
BOOL CFtpListDialog::DownLoadFiles(LPVOID lParam)
{
CString temp_ftp_name = (LPTSTR)lParam;
AfxMessageBox(temp_ftp_name);
........
显示为乱码
void CFtpListDialog::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int i;
CString str_Filename;
if (( i =m_SerListFile.GetSelectedCount()) == 0)
return;
POSITION iPos = m_SerListFile.GetFirstSelectedItemPosition();
for (int j = 0 ;j< i; j++)
{
int nItem=m_SerListFile.GetNextSelectedItem(iPos);
str_Filename = m_SerListFile.GetItemText(nItem,0); AfxMessageBox(str_Filename);
}
//CWinThread * dl_thread = AfxBeginThread(::DownLoadFunction, this);
if(!DownLoadFiles(str_Filename))
AfxMessageBox("建立文件发送线程出错");
*pResult = 0;
}BOOL CFtpListDialog::DownLoadFiles(CString sz_filename)
{
//CString *temp_ftp_name = (CString *)lParam;
//AfxMessageBox(*temp_ftp_name);
if (m_pReceiveFileThread)
{
::WaitForSingleObject(m_pReceiveFileThread->m_hThread,100);
//AfxMessageBox("Thread end");
delete m_pReceiveFileThread;
m_pReceiveFileThread=NULL;
}
if (m_pReceiveFileThread = AfxBeginThread(::DownLoadFunction, sz_filename,THREAD_PRIORITY_ABOVE_NORMAL,
0,CREATE_SUSPENDED,NULL))
{
m_pReceiveFileThread->m_bAutoDelete=FALSE;
m_pReceiveFileThread->ResumeThread();
//AfxMessageBox("Thread start");
return TRUE;
}
else
return FALSE;}UINT DownLoadFunction(LPVOID lParam)
{
CString temp_ftp_name = *(CString*)lParam;
AfxMessageBox(temp_ftp_name);
/*CInternetSession Cis;
CFtpConnection* m_Ftp_Conn;
try {
m_Ftp_Conn = Cis.GetFtpConnection(szFtpName,szFtpUser,szFtpPassword);
m_Ftp_Conn->SetCurrentDirectory(sz_Path);
CInternetFile* ifp = m_Ftp_Conn->OpenFile(temp_ftp_name);
}
catch (CInternetException* pEx)
{
}*/
return 0;
}
传递全局内存的句柄吧.
0,CREATE_SUSPENDED,NULL))UINT DownLoadFunction(LPVOID lParam)
{
CString temp_ftp_name = (LPCTSTR)lParam;
AfxBeginThread(::DownLoadFunction, this);--->你的DownLoadFunction函数的传递的内容是那个啊???》》
0,CREATE_SUSPENDED,NULL))
不行,编译报错
0,CREATE_SUSPENDED,NULL))
要不就
AfxBeginThread(::DownLoadFunction, (lparam)(&sz_filename),THREAD_PRIORITY_ABOVE_NORMAL,
0,CREATE_SUSPENDED,NULL))
{
// TODO: Add your control notification handler code here
int i;
CString str_Filename;
if (( i =m_SerListFile.GetSelectedCount()) == 0)
return;
POSITION iPos = m_SerListFile.GetFirstSelectedItemPosition();
for (int j = 0 ;j< i; j++)
{
int nItem=m_SerListFile.GetNextSelectedItem(iPos);
str_Filename = m_SerListFile.GetItemText(nItem,0); AfxMessageBox(str_Filename);
}
//CWinThread * dl_thread = AfxBeginThread(::DownLoadFunction, this);
if(!DownLoadFiles(str_Filename))
AfxMessageBox("建立文件发送线程出错");
*pResult = 0;
}BOOL CFtpListDialog::DownLoadFiles(CString sz_filename)
{
//CString *temp_ftp_name = (CString *)lParam;
AfxMessageBox(sz_filename);
if (m_pReceiveFileThread)
{
::WaitForSingleObject(m_pReceiveFileThread->m_hThread,100);
//AfxMessageBox("Thread end");
delete m_pReceiveFileThread;
m_pReceiveFileThread=NULL;
}
//if (m_pReceiveFileThread = AfxBeginThread(::DownLoadFunction,(LPCTSTR)sz_filename,THREAD_PRIORITY_ABOVE_NORMAL,
//0,CREATE_SUSPENDED,NULL))
if (AfxBeginThread(::DownLoadFunction, (LPVOID)(&sz_filename), THREAD_PRIORITY_ABOVE_NORMAL,
0,CREATE_SUSPENDED,NULL))
{
m_pReceiveFileThread->m_bAutoDelete=FALSE;
m_pReceiveFileThread->ResumeThread();
//AfxMessageBox("Thread start");
return TRUE;
}
else
return FALSE;}UINT DownLoadFunction(LPVOID lParam)
{
CString temp_ftp_name = (LPCTSTR)lParam; AfxMessageBox(temp_ftp_name); return 0;
}