I am writing an AutoCAD plugin that uses C++ with the Microsoft Foundation Classes framework (MFC), and linking the ObjectARX source library tied to AutoCAD that helps me integrate my plugin with AutoCAD's native code.
I am currently experiencing an issue where I cannot intercept Windows Messages that are created when using touchscreen gestures like pinch, zoom, or pan.
This is an example of the hook method I have implemented below. I am able to receive basically all mouse events (left click down, left click up, mouse wheel, right click, double click, etc.). The problem is, when I use my fingers on my touchscreen to perform gestures like pinching and zooming, or two finger panning, no Windows Messages are forwarded to this hook. I would have assumed that WM_GESTURE or WM_TOUCH messages would have also been intercepted by this hook as well.
However, AutoCAD's main frame window with the drawing in it is still responsive to these gesture actions I am making. I.e. I am able to use AutoCAD's native zoom and pan functionality while I pinch, zoom, and pan with my fingers. The problem I now have is I have no way to intercept or modify these gesture events in the case that I need to either block or modify this default functionality.
BOOL WindowsMessageHook(MSG *pMsg)
{
if (pMsg->message == WM_LBUTTONDOWN)
{
//Got Left Click (This works!)
}
else if (pMsg->message == WM_TOUCH)
{
//Try to intercept WM_TOUCH (Doesn't work)
return TRUE;
}
else if (pMsg->message == WM_GESTURE)
{
//Try to intercept WM_GESTURE (Doesn't work)
return TRUE;
}
return FALSE;
}
In a separate method that is being called, I have this line of code, which will register the hook with ObjectARX.
acedRegisterFilterWinMsg(WindowsMessageHook);
I have tried writing some code that simulates a transparent window to intercept Windows Messages (as I have seen suggested to others asking similar questions). Unfortunately, at least from the code that I tried, I was still not able to intercept these types of Windows Messages (WM_GESTURE / WM_TOUCH).
I am now wondering if there is something special or particular I need to do in order to retrieve these messages. Or it could be I am just fundamentally not understanding something and going the complete wrong way about addressing this problem.
Another potential solution idea that occurred to me was to find a way to override the AutoCAD's main frame "Wnd" (window) class and override the "WndProc" method in particular as I have seen other similar suggestions online. The problem is I'm not exactly sure how to go about doing that properly with ObjectARX. I believe to get the main frame window you use the following line of code below.
CMDIFrameWnd* acadWindowFrame = acedGetAcadFrame();
Note: I am targeting Windows 10 machines only.
Any insight or help is extremely appreciated as I've been pretty stressed out in trying to get my head around this problem and it this point it just feels like I'm wasting my time.
Thank you so much for your time and efforts.