SendMessage始终返回ZERO? [英] SendMessage Always returns ZERO?

查看:326
本文介绍了SendMessage始终返回ZERO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么Windows SendMessage()总是返回ZERO,即使邮件传递是成功的?








p>

  LRESULT result = :: SendMessage(hwndOtherWindow, WM_COPYDATA,NULL / *(WPARAM)this-> GetSafeHwnd()* /,(LPARAM)& structCDS); 

result始终为零:(,但邮件成功传递到其他窗口



EDIT

  BOOL CDlg :: OnCopyData pWnd,COPYDATASTRUCT * pCopyDataStruct)
{
return / * CDialog :: OnCopyData(pWnd,pCopyDataStruct)* / true; // true是诀窍
}


解决方案

WM_COPYDATA 表示目标应用程序未处理消息(FALSE = 0)。



消息可能成功传递,但如果目标应用程序没有正确处理消息(即,错误的返回值或将其传递到默认窗口过程),那么您的SendMessage调用将出现以返回错误的结果。



如果可能,可能值得花时间查看目标应用程序处理WM_COPYDATA消息的方式。


Why does Windows SendMessage() always return ZERO, even the message delivery is success? Is there anyway to check the message delivery failure with SendMessage() ?

EDIT

Forgot to mention that I'm using SendMessage() inside a c++ DLL

LRESULT result = ::SendMessage(hwndOtherWindow,WM_COPYDATA, NULL/*(WPARAM)this->GetSafeHwnd()*/,(LPARAM)&structCDS);

"result" is always zero :(, but message delivers to other window successfully

EDIT

BOOL CDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
    return /*CDialog::OnCopyData(pWnd, pCopyDataStruct)*/ true;  //true is the trick
 }

解决方案

A zero return from SendMessage for WM_COPYDATA means the target application didn't process the message (FALSE = 0).

The message might deliver successfully, but if the target application doesn't handle the message properly (ie, wrong return value, or passing it to the default window procedure) then your SendMessage call will appear to come back with the wrong result.

It might be worth your time to see what the target application's handling of the WM_COPYDATA message is, if possible.

这篇关于SendMessage始终返回ZERO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆