Nitheesh George answer is almost correct. You just need to create the dialog object dynamically, or make it member of a class, otherwise the dialog object will be detroyed as soon as you exit the function.
If you prefere to create the dialog dynamically, you can do something like:
CYourDialog* dlg = new CYourDialog();
dlg->Create(IDD_YOUR_DIALOG_ID, this);
dlg->ShowWindow(SW_NORMAL);
And to make sure you don't have memory leaks, you also have to delete the created dialog once it is not needed anymore. For example:
Add this inside your dialog .h file:
class CYourDialog
{
...
protected:
virtual void PostNcDestroy();
afx_msg void OnClose();
};
Add this inside your dialog .cpp file:
BEGIN_MESSAGE_MAP(CYourDialog, CDialog)
...
ON_WM_CLOSE()
END_MESSAGE_MAP()
...
void CYourDialog::PostNcDestroy()
{
CDialog::PostNcDestroy();
delete this;
}
void CYourDialog::OnClose()
{
CDialog::OnClose();
DestroyWindow();
}