我现在做了一个对话框!让用户可以拖拉文件到里面!我现在想让这个对话框总在最前显示!就像realplay总在最前显示的问题!请问应该怎么做!谢谢大家!

解决方案 »

  1.   

    你直接拦截WM_CREATE消息,加上下面的代码即可:
    int CTopWindowDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    if (CDialog::OnCreate(lpCreateStruct) == -1)
    return -1;

        SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
    return 0;
    }
      

  2.   

    ::SetWindowPos(AfxGetMainWnd()->m_hWnd,HWND_TOPMOST,-1,-1,-1.-1,SWP_NOMOVE|SWP_NOSIZE)
      

  3.   

    同意zbc(ChinaBCB之AlexAndy用户) 
    另外,CWnd::SetWindowPos也可以:
    SetWindowPos( ※wndTopMost, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
      

  4.   

    ::SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE |SWP_NOSIZE);
      

  5.   

    ::SetWindowPos(this->m_hWnd,m_bOnTop?HWND_TOPMOST:HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);