OnInitDialog.
1. You will have to move the window in the OnInitDialog of CMainDialog.
You
can call GetParent()->GetWindowRect() and then Offset the rect a little
and
call SetWindowPos to move the window.
BOOL CMainDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd *pParent = GetParent();
if (pParent)
{
CRect Rect;
pParent->GetWindowRect(&Rect);
Rect.OffsetRect(5,5);
SetWindowPos(NULL,Rect.left,Rect.top,0,0,SWP_NOZORDER|SWP_NOSIZE);
}
}
As far as number 2 goes, you guess is as good as mine.
Maybe the user is double clicking somehow which calls StartNewDialog()
twice, and since the dialog is modal it opens one and when it is closed
StartNewDialog() gets called again.
AliR.
"Donos" <donguy76@gmail.com> wrote in message
news:17756fbe-792b-43fa-ace9-d39476ad30a0@27g2000hsf.googlegroups.com...
There is a class derived from CDialog,
CMainDialog::CDialog
Now with in this class there is a function,
void CMainDialog::StartNewDialog()
{
CMainDialog m_MainDlg;
m_MainDlg.DoModal();
}
Here nother instance of CMainDialog is opened. So once this is
executed, right now there are 2 CMainDialog dialogs open.
There are 2 issues thats coming up in this scenario.
1. When the 2nd CMainDialog is opened, it gets opened right
on top of 1st CMainDialog. I think this is because of default
window positioning.
How to make sure that 2nd CMainDialog opens a bit away
from the 1st dialog, so that USER can see a portion
of 1st dialog on background?
2. When clicking on "Close" of 2nd dialog, it
closes the dialog, but immedaitaly open another CMainDialog
again. This is not happening all the time, only happens
in certain cases. While trying to recreate the same sceneario
in DEBUG mode, it doesn't happen. Any idea why this is
happening?
Joseph M. Newcomer [MVP]