Enddialog on lost focus

Posted on 2000-04-11
Last Modified: 2011-04-14

I want close a dialogwindow, when I click outside the dialog window's area.

Iam not using MFC.

Should I use Modal or Modeless Dialog windows.

In which WM_????? should put in EndDialog/DestroyWindow.

Question by:uffe_thomassen
LVL 86

Accepted Solution

jkr earned 100 total points
ID: 2704435
WM_KILLFOCUS should be the message you're looking for...

Expert Comment

ID: 2704675
Overide KillFocus jkr is write

Expert Comment

ID: 2706517
Hi !!
    Both Jkr and kakamna are right but regarding Modal or Modeless u can
1) Modal dialog --> It does not give the user to click outside until the user clicks on OK button or Cancel or Esc key.
2) Modeless dialog --> It gives the user to click outside the dialog and there as they said u can trap OnKillFocus() and do the end Dialog.
   See which can be best suited for u r requirement.

LVL 86

Expert Comment

ID: 2707598
kakanma - it is *NOT* proper expert protocol to post answers other users have posted as comments.

Please *unlock* the question and refrain from this behaviour in the future!

Author Comment

ID: 2711208

I found the solution, perhaps I didn´t explain, my problem precisly. I use a Modeless dialog, but Instead of acting WM_KILLFOCUS, I use:
      case WM_ACTIVATE:
            if((BOOL)LOWORD(wParam) == WA_INACTIVE) {
                  DestroyWindow (hWnd);
                  g_nhWnd =0;
                  return TRUE;

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

937 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

10 Experts available now in Live!

Get 1:1 Help Now