Catching activity outside dialog

I have a modeless dialog that I open up, and the user can then respond to a question by clicking somewhere inside the dialog.  If he clicks anywhere outside the dialog box, in any other window, I want the modeless dialog box to catch this and close down.  How do I do this?  I tried WM_KILLFOCUS but it doesn't seem to work.
ClausAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorbertCommented:
I Did the same using WM_ACTIVATE:
YourDialogBasedClass::OnActivate(UINT nState, CWnd* pWndOther, BOOL Minimized)
{
     CDialog::OnActivate(nState,pWndOther,Minimized);
     if(nState==WA_INACTIVE)
     {
          ShowWindow(SW_HIDE);//I did not close the dialog I only Hide it.
      }
      else
      {
         //don't know your needs may be
         UpdateData(FALSE)
      }
}
and this works great for me
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NorbertCommented:
if there are any problems I am sorry to say:
I am going into vacation today so you can reach me today or only next year -
if Internet still works after the change of the milenium :)

but as I said it works great for me so
I don't think that there is a problem.

BTW:
Normaly inside a dialog one of the controls laying on the dialog has the focus so the dialog does probably not get the killfocus message and if it got it you don't know is the focus killed because one of the dialog childs gets it or because you are clicking outside the dialog brobably with a lot of work it could be done checking each childs killfocus function and may be the position of the mouse or have a look wich window gets the focus now but WM_ACTIVATE is much more elegant and much less to do

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.