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