This is my second question of the day, pardon me.
I am writing a wrapper library to communicate with a scanner device. The source code was in C++ MFC. I am converting it to a plain Dll which will be invoked from C#. So, I am using DllImport in C# to call the wrapper library.
Now I am provided with MFC code and the library is a ActiveX Object, at least I think so.
class CDpocx : public CWnd
{
}
So in my wrapper library I will have an instance of CDpocx and will call it via C# P/Invoke. But the problem is CDpocx also throws some events which I need to catch. In traditional app, I would just attach an function with it. But How would I attach the events on non MFC class.
I have seen something like:
BEGIN_EVENTSINK_MAP(CVC60Dlg, CDialog)
//{{AFX_EVENTSINK_MAP(CVC60Dlg)
ON_EVENT(CVC60Dlg, IDC_DPOCXCTRL1, 1 , OnReadyDpocxctrl1, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
OnReadyDpocxctrl开发者_Python百科1 is the function that handles 1 (Ready) event.
How can I gain simmilar function in non MFC class.
Regards, Maksud
I'm not sure if this is what you want, but if you want to call an ActiveX component from C#, you should use Windows Forms ActiveX Control Importer (Aximp.exe) which will convert the type definitions in a COM type library for an ActiveX control into a Windows Forms control.
精彩评论