我想拦截一个指定Caption的窗口给个思路?

解决方案 »

  1.   

    OnTimer()中即可.CWnd *pwnd=FindWindow(NULL,"caption");
    if(pwnd)
    {
       //得知窗口已开
    }
      

  2.   

    CBTProc
    The CBTProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The system calls this function before activating, creating, destroying, minimizing, maximizing, moving, or sizing a window
    ......
      

  3.   

    hHookCBTs = ::SetWindowsHookEx( WH_CBT, (HOOKPROC)CBT_Proc, hGameHook, 0 );LRESULT __declspec(dllexport) __stdcall CALLBACK 
    CBT_Proc( int nCode, WPARAM wParam, LPARAM lParam )
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());    if (nCode < 0) 
            return CallNextHookEx(hHookCBT, nCode, wParam, lParam);  switch (nCode) 
            { 
            case HCBT_CREATEWND:
    break;
    case HCBT_DESTROYWND:
    break;
    }
    }
      

  4.   

    下面是关闭莫个特定标题的程序代码
    void DestroyHelpWindow(void)
    {
    EnumWindows(DestroyHelpProc,NULL);
    }BOOL CALLBACK DestroyHelpProc(HWND hwndChild, LPARAM lParam) 

    char childText[30];
    GetWindowText(hwndChild,childText,30); char HelpTitle[MAX_LOADSTRING];
    LoadString(hInst, IDS_Help_TITLE, HelpTitle,MAX_LOADSTRING); if(
    strcmp(childText,HelpTitle)==0
    )
    {
    PostMessage(hwndChild,WM_SYSCOMMAND,SC_CLOSE,0); return FALSE;
    }    return TRUE; 
    }