code:
// C++
// Initialisation
HHOOK cwp = SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, dllInstance, GetCurrentThreadId());
HHOOK gmp = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, dllInstance, GetCurrentThreadId());
UINT msgID = RegisterWindowMessage(_T("MessengerPlus_DisplayToast"));
// Uninitialisation
UnhookWindowsHookEx(cwp);
UnhookWindowsHookEx(gmp);
// CallWndProc - Used for SendMessage() calls
LRESULT CALLBACK CallWndProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code >= 0) {
CWPSTRUCT *msg = (CWPSTRUCT*)lParam;
if (msg->message == msgID) {
// Process msg->LPARAM here: MP_TOAST_INFO*
}
}
return CallNextHookEx(cwp, code, wParam, lParam);
}
// GetMsgProc - Used for PostMessage() calls
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code >= 0 && wparam == PM_REMOVE) {
MSG *msg = (MSG*)lParam;
if (msg->message == msgID) {
// Process msg->LPARAM here: MP_TOAST_INFO*
}
}
return CallNextHookEx(gmp, code, wParam, lParam);
}
cwp, gmp, and msgID will need to be globally accessible as they will be used in multiple functions.
_T() is a C++ macro that is used to ensure all string l=iterals are the correct type. C++ defines two character types: the ANSI char type, and the Unicode wchar_t type. _T() resolves to L in Unicode, and disappears entirely in ANSI.
MP_TOAST_INFO is defined in the Messenger Plus! API.
To get dllInstance, save the hInstance argument to DllMain in a global variable.
Edit: Dammit, why does this board remove tabs?