Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

808 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