Let's face it : sometimes, I really feel as though the minds and powers of those famous industry experts lies in me, such as Jeff Prosise, Dino Esposito, Jeffrey Richter, and John Robbins.
In short : I am the man.

Now, I managed to solve this problem with a solution : create local pointers to achieve the creation of n-th number of modeless dialogs at run-time, and storing these pointers in a CArray template class so that I can access them later.

The code snippet is as follows :
Code:
//called when a push-button is clicked
void CManyDlgsDlg::OnCreatedlgs() 
{
	for(int i = 0; i < 10; i++)
	{
		CMyDialog* pDlg = new CMyDialog(this);
		m_arDlgs.Add(pDlg);
	}
}

//called when another push button is clicked.......basically, this part changes the window text of the first modeless dialog
void CManyDlgsDlg::OnChangetext() 
{
	m_arDlgs.GetAt(0)->SetWindowText("Hugo!");
}
m_arDlgs is declared as :
Code:
CArray<CMyDialog*, CMyDialog*> m_arDlgs;
where CMyDialog is my modeless dialog class.


When I run the program and click the buttons and such, I was expecting to get an Access Violation error, cos' u see, the local dialog pointers(pDlg) SHOULD ALL BE OUTTA SCOPE and be DESTROYED when the OnCreatedlgs() function ends, and when I try to access them in the OnChangeText() function, an Access Violation error should occur, cos' I'm trying to access something that's already invalid; gone outta scope; destroyed.

But INSTEAD........(I dunno why)........everything works as though they're in God's garden! Isn't this crazy! This is even more mysterious than the Bermuda Triangle! Crazy!

I would really appreciate it if anyone can gimme an explanation of why success occurs instead of failure.

Please and thanks a lot!
Xeon.