Solved

Dialog-Based Application not responding!!!

Posted on 2001-06-10
7
183 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
string initialization in java 11 103
sum67 challenge 35 89
Problem to event 3 50
Thin secure Windows 10 5 49
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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

759 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

20 Experts available now in Live!

Get 1:1 Help Now