自己调用使用GetMessage()会出错
LPMSG pMsg = NULL;
BOOL bRet;
HWND hwnd=GetActiveWindow()->m_hWnd;
------>while((bRet = GetMessage(pMsg, hwnd, 0, 0 )) != 0)
{
char buf[1024];
sprintf_s(buf, 1024, "hWnd:%d uMsg: %d WParam: %d LParam: %d\n",pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
std::cout<<buf;
}
为什么这里会出错呢?到底怎么使用GetMessage呢?
出现错误提示:
Unhandled exception at 0x77cf91f1 in NOW.exe: 0xC0000005: Access violation reading location 0x00000004.
希望高手能给我解答,谢谢
exception GetMessage MFC
[解决办法]
LPMSG pMsg = NULL;// 错 : MSG msg;
GetMessage(&msg,
复习 指针 !
[解决办法]
LPMSG pMsg ;这是一个 悬挂 指针(即 不知道 指向 哪里!)
GetMessage(&msg, 是叫 函数 吧 消息 填到 msg 中 , 你给 一个 悬挂 指针 ,他 怎么 填 msg ?