0

I've been having some difficulties to understand and maybe you guys can help.

I have a project that uses CDialog and I've been trying to create a child window that retrieves some info from the main window ( the main/child windows have they're own classes), edits the content and sends the edited info back to the main window.

When I tried using CDialog::Create(), I wasn't able to use ANY of the controls on the child window. ( Example: Buttons are not responsive )

When I created the child window with DoModal() it backfired.. Buttons were responsive, and I had access to the child window's class functions, but when I tried to get the info from the main window class I was struck down with an appcrash. I have tried passing the CWnd manually but it still crashed.. (Could not retrieve the main window handle )

Any ideas on how can I create the child window while still having access to the main app's variables and to the child window's event handlers ?

EDIT: Ok, I finally found out what was the problem: I was using

CDialog *eTest = new CDialog; // Pointing to .. ?? .. yeah I hate myself for this
eTest->Create(IDD_EDIT_DIALOG, NULL);
eTest->ShowWindow(SW_SHOW);

Instead, I should of created the window like this:

CDialog *eTest = new CEditDialog(); //  Pointing to the dialog class
eTest->Create(IDD_EDIT_DIALOG, this);
eTest->ShowWindow(SW_SHOW);

Everything from the buttons to the data transfer seems to be working right now. I hope it can help someone as dumb as me in the future.

Nutterz
  • 42
  • 7
  • You only fixed half of the mistake. The type for eTest should be CEditDialog*. – ScottMcP-MVP Aug 16 '13 at 20:46
  • You are absolutely right, I found that out myself later that day but forgot to edit it here also, if it remained 'CDialog' I still wouldn't have been able to use the functions inside the main class. – Nutterz Aug 25 '13 at 09:17

0 Answers0