The current projects are all written in VC6 and VB6. It has been proved that .Net can write Active X controls for MFC use. So we'd like to write some active x controls using .Net with minimum changes in the legacy code.
Here is the requirements:
- The Host application (written in VC6) must be able to find and load the active x control from the registered category.
- The active x control must support property pages.
- The active x control must support property persistence.
Here is my questions:
- Is it possible to write Active X property pages using .Net WinForm Controls? And how to communicate between controls and corresponding properties in C#?
How to register the Active X control under a certain category in C#? The following is a piece of sample code in MFC regarding to control registration.
STDAPI DllRegisterServer(void) { HRESULT hr; AFX_MANAGE_STATE(_afxModuleAddrThis); if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE)) return ResultFromScode(SELFREG_E_CLASS); hr = CreateComponentCategory(CATID_CTRL_CAT, L"XXXX"); if (FAILED(hr)) return hr; hr = RegisterCLSIDInCategory(CATID_CONTROL, CATID_CTRL_CAT); if (FAILED(hr)) return hr; return NOERROR; }
The above registration has 3 steps, AfxOleRegisterTypeLib, CreateComponentCategory and RegisterCLSIDInCategory. How can we implement them in C#?
- What is the equivalent way in C# to achieve property persistence?
Thank you in advance for any comments and helps!!!