窗口随时置顶

来源:互联网 发布:单片机电子琴汇编程序 编辑:程序博客网 时间:2024/05/11 21:08

如果需要自己的窗口在某时刻 置顶,可以这样:

如 :OnTimer
{
    CPoint pt;
    GetCursorPos(&pt);
    CWnd *pWinAny=WindowFromPoint(pt);
    DWORD tidOrig=GetWindowThreadProcessId(pWinAny->m_hWnd,0);
    DWORD tid=GetCurrentThreadId();
    if( tid != tidOrig)
    {
        afxDump << "Active My Window!\n";
        if(AttachThreadInput(tid,tidOrig,TRUE))
        {
             SetActiveWindow();
        // we have to detach it !
             AttachThreadInput(tid,tidOrig,FALSE);
        }
    }
}
不怕 全 覆盖 !

最小化时,加入:

//
if (IsIconic())
{
ShowWindow(SW_RESTORE);
}

0 0