Qt5中实现类似发送sendmessage()和postmessage()发送自定义消息

HWND hWnd_login;	
hWnd_login = (HWND)login.winId();
::SendMessage(hWnd_login,(WM_USER+100),(WPARAM)&pSzResult,NULL);


bool Login::winEvent(MSG *message, long *result)
{
	if(message->message == WM_USER+100)
	{
		accept();
	}
	else
		return false;
}

//接受sendmessage自定义消息,然后发送给winEvent去处理消息
bool Login::nativeEvent(const QByteArray &eventType, void *message, long *result)  
{  
	Q_UNUSED(eventType);  
	MSG* msg = reinterpret_cast(message);  
	return winEvent(msg, result);  
} 

 

你可能感兴趣的:(Qt)