MDI using Modeless dialogs

Hi All,

I have a MDI project where I need a modeless dialog for every document, the problem I have is
that I need to attach the dialog to the view, so when I add additional documents which will have
their own modeless dialog attached, I need to bring the dialog to the front and also hide behind
the current focused view, at the moment the dialog is always displayed to the front, and the
screen gets cluttered with the dialogs from all the documents added.

I just need a way to link the dialog to the view so when the view get affected by position etc..
then the same should happen to the dialog.

Any ideas, have tried various ways and still no luck, thanks in advance...

Shaun Garratt
[748 byte] By [Shaun Garratt] at [2007-11-17 8:55:24]
# 1 Re: MDI using Modeless dialogs
SetWindowPos allows you to change the Z-order of the window. Try manipulating it with that.
Wolfram Steinke at 2007-11-10 7:45:25 >
# 2 Re: MDI using Modeless dialogs
Thanks for the reply,

Have tried manipulating SetWindowPos, but still does not achieve the result, as I am using a MDI environment.

Thankyou

Shaun Garratt
Shaun Garratt at 2007-11-10 7:46:24 >
# 3 Re: MDI using Modeless dialogs
The other alternative is to hide the dialogs that belong to the inactive view and show it when the view becomes active. Use OnActivateView in your view class(es) to detect this.
Wolfram Steinke at 2007-11-10 7:47:22 >
# 4 Re: MDI using Modeless dialogs
Wolfram you have cracked it my friend, works like a dream, I owe you one!!!

Regards

Shaun Garratt
Shaun Garratt at 2007-11-10 7:48:28 >
# 5 Re: MDI using Modeless dialogs
Great - glad I could be of help
Wolfram Steinke at 2007-11-10 7:49:25 >
# 6 Re: MDI using Modeless dialogs
Just to add, maybe a little tip for others, I needed to also know when the view was minimized,
I just overridden the CChildFrame's OnSize function then send a WM_MESSAGE to my view,
sending nType variable passed to OnSize, the view then decided wether view is minimized and then
can hide the modeless dialog, or show if not minimized.

#define UWM_MAINFRAME_TO_VIEW (WM_APP+1)

void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
CCBSview *pView = reinterpret_cast<CCBSview*>(GetActiveView());
if( pView )
pView->SendMessage( UWM_MAINFRAME_TO_VIEW, WM_SIZE, (LPARAM)nType );

CMDIChildWnd::OnSize(nType, cx, cy);
}

void
CCBSview::OnMainFrameMsg( WPARAM wParam, LPARAM lParam )
{
UINT nMsg = static_cast<UINT>(wParam);
UINT nInfo = static_cast<UINT>(lParam);

switch( nMsg )
{
case WM_SIZE:
if( (m_bHideNewDlg) || (!m_pNewFieldDlg) )
return;

if( (nInfo==SIZE_MINIMIZED) || (nInfo==SIZE_MAXHIDE) )
{
// hide modeless dialogs
m_pNewFieldDlg->ShowWindow( SW_HIDE );
m_bMinimized = TRUE;
}
else
{
// display modeless dialogs here
m_pNewFieldDlg->ShowWindow( SW_RESTORE );
m_bMinimized = FALSE;
}

break;
}

}

There maybe another aproach to achieve this but the above works fine for me.

Shaun Garratt
Shaun Garratt at 2007-11-10 7:50:24 >