Solved

Dialog-Based Application not responding!!!

Posted on 2001-06-10
7
187 Views
Last Modified: 2013-11-20
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
Comment
Question by:hoandrew
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:webbingxia
ID: 6175831
hi hoandrew
could u show us the code ?
and u'd better not call AfxMessageBox at your thread
0
 

Author Comment

by:hoandrew
ID: 6175956
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
 
LVL 1

Expert Comment

by:webbingxia
ID: 6176033
there is nothing happen and the application hanged when your application is inactivated?

AND

Everything is ok when your application is "activated"?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
MadYugoslav earned 100 total points
ID: 6176051
Try to use PostMessage instead of SendMessage:
::PostMessage(main_hwnd, WM_SEND_CHECKALIVE_MSG, 0,0);
0
 

Author Comment

by:hoandrew
ID: 6176069
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
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6176124
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
 

Author Comment

by:hoandrew
ID: 6176495
That is the point?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 47
Change owner from userA to server Local Administrators 7 71
Best tools for Backup and restore of Wordpress site 6 58
MaxSpan challenge 9 122
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question