Enddialog on lost focus

Hi,

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.

uffe_thomassenAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
WM_KILLFOCUS should be the message you're looking for...
0
 
kakamnaCommented:
Overide KillFocus jkr is write
and
GetParentFrame()->DestroyWindow;
0
 
akalmaniCommented:
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.

Bye..
0
 
jkrCommented:
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!
0
 
uffe_thomassenAuthor Commented:
Hi,

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;
            }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.