mfc >> Switching Modeless Dlg on TOP

by Trevor » Wed, 03 Dec 2003 22:59:16 GMT

"Sudhir" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
> Hi Friends,
>
> I have a MFC Dialog based application. Where I create one modal dialog
> (say Dlg1) from my main dialog. On click of some button on Dlg1 I
> create another Dlg2 which is again a modeless one. Now I want to make
> the selected dialog on top of all other dialogs. If I select dlg1 it
> gets selected but doesn't come up.
>
> In order to make selected dialog topmost I have used following code:
>
> void CDlg2::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized
> )
> {
> CDialog::OnActivate(nState, pWndOther, bMinimized);
>
> // TODO: Add your message handler code here
> if(nState == WA_CLICKACTIVE )
> SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
> }
>
> void CDlg2::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized
> )
> {
> CDialog::OnActivate(nState, pWndOther, bMinimized);
>
> // TODO: Add your message handler code here
> if(nState == WA_CLICKACTIVE )
> SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
> }
>
> But somehow this doesn't work. Can anybody help me finding what's
> going wrong. I am working on Win2000 OS.
>
> Thanks and regards,
> Sudhir

Sudhir,
You need to specify the HWND_TOPMOST for the 2nd param to SetWindowPos.
Your original call to SetWindowPos had no effect on the window at all.




Similar Threads

1. MFC: Switching Modeless Dlg on TOP

Hi Friends,

I have a MFC Dialog based application. Where I create one modal dialog
(say Dlg1) from my main dialog. On click of some button on Dlg1 I
create another Dlg2 which is again a modeless one. Now I want to make
the selected dialog on top of all other dialogs. If I select dlg1 it
gets selected but doesn't come up.

In order to make selected dialog topmost I have used following code:

void CDlg2::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized
)
{
	CDialog::OnActivate(nState, pWndOther, bMinimized);
	
	// TODO: Add your message handler code here
	if(nState == WA_CLICKACTIVE )
		SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}

void CDlg2::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized
)
{
	CDialog::OnActivate(nState, pWndOther, bMinimized);
	
	// TODO: Add your message handler code here
	if(nState == WA_CLICKACTIVE )
		SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}

But somehow this doesn't work. Can anybody help me finding what's
going wrong. I am working on Win2000 OS.

Thanks and regards,
Sudhir

2. putting a modeless dlg on another dlg (or formview)

3. Re Switching modeless dialog on TOP

Hi Friends,

I have a MFC Dialog based application. Where I create one modal dialog
(say Dlg1) from my main dialog. On click of some button on Dlg1 I
create another Dlg2 which is again a modeless one. Now I want to make
the selected dialog on top of all other dialogs. If I select dlg1 it
gets selected but doesn't come up.

In order to make selected dialog topmost I have used following code:

void CDlg1::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized
)
{
	CDialog::OnActivate(nState, pWndOther, bMinimized);
	
	// TODO: Add your message handler code here
	if(nState == WA_CLICKACTIVE )
		SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}

void CDlg2::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized
)
{
	CDialog::OnActivate(nState, pWndOther, bMinimized);
	
	// TODO: Add your message handler code here
	if(nState == WA_CLICKACTIVE )
		SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}

But somehow this doesn't work. Can anybody help me finding what's
going wrong. I am working on Win2000 OS.

Thanks and regards,
Sudhir

4. Modeless Dialog Boxes - Knowing when it terminates, Terminate without using delete Dlg and Getting input Focus

5. Modeless Dlg Box

Hello all,

   What I would like to do is have a modeless dialog
box available to all classes in a project.
   So, what I've done is inserted a new dialog box 
resource with an ID of 'IDD_MSG_DIALOG' and using 
ClassWizard added a string variable of 'm_static_msg'. 
   The class name is CMsgDlg, and I moved the header
'#include MsgDlg.h' into the stdafx.h, thinking this would
now make it available to everybody who has the 
#include "stdafx.h"? 
   But when I build it, I get the error:
 "error C2065: 'IDD_MSG_DIALOG' : undeclared identifier"

The ''IDD_MSG_DIALOG' is part of the:
        // Dialog Data
	//{{AFX_DATA(CMsgDlg)
	enum { IDD = IDD_MSG_DIALOG };
	CString	m_static_msg;
	//}}AFX_DATA
in the header file.

OK, so where am I going off the track?  Can I do what I 
would like to do? Or do I have to include the dialog's 
header file in every class where I would like to use it?

TIA,

Ray K.

6. creating modeless dlg in OCX causes msg pump shutout when keys pressed

7. Positioning a modeless child dlg

HI

I have an application that needs to change the data it displays dependent on 
user selection.

There are mutliple child dlgs (one for each button selection) and I want to 
embed in the parent window, i.e. inside a group box on the parent.

Is there any way of adding a dialog to another dialog in this fashion?

TIA

Tony 


8. Modeless dialog always on top/forefront of the screen