No, It doesn't have to be before CDHtmlDialog::OnInitDialog();
It works even if you call after this line.