Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialog Variable Passing Problem

Status
Not open for further replies.

ronnyjljr

IS-IT--Management
Nov 23, 2003
249
US
Ok here goes,

I have a dialog that when I select a button it creates another dialog, like this:

void CMRDlg::OnBnClickedCreatedatabase()
{
DBNameDlg NewDB;
NewDB.DoModal();
return;
}

In the NewDB Dialog when I clicked the submit button I want to call the CreateDatabase Function that is part of the original dialog, I have been trying to get this for a while and I have failed everytime.

This is as far as I have gotten:

void DBNameDlg::OnBnClickedCreatedb()
{
sDBName.GetWindowText(NewDBName);
CMRDlg old = this->GetParent();
old.CreateDatabase(NewDBName);
this->DestroyWindow();
}

Please tell me how to pass this variable page to the function =)

Any help is much obliged..
-Ron

/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
GetParent() won't work because the CMRDlg is not the parent window of the DBNameDlg.

Try storing a pointer to the CMRDlg as a member variable of the DBNameDlg class, and use it in the DBNameDlg instead of GetParent().
 
Ter,

Not Really Sure how to do that, do you have any example code?

Thanks,
Ron

/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
In the class declaration of DBNameDlg add this:

public:
CMRDlg *m_mainDlg;

Then in your button handler have this:

void CMRDlg::OnBnClickedCreatedatabase()
{
DBNameDlg NewDB;
NewDB.m_mainDlg = this;
NewDB.DoModal();
return;
}

Finally, in the DBnameDlg method, have this:

void DBNameDlg::OnBnClickedCreatedb()
{
sDBName.GetWindowText(NewDBName);
m_mainDlg->CreateDatabase(NewDBName);
this->DestroyWindow();
}
 
B E A UTIFUL, Thanks =)

/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top