A 3D mouse is an input device used by CAD users. If you are hosting one of Eyeshot's WinForms controls within an MFC application, you'll notice that your 3D mouse won't work at all.
The problem
Eyeshot WinForms controls process 3D-mice-related Windows Messages by implementing the IMessageFilter interface and asking the WinForms application to be added to its message pump (via the Application class). When these controls are hosted in an MFC application, though, there's no WinForms application with any message pumps to begin with!
The solution
Since in MFC applications there is no message pump, we'll need to rely on the WinForms controls' usual WndProc method. Let's override it in a new C++/CLI "MyDesign.h" header class:
#pragma once
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <devDept.Eyeshot.Control.Win.v2023.dll>
ref class MyDesign :
public devDept::Eyeshot::Control::Design
{
protected:
virtual void WndProc(System::Windows::Forms::Message% m) override;
};
Implementing the IMessageFilter interface means implementing its sole member, the PreFilterMessage method. This message is supposed to preprocess Windows Messages (including the ones related to 3D mice) before they arrive to WndProc. Also, if it returns true, the messaged should be considered filtered out (i.e. it should stopped from being dispatched to WndProc). Here's how this would look in a new "MyDesign.cpp" file:
#include "pch.h"
#include "MyDesign.h"
void MyDesign::WndProc(System::Windows::Forms::Message% m) {
if (!Design::PreFilterMessage(m))
Design::WndProc(m);
}
Comments
Please sign in to leave a comment.