UINT server_thd (LPVOID p)
{
If ((ssocket=accept (listen_sock, (struct sockaddr *) & amp; Client_addr, & amp; IaddrSize))==INVALID_SOCKET)
{
//MessageBox (__T (" failed to create listening "))
}
While (1)
{
Res=recv (ssocket, MSG, 1024, 0);
MSG (res)='\ 0';
: : MessageBox (NULL, "Recv a File"), NULL, MB_OK);
CFileDialog DLG (FALSE);
DLG. M_ofn. HInstance=AfxGetInstanceHandle ();
DLG. M_ofn. LpstrFilter="All Files (*. *) | (*. *)".
DLG. M_ofn. LpstrFile=filename;
DLG. M_ofn. Flags & amp;=~ OFN_EXPLORER;
If (DLG) DoModal ()==IDOK)
{
CFile file (filename, CFile: : modeCreate | CFile: : typeBinary | CFile: : modeWrite);
}
}
}
Transmission TXT and excel file are no problem, PDF and MP4 file, save as dialog can't open, single step mode to enter
INT_PTR CFileDialog: : DoModal () function,
if (m_ofn hwndOwner!=NULL & amp; & : : IsWindowEnabled (m_ofn hwndOwner))
{
BEnableParent=TRUE;
: : EnableWindow (m_ofn hwndOwner, FALSE);
}
To: : EnableWindow (m_ofn hwndOwner, FALSE); Is stuck,
Mode output shows thread withdrew,
Thread 'Win32 threads (0 x1748) have withdrawn, the return value is zero (0 x0),
Thread 'Win32 threads (0 x1f14) have withdrawn, the return value is zero (0 x0),
Thread 'Win32 threads (0 x12fc) have withdrawn, the return value is zero (0 x0),
Thread 'Win32 threads (0 x1628) have withdrawn, the return value is zero (0 x0),
Ah, in asking great god answer puzzled me for a long time,
CodePudding user response:
In the thread function opens a dialog box, what a strange idea.CodePudding user response:
Like logic is also wrong,1 each receive 1024 bytes will save as a file, if sent by file bytes larger than 1024 to do,
2 filename is to save the file name. If the save dialog artificially modified file name a name can be a problem
3 to 2 floor
CodePudding user response:
In the second floor also have said, logic has a problem, the file size, good processing, you also too simple processing methodCodePudding user response:
Can't work in the open dialog box in the thread, this is wrong, no message loop in the worker thread processing, you can send window messages to the worker thread main thread, to do the work related to the UI, completes the synchronization between the thread processing,CodePudding user response: