用SendMessage向由CreateDialogIndirectParam创建的对话框发送消息 
SendMessage的返回值与消息处理时返回的值不一样 
返回的总是0, 
而消息处理时返回的是1 
为什么呢? 
有什么样的原因会导致这种状况出现呢? 我都是直接用的WINAPI,没用MFC

解决方案 »

  1.   

    GetLastError() 是 0
    也就是S_OK
      

  2.   

    消息处理时返回的是1 这不就是SendMessage的返回么?
      

  3.   

    我是指对话框的消息处理中返回1
    但SendMessage的返回值确实0
      

  4.   


    我表达能力这么差吗?1.用CreateDialogIndirectParam创建对话框,窗口过程为DLGPRO
    2.用SENDMESSAGE 向对话框发送了一个自定义的消息,
    3.对话框的窗口过程DLGPRO处理了此消息,并返回TRUE,也就是1
    4.但在SENDMESSAGE得到的返回值却是0
      

  5.   

    3.对话框的窗口过程DLGPRO处理了此消息,并返回TRUE,也就是1 --给了操作系统了
    4.但在SENDMESSAGE得到的返回值却是0--在消息队列中处理完了,0表示正确处理了,非0看错误号
      

  6.   

    TO 楼上的,
    不是吧
    SENDMESSAGE的返回值应该是窗口过程的返回值啊
    按你的说法,是SENDMESSAGE不能得到窗口过程的返回值?
    恐怕难以接受
      

  7.   

    我用mfc生成的对话框测试确实是得到正确的值哦
    postmessage才是这样,sendmessage确实是返回消息处理函数的返回值来的。看msdn中的描述:
    BOOL PostMessage(
      HWND hWnd,      // handle to destination window
      UINT Msg,       // message
      WPARAM wParam,  // first message parameter
      LPARAM lParam   // second message parameter
    );Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. LRESULT SendMessage(
      HWND hWnd,      // handle to destination window
      UINT Msg,       // message
      WPARAM wParam,  // first message parameter
      LPARAM lParam   // second message parameter
    );Return Values
    The return value specifies the result of the message processing; it depends on the message sent. 
      

  8.   

    对话框的消息返回值,TRUE和FALSE表示窗口过程是否已处理该消息,如果是FALSE,系统会调用默认的窗口过程进行处理,因此返回值并不会传给SendMessage,如果想SendMessage收到返回值,必须在对话框消息处理返回前调用SetWindowLong(hWnd,DWL_MSGRESULT,返回值);
      

  9.   

    SendMessage本身返回值就是看你给的是什么消息,各消息的返回值意义是不同的,如果是自定消息,那么返回值使用14楼的方法也许可行.
      

  10.   

    如何用jnative中的user32.sendMessage(1,2,3,4),其中第4个参数是要传递指针类型的参数。