How to Move Two Dialogs at Once



Hello,

One of my work's project specifications is to allow users to move two Dialog
boxes together so when a user moves one box, the other one moves together
with the first. This is what I am trying to do:

1) Create OnMove() event
//Import a function to create a Second Dialog
extern "C" __declspec(dllimport) long CallDlg();

//Import a function to move a Second Dialog
extern "C" __declspec(dllimport) long CallDlg2(int x, int y);

void CSvg::OnMove(int x, int y)
{
//Detect if a user selected two-dialogs move option
if (m_attach)
{
//Create a second dialog
/*This is how my second dialog gets created in
the OTHER DLL
CMain* m_dlg;
try
{
m_dlg = new CMain();
m_dlg->SetModelessFlag(true);
m_dlg->Create(IDD_MAIN);
m_dlg->ShowWindow(SW_SHOW);
}
catch (CMain* m_dlg)
{
m_dlg->PostNcDestroy();
delete m_dlg;
}
*/
//Call that dialog
CallDlg();
//Enable moving option
m_move = true;
}
//Make sure dialog is not created more than once
m_attach = false;
if (m_move)
{
//Call the Move function from another DLL
/*This is my move function from another DLL
CMain* m_dlg;
m_dlg = NULL;
try
{
//Please note GetObj() it returns a "this" pointer from another DLL
m_dlg->GetObj()->RePos(x, y);
}
catch (CMain* m_dlg)
{
m_dlg->PostNcDestroy();
delete m_dlg;
} */
//ATTEMPT TO MOVE A DIALOG
CDialog::OnMove(x, y);
CallDlg2(x, y);
}
}

In the line: m_dlg->GetObj()->RePos(x, y); I am hoping that GetObj() will
return an object created earlier when I call the creation of a Dialog using
CallDlg(). And, the RePos() function is a member of my CMain class that does
the following:

void CMain::RePos(int x, int y)
{
CWnd::MoveWindow(x, y, 50, 50, TRUE);
}

I set the arbitrary size for a Dialog here, but the problem is when I try to
move the first dialog. Everything crashes at that point. After running a
debugger, I get an arrow pointing to "ASSERT(::IsWindow(m_hWnd))" from CWnd
class.

First of, I'd like to thank you for reading my long post. But I will be
deeply grateful to anyone who would be able kindly to tell me how to fix this
problem. Thank you very much.

Victor.


.



Relevant Pages


Loading