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

。_饼干妹妹 提交于 2019-12-08 02:44:58

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/5343473/convert-simple-mfc-cview-cdocument-csingledoctemplate-app-to-activex-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!