Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. How to create an ActiveX in a CView (MFC) help or URL or Books wanted

How to create an ActiveX in a CView (MFC) help or URL or Books wanted

Scheduled Pinned Locked Moved COM
comc++algorithmshelptutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Remi Morin
    wrote on last edited by
    #1

    Hi, I'm a begginner with activeX, but I'm not so bad whit MFC. For now I have a good book to learn ActiveX, but I'm unable to insert any of them in a CView... So the first step was to learn: ActiveX, make you're own and know how it work but I'm searching: ActiveX --> the next step how to create it in you're MFC document/view application dynamicaly by the way my activeX is a control, so It must be displayed thanks Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

    R 1 Reply Last reply
    0
    • R Remi Morin

      Hi, I'm a begginner with activeX, but I'm not so bad whit MFC. For now I have a good book to learn ActiveX, but I'm unable to insert any of them in a CView... So the first step was to learn: ActiveX, make you're own and know how it work but I'm searching: ActiveX --> the next step how to create it in you're MFC document/view application dynamicaly by the way my activeX is a control, so It must be displayed thanks Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

      R Offline
      R Offline
      Remi Morin
      wrote on last edited by
      #2

      Hi to Myself, it look like anybody is able to answer me so I will (because I've find) so To create a ActiveX in a CView (just to create it to make it work properly... maybe later) First add a CWnd member in you'r class

      class MyView : public CView
      {
      //...
      CWnd m_ActiveXControl;
      //...
      //override create
      virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD
      //...
      //override On_Size
      //{{AFX_MSG(CTestViewAsAContainerView)
      afx_msg void OnSize(UINT nType, int cx, int cy);
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      };

      then in the create function you must create you'r activeX control. The CWnd is the wrapper for you'r active X so you do that way :

      BOOL CTestViewAsAContainerView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
      {
      // TODO: Add your specialized code here and/or call the base class
      BOOL Ok;
      //to be sure it clip children, I didn't try without
      dwStyle |= WS_CLIPCHILDREN;
      //create the windows
      Ok = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
      //then create the control
      Ok &= m_ControlWrapper.CreateControl("MYACTIVEX.MyActiveXCtrl.1", //this string is the identifiant string that you find in the registry
      "",
      WS_VISIBLE,
      CRect(0,0,100,100), //the size of this rect don't bother, the On_Size function will size it properly
      this,
      5000, //change this for a ressource ID
      NULL,
      FALSE,
      NULL);

      return Ok;
      

      }

      then the on_size to size if

      void CTestViewAsAContainerView::OnSize(UINT nType, int cx, int cy)
      {
      CRect r;
      CView::OnSize(nType, cx, cy);
      GetClientRect(&r);
      //this function is call before the document is attach to the view, in that case
      //the size of the view is 0 so we must'not call the moveWindow function because
      //we have create this control with WS_VISIBLE (it's why we have create it with a
      //dummy rect)
      if(!r.IsRectEmpty())
      {
      m_ControlWrapper.MoveWindow(&r);
      }
      }

      so that it's thanks to myself hehehehe, Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups