[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Dialog-Based Application not responding!!!

Hi All,

Now i am facing a strange question is that:
when my client dialog-based application start, a thread will be created to check the connection with the server. When the connection close is detected, i will alert user for connection closed using AfxMessageBox.

This approach doesn't work when my application is inactivated: The messagebox won't show up and my application hanged.

Are there any suggestions??

Thanks in advance.

0
hoandrew
Asked:
hoandrew
  • 3
  • 2
  • 2
1 Solution
 
webbingxiaCommented:
hi hoandrew
could u show us the code ?
and u'd better not call AfxMessageBox at your thread
0
 
hoandrewAuthor Commented:
Hi webbingxia,

Yeah, i know that i should not call AfxMessageBox in worker thread, but my approach is in the worker thread, i have signal the main thread using SendMessage(); for checking the connection between client app. and the server, so that the AfxMessageBox is called at the main thread.

/*In worker thread, notify the main thread to perform action*/
::SendMessage(main_hwnd, WM_SEND_CHECKALIVE_MSG, 0,0);

/* In main thread, this function is called when WM_SEND_CHECKALIVE_MSG is notified */
LRESULT COAGPCliDlg::OnSendCheckAliveMsg(UINT wParam, LONG lParam)
{
       if connection closed
     then call AfxMessgeBox("Connection closed.")
}

Any idea?
0
 
webbingxiaCommented:
there is nothing happen and the application hanged when your application is inactivated?

AND

Everything is ok when your application is "activated"?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
MadYugoslavCommented:
Try to use PostMessage instead of SendMessage:
::PostMessage(main_hwnd, WM_SEND_CHECKALIVE_MSG, 0,0);
0
 
hoandrewAuthor Commented:
Actually, i force the connection close happened by type the command "ipconfig /release" in cmd on window2000.

When the app. have noticed that the connection is closed, then The Messagebox is pop-up when the app. is ACTIVATE. But it doesn't work when the app. is INACTIVATE.

It is so annoying!!! Please Help!!

Thanks.
0
 
MadYugoslavCommented:
You need to move dialog box in foreground.
You may to do this with SetForegroundWindow() or
with SetWindowPos(&(CWnd::wndTop), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
0
 
hoandrewAuthor Commented:
That is the point?
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now