To SuperChen: AfxGetMainWnd ()等于NULL?===>Trace发现不是To FoolBoy: 我已经试过了。:(
attention: maybe the prototype definition of OnModifyMenu() function is wrong. Please show the declaration of the function.SUCH AS THE FOLLOWING: afx_msg void OnModifyMenu(WPARAM wp, LPARAM lp);
Because I had meet the problem before. this kind of problem show itself only in Release edtion but not in Debug edtion.
一定是SendMessage()去执行的程序有误,仔细看看。
把 WM_YOUR_MSG 的响应函数贴出来。
system tray处理类中;
CWnd* pTarget = AfxGetMainWnd();
if (LOWORD(lParam) == WM_RBUTTONUP)
{
::SendMessage (pTarget->m_hWnd,
WM_MODIFYMENU,
NULL,
NULL);
....
}
主程序里
OnModifyMenu ()为空,结果:同样出错。
我把程序反汇编了,找到那行,发现出错的语句是执行了一个无效的指针操作。
stdafx.h
#define WM_MODIFYMENU WM_USER + 101
AfxGetMainWnd ()等于NULL?===>Trace发现不是To FoolBoy:
我已经试过了。:(
Please show the declaration of the function.SUCH AS THE FOLLOWING:
afx_msg void OnModifyMenu(WPARAM wp, LPARAM lp);
不过我用AfxGetApp ()->m_pMainWnd->GetSafeHWnd ();也一样。虽然现在用别的方法避开了这个问题,还是感谢大家,再加30银。