MFC modeless dialog - showWindow not called

Hi Experts,
I wanted to trap the ShowWindow(false) call so that I could save the dialog's position in the registry - but the function is not getting called when we close it with the X.  What's the correct place to do this?

Who is Participating?
jkrConnect With a Mentor Commented:
I'd rather override 'OnClose()' for that purpose, since this is what handles 'WM_CLOSE' (the message that is sent when the window closes, regardless if it's via the 'X', 'OK' or 'Cancel'). I.e.

class CMyDialog : public CDialog

  void OnClose();

  // ...

// ...

void CMyDialog::OnClose()
  // save coordinates

  CDialog::OnClose(); // call base class handler

Open in new window

threadyAuthor Commented:
Merci beaucoup mon ami!
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.