Cannot access a child window's controls ( Created with CDialog::Create )

209 Views Asked by At

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.

0

There are 0 best solutions below