Re: MFC 7.1 als Container für .NET Controls

From: Frank Franzoni (franzoni_at_gepasoft.de)
Date: 02/09/05


Date: Wed, 9 Feb 2005 16:54:07 +0100

Hallo Andreas,

> Das glaubst du doch selbst nicht! Entweder es ist ein
> ActiveX-Control oder nicht.

Um ehrlich zu sein kenne ich mich mit der MFC und COM-Interop noch zu wenig aus um es zu glauben bzw. nicht zu glauben.
Muss momentan halt glauben was ich lese:-).

> D.h. falls die .NET-Assembly alle nötigen Schnittstellen für ActiveX implementiert und als
> COM-Server geladen werden kann,

Das scheint aber laut diversen Artikeln, Forenbeiträgen etc nicht der Fall zu sein.

Originalton aus einem Artikel aus der MSDN:

While I'm on the topic of managed controls, one thing that version 1.0 supported was hosting Windows Forms controls in exactly one
unmanaged host: Microsoft Internet Explorer.
Internet Explorer simply loads the Windows Forms control itself and treats it as a COM control. However, no other popular COM
control hosts, like MFC, Visual Basic® 6.0, or ATL, were supported in version 1.0. While neither Visual Basic 6.0 nor ATL is
officially supported in version 1.1 either, the Windows Forms team did a full test cycle on hosting Windows Forms controls as COM
controls in MFC 7.1—the version of MFC that comes with Visual Studio .NET 2003—and it is now an officially supported unmanaged host.
However, while it is fully supported, it's not fully integrated. You'll need to augment the standard COM control containment
infrastructure to support Windows Forms controls.

> Was du meinst, sind vielleicht reine .NET-Controls. Wie ich schon
> schrieb, sind sie auch nur *innerhalb* des Frameworks einsetzbar.

Ich habe ein einfaches Net-Control erzeugt und die ebenfalls erzeugte Typbliothek registriert. Dieses Control kann ich
imTestcontainer für ActiveX Steuerelemente erzeugen. Damit es als ActiveX in den entsprechenden Auswahldialogen diverser Anwendungen
auftaucht sind noch zusätzliche Registryeinträge nötig.
Nachdem ich diese hinzugefügt hatte war es auch im Dialogeditor von VS 2003 in der Liste verfügbar. Allerdings lässt es sich nicht
erzeugen, sondern bricht mit der Meldung 'ActiveX Steuerelement wurde fehlerhaft initialisiert' ab.
Gleiches nur mit anderer Fehlermeldung passiert auch in anderen Anwendungen die ActiveX hosten können.

> VS kann auch managed C++, mit Version 2003 gibt es sogar einen
> Designer für Windows.Forms und C++.

Deswegen auch meine Frage im Erstposting nach dem Sinn dieser Funktionalität, da mir dieser Weg wann immer er gehbar ist die
sinnvollere Variante der Verbindung beider Welten ist.
Nur ist jetzt meine technische Neugier geweckt und ich würde gerne zumindest ein einfaches NET Control, mit minimalen Aufwand, als
ActiveX verwenden.

Gruss Franzoni Frank



Relevant Pages

  • Re: WMP control resizing
    ... I understand how things work re: MFC, ActiveX ... getting the WMP9 activex control in a window and playing movies etc. ... when you want to resize the control in MFC, ...
    (microsoft.public.windowsmedia.sdk)
  • How to Read an Active X Control?
    ... My application is an MFC application but since MFC is essentially a ... that the non editable TextBox is implemented as an Active X Control. ... the Windows that Spy++ will EXCLUDE in its Windows Hierarchy display. ... If the ActiveX control is inside an ActiveX container then: ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Custom ActiveX Control containing standard MFC controls.
    ... Arthur wrote: ... > I'm new to ActiveX stuff, although have quite a bit experience with MFC, ... is create a custom control ...
    (microsoft.public.vc.mfc)
  • Custom ActiveX Control containing standard MFC controls.
    ... I'm new to ActiveX stuff, although have quite a bit experience with MFC, ... is create a custom control ... how do I get the ActiveX custom control to ...
    (microsoft.public.vc.mfc)
  • Re: How can I use C# GUI component in my MFC application.
    ... Here's some stuff I had written on this topic for my book (Extending MFC ... Using a .NET control in an MFC dialog ... we have seen how Windows Forms makes GUI development slightly easier ... BOOL Create(CWnd* pWnd, int x, int y, int cx, int cy); ...
    (microsoft.public.dotnet.languages.vc)