你应该给它的父窗口发送BN_CLICK消息

解决方案 »

  1.   

    给父窗口messagehwnd发个WM_DESTORY看看
      

  2.   

    需要移动鼠标指针而不是设置焦点。建议这样做:
    SendMessage(messagechildhwnd, BM_CLICK, 0, 0);
      

  3.   

    SendMessage(messagehwnd, WM_COMMAND, 消息,(LPARAM)messagechildhwnd);
      

  4.   

    那你直接SendMessage(messagehwnd, WM_CLOSE, 0, 0);
    另外调试一下程序,看看FindWindow、FindWindowEx的返回值是不是NULL。
      

  5.   

    给为老师的方法都试了 而且依cnzdgs老师的方法也调试了 返回值是成功的 那么是不是真如arong1234老师说的那样被截获而且改变了 能不能模拟硬件点击呢 请给个模拟硬件的源码吧 谢谢
      

  6.   

    在你发送BM_CLICK之前,必须先激活对方的窗口
    HWND messagehwnd = ::FindWindow(NULL,"提示信息"); 
    if(messagehwnd)
    {
        HWND messagechildhwnd = ::FindWindowEx(messagehwnd,0,"Button","确定");
        if(messagechildhwnd)
        {
            SetActiveWindow(messagehwnd);
            SendMessage(messagechildhwnd, BM_CLICK, 0, 0);
        }
    }
    这点在MSDN里是由解释的:
    If the button is in a dialog box and the dialog box is not active, the BM_CLICK message might fail. To ensure success in this situation, call the SetActiveWindow function to activate the dialog box before sending the BM_CLICK message to the button.
      

  7.   

    模拟硬件可以用SendInput函数,或者mouse_event、keybd_event。你的控制线程与目标窗口所属线程不在同一桌面吧?