简体   繁体   中英

Convert simple MFC CView/CDocument/CSingleDocTemplate app to ActiveX control

I have a fairly simple MFC app that just defines its own sub-classes of CDocument , CView and CFrameWnd and uses them via a CSingleDocTemplate to display the read-only contents of the document in a tree on the view. All very standard MFC MVC.

I now need to convert this app so that it works as an ActiveX control that I can then embed it within a larger application.

How should I go about this?

Is it possible to use the COleControl sub-class in place of the CFrameWnd sub-class in the CSingleDocTemplate ? Or do I need to place the CFrameWnd sub-class within the COleControl some how?

Failing that, how can I use my existing CDocument\\CView sub-classes within an ActiveX control?

Answering my own question : I found quite a few references to an old article about this, which used to be at http://www.microsoft.com/mind/0497/mfc.asp but has long since disappeared. :(

Fortunately though, the Wayback Machine still has a complete copy of it:

"Designing ActiveX Components with the MFC Document/View Model" by Steve Zimmerman, Microsoft Interactive Developer (April 1997)

Steve presents source code for two new classes:

CActiveXDocTemplate : a sub-class of CSingleDocTemplate
CActiveXDocControl : a sub-class of COleControl

which allowed me to use my existing CView and CDocument sub-classes in an ActiveX control.

(Thanks Steve wherever you are now)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM