please notice model dialog and modeless dialog
if your dialog is modeless dialog you send message WM_CLOSE,it is ok to close the dialog
but your dialog is model dialog,so when dlg.DoModal() Run,the next language dlg.SendMessage(WM_CLOSE) would not run,unless you have press ok button on dlg,but if you press ok button,the dialog is already closed ,so the dlg,SendMessage(WM_CLOSE) is useless.