troubleshooting Question

How do I re-enable a button in a modeless dialog to the calling dialog

Avatar of JPM2002
JPM2002 asked on
System Programming
2 Comments1 Solution383 ViewsLast Modified:
I have created a modal dialog the in turn creates a modeless dialog.  However I don't want the user to exit the modal dialog or create a duplicate modeless dialog unless he/she first closes the modeless dialog.

  I have disabled the Cancel and the create modeless button in the modal dialog, but when I close the modeless dialog my code that is in the OnCancel event in the modeless dialog gives me an assertion error.... specifically the pButton->EnableWindow(TRUE).
CSUADlg* mSUAModeless;
mSUAModeless = new CSUADlg();
if (mSUAModeless != NULL)
   // disable the 2 buttons that exit the modal dialog and exit button 
    CWnd* pButton;
   pButton = GetDlgItem(IDC_PB_VIEW);
   pButton = GetDlgItem(IDCANCEL);
   if (mSUAModeless-> Create(IDD_SUA_DLG, this) == TRUE)
   MessageBox("Error in Creating Dialog", MB_OK);
// code inside my modeless dialog
void CSUADlg::OnCancel()
     CWnd* pButton;
     pButton = GetDlgItem(IDC_PB_VIEW);
    pButton->EnableWindow(TRUE);           // THIS IS WHAT ERRORS OUT
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros