locked
hosting a MFC/C++ user control to OCX RRS feed

  • Question

  • I have a MFC Extension Classes CListViewEx here : http://www.codeguru.com/cpp/controls/listview/advanced/article.php/c4179

    How can i compile it to an OCX (ActiveX Control), so i can using it on other language such as VB6 etc.

    Thank!


    • Edited by vuadapass Monday, December 5, 2011 2:55 PM
    Monday, December 5, 2011 2:45 PM

Answers

  • You can create any kind of control inside an ActiveX project. I suggest you go to this site

    www.codeproject.com

    and search for "MFC OCX" to see numerous sample projects.


    • Edited by Scott McPhillips Tuesday, December 6, 2011 5:17 PM
    • Marked as answer by Rob Pan Monday, December 12, 2011 9:24 AM
    Tuesday, December 6, 2011 5:17 PM

All replies

  • Build a new project using the "MFC ActiveX Control" template in the File/New wizard. Then add methods to create and access your control. All of the method parameters will have to be OLE compatible types.

     

    Monday, December 5, 2011 3:47 PM
  • I mean converting the MFC Control (CTreeview, Clistview....) to be used in VB6. Because that control already exist on MFC, so how can i convert it to an OCX ? Any example please.

    • Edited by vuadapass Tuesday, December 6, 2011 1:26 AM
    Tuesday, December 6, 2011 1:25 AM
  • The answer is the same as before. You can't simply "convert" a control, but you can wrap it inside an ActiveX project.  Here's a page I found to introduce you to the basics, and it has a link at the bottom for some samples.

    http://msdn.microsoft.com/en-us/library/k194shk8(v=VS.100).aspx

     

    Tuesday, December 6, 2011 2:08 AM
  •  As the page you suggest, it's same that i'm draw an Activex control by using painting API like FillRect, ellipse.. ) . How can i draw a MFC Control on my ActiveX control ?


    • Edited by vuadapass Tuesday, December 6, 2011 8:28 AM
    Tuesday, December 6, 2011 3:19 AM
  • You can create any kind of control inside an ActiveX project. I suggest you go to this site

    www.codeproject.com

    and search for "MFC OCX" to see numerous sample projects.


    • Edited by Scott McPhillips Tuesday, December 6, 2011 5:17 PM
    • Marked as answer by Rob Pan Monday, December 12, 2011 9:24 AM
    Tuesday, December 6, 2011 5:17 PM