Convert modeless dialogs to modal

-->

This is another simple way of converting a modeless dialog into a modal dialog.

While overriding the dialog's Create() call, get the pointer to the main frame window and disable it using EnableWindow() call.

BOOL CModelessDlg::Create( UINT nID, CWnd* pParentWnd )
{
	// TODO: Add your specialized code here and/or call the base class

	pParentWnd->EnableWindow(FALSE);//You can get pParentWnd by calling
	AfxGetMainWnd() also.
	return CDialog::Create(nID, pParentWnd);
}


Before destroying by "DestroyWindow()", call EnableWindow() to set it as TRUE.
void CModelessDlg::OnOK()
{
	// TODO: Add extra validation here
	...........
	..........
	.........

	AfxGetMainWnd()->EnableWindow();
	DestroyWindow();
}

IT Offers

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Go Deeper

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds