Solved

Dialog-Based Application not responding!!!

Posted on 2001-06-10
7
185 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 163
How to know only "File created" with EventLog 3 34
post4 challenge 28 102
mapBully challenge 6 136
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

832 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