"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.