Solved

Dialog-Based Application not responding!!!

Posted on 2001-06-10
7
184 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 106
repeatSeparator  java  challenge 13 56
Problem to event 3 75
how to use laptop or pad camera in vb.net windows application 2 45
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

929 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now