Now encountered a problem, do you want to be a user to confirm function, current practice is to use MessageBox play box, confirm before issued, issued in another open thread,
But found that has been added to the MessageBox, frequently, click on the confirmation after Onreceive function is invoked, but in issued after the timeout after the failure (that is, sending) will receive the data, the log server, the server side is at the right time on the data sent, but just can't trigger, received after the last time send failure data correctly, because is the machine network, regardless of the network delay,
At first thought that the network has a problem, always can't find the reason, until accidentally dropped the prompt confirmation box code comments when it found the Onreceive function can be normal, so the feeling is MessageBox side out of the question,
T=MessageBox (this - & gt; GetSafeHwnd (), "confirmed distributed parameter?" ", "issued by parameters, MB_YESNO | MB_ICONWARNING);
If (t==IDNO) return;
So I don't know this situation caused by what, how should solve? Please help to have a look
CodePudding user response:
I also met you can change the controls in the interface Messagebox display information will pop up when you are not receive dataCodePudding user response:
You try to use afxmessageboxCodePudding user response:
Messafebox may affect the message loop, causing aocket color message also be affectedCodePudding user response:
I really need to decide whether issued according to user selection, so must have blocked here, do you have any other control can solve this problem?CodePudding user response:
Issued in another open thread is what mean?Attention should be paid to by default, the CAsyncSocket and CSocket object cannot be used across threads,
CodePudding user response:
After messageBox is the user to confirm, send function calls, function starting a thread in the distributed parameter, use the send,Thread will wait for a period of time (design here is 500 ms), during this period if the received data, mark position, exit the threads,
At the end of the waiting thread in sending function, using the waitforMultipleobjects, also set up a message loop to ensure the message is not blocked,
Waiting thread end is written so:
RefreshResult=AfxBeginThread (DownloadParaThread, (LPVOID) & amp; The index);
If (RefreshResult!=NULL)
{
DWORD dwRet=0;
MSG MSG.
While (TRUE)
{
DwRet=MsgWaitForMultipleObjects (1, & amp; RefreshResult - & gt; M_hThread, FALSE, INFINITE, QS_ALLINPUT);
If (dwRet==WAIT_OBJECT_0)
break;
Else if (dwRet==WAIT_OBJECT_0 + 1)
{
PeekMessage (& amp; MSG, NULL, 0, 0, PM_REMOVE);
DispatchMessage (& amp; MSG);
}
The else
break;
}
RefreshResult=NULL;
}
Intuitively sense is in after the send function call, the issuance of the Onreceive function cannot be triggered, but occasionally is triggered, would have not failed every time, but the probability of failure is large, but if the front MessageBox code will be deleted after Onreceive function can trigger normally, hence the positioning to MessageBox, how do you feel?
CodePudding user response:
And I just can't trigger when MessageBox exist, can trigger off after a MessageBox,CodePudding user response:
Advance the messageBox in other places, or in the interface in the UI thread processingCodePudding user response:
Oneself do a Modeless dialog box (create), no?CodePudding user response:
MessageBox processing after the end of the called function will start a thread, is feel MessageBox although by clicking OK or cancek ended behind but it will affect the thread's start,CodePudding user response:
I'm going to draw a dialog box, and then call DoModal, and see whether there is any problem,CodePudding user response:
Whether to call WM_CANCELMODE??Void CCancelModeDlg: : OnSetfocusEdit2 ()
{
if(! FindWindow (0, "yyy"))//change: AFX_IDS_APP_TITLE="yyy"
{
AfxMessageBox (" SetfocusEdit2 ");
William ouchi//this, the cursor is' I 'anywhere, means focus in edit2!!!!!!
//mouse has captured by edit2
M_Edit2. PostMessage (WM_CANCELMODE, 0, 0);
}
}
CodePudding user response:
Do it himself a dialog box, use DoModal () start, found Onreceive function or trigger has been delayed, don't know what meaning is WM_CANCELMODE??CodePudding user response:
The SUMMARYIn the Microsoft Windows graphical environment, the WM_CANCELMODE message informs a window that it should cancel any internal state. This message is sent to the window with the focus the when a dialog box or message box is displayed, giving the window the opportunity to cancel states to as mouse capture.
When a control has the focus, it receives a WM_CANCELMODE message When the EnableWindow function disables the control or the When a dialog box or a message box is displayed. When a control receives this message, it should cancel modes, to the as the mouse capture, and delete any timers it has created. A control must cancel these modes because an application may use a notification from the control to display a dialog box or a message box.
The DefWindowProc function The processes WM_CANCELMODE by calling The ReleaseCapture function, which cancels The mouse capture for whatever The window from The capture, The DefWindowProc function does not cancel any other modes.
CodePudding user response:
CAsyncSocket do infinite reentrant, avoid such MessageBox obstruction after you receive the new information led to countless MessageBox is pop up,You should reconsider the interface design, such as in the status bar or list view to display the information,
CodePudding user response:
"Front MessageBox code segment will be changed to" afxDump (ram) and have a lookCodePudding user response:
In the TRACECodePudding user response:
To summarize, because there is no good news pump, not put all of the information is passed to the message loop, a piece of code is as follows:While (TRUE)
{
//wait for m_hThread to be over, and wait for
//QS_ALLINPUT (Any message is in the queue)
DwRet=MsgWaitForMultipleObjects (1, & amp; CThread - & gt; M_hThread, FALSE, INFINITE, QS_ALLINPUT);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull