Cdialog CWnd* pParent null after passing this pointer to Cdialog constructer
-
I have a modeless dialog from which I display to two modal dialog boxes one after the other I would like to save all the information I get from the two in the modeless dialog So my plan was when creating the modal dialog box pass the Cwnd pointer using the this pointer Well the first one seems to work by this I mean make breakpoint
abendialog = new RTMDialog(mylparam,this);
at the creation of the object and then at the contructor
RTMDialog::RTMDialog(LPARAM mylparam, CWnd* pParent)
: CDialog(IDD_DIALOG9, pParent)at this pParent has valid pointer In this dialog I create a second modal dialog
void RTMDialog::Percolate()
{
CMypercolate DOPREC(this);
DOPREC.DoModal();
}here too the this pointer is valid however when I get to this constructer pParent is null
CMypercolate::CMypercolate(CWnd* pParent /*=NULL*/)
: CDialog(IIDD_MYPERCOLATE, pParent)
{ -
I have a modeless dialog from which I display to two modal dialog boxes one after the other I would like to save all the information I get from the two in the modeless dialog So my plan was when creating the modal dialog box pass the Cwnd pointer using the this pointer Well the first one seems to work by this I mean make breakpoint
abendialog = new RTMDialog(mylparam,this);
at the creation of the object and then at the contructor
RTMDialog::RTMDialog(LPARAM mylparam, CWnd* pParent)
: CDialog(IDD_DIALOG9, pParent)at this pParent has valid pointer In this dialog I create a second modal dialog
void RTMDialog::Percolate()
{
CMypercolate DOPREC(this);
DOPREC.DoModal();
}here too the this pointer is valid however when I get to this constructer pParent is null
CMypercolate::CMypercolate(CWnd* pParent /*=NULL*/)
: CDialog(IIDD_MYPERCOLATE, pParent)
{Hardly surprising the question you need to ask yourself as a learning exercise What is difference between instantiating an object using new vs. without AKA there is a difference between these two things abendialog = new RTMDialog(mylparam,this); CMypercolate DOPREC(this); The hint is where is the object put in the two different cases? Hmmm your into your mutitasking so what is wrong with this which is the same thing
void SomeCreateCall (void){
char[256] data;
CreateThread(NULL, 0, SomeThreadFunction, (LPVOID)&data, 0, NULL);
}The variable data above is obviously valid to pass so whats the problem and whats the fix?
In vino veritas
-
Hardly surprising the question you need to ask yourself as a learning exercise What is difference between instantiating an object using new vs. without AKA there is a difference between these two things abendialog = new RTMDialog(mylparam,this); CMypercolate DOPREC(this); The hint is where is the object put in the two different cases? Hmmm your into your mutitasking so what is wrong with this which is the same thing
void SomeCreateCall (void){
char[256] data;
CreateThread(NULL, 0, SomeThreadFunction, (LPVOID)&data, 0, NULL);
}The variable data above is obviously valid to pass so whats the problem and whats the fix?
In vino veritas
-
Correct pretty sure same thing is going to happen with your code, I wouldn't hold the dialog on the stack on a modeless dialog. It's pretty dangerous to do, hold it as local data in the first dialog or on the heap same as you would on a multitask code :-)
In vino veritas