Hi Guys,
I am trying to catch a 'dragged file' windows message via a DLL I am creating (for a third party engine).
I have the DLL currently talking with the engine correctly and it now ‘accepts files’ that are dragged onto the window, as it now displays the + symbol when a file is dragged on the window, which it didn't before and shows the return code of ‘998’.
I am new to Windows hooks though, so am not 100% sure I am going about this the right way.
It appears that my hook is also working because when I try to catch the HCBT_SYSCOMMAND message, it is displaying the message box, whenever I attempt to maximise etc…
But I can't get it to respond to a WM_DROPFILES message no matter what I try.
This is where my entire source is at present. Any advice would be greatly appreciated.
#include <Windows.h>
#include <iostream>
#define fn_export extern "C" __declspec (dllexport)
HHOOK hook_handle = NULL;
LRESULT CALLBACK DragFilesProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode < HC_ACTION)
return CallNextHookEx(hook_handle, nCode, wParam, lParam);
// This works as it is catching window resize etc...
/*
if (nCode == HCBT_SYSCOMMAND)
{
MessageBox(0, L"", L"", 0);
}
*/
if(wParam == WM_DROPFILES)
{
MessageBox(0, L"", L"", 0);
// Can't get this to fire.
}
return CallNextHookEx(hook_handle, nCode, wParam, lParam);
}
fn_export double test(HWND hWnd)
{
// Make the window 'accept files'
SetWindowLongPtr(hWnd, GWL_EXSTYLE, GetWindowLongA(hWnd, GWL_EXSTYLE) | WS_EX_ACCEPTFILES);
hook_handle = SetWindowsHookEx(WH_CBT, &DragFilesProc, GetModuleHandle(NULL), GetCurrentThreadId());
// Alternate method
DragAcceptFiles(hWnd, TRUE);
return 998;
}