mfcinitializationcdialog

How to end a dialog mfc application from CDialog::OnInitDialog or immediately after this function ends?


In one case of my application, I want to end the application in the dialog's OnInitDialog or immediately after this function. Is there any way to do it?

I tried using windows messages – in OnInitDialog calling SendMessage and in the handler of the sent message calling OnClose – but it didn't do what I intended since the dialog still appeared.


Solution

  • PostQuitMessage(0) in the WM_INITDIALOG handler body will do the job.