MSDN这样说:To dynamically create an ActiveX control in a non-dialog window 1.Insert CIRC2.H in CMYVIEW.H, just before the CMyView class definition:
#include "circ2.h"2.Add a member variable (of type CCirc2) to the protected section of the CMyView class definition located in CMYVIEW.H:
class CMyView : public CView
{
...
protected:CCirc2 m_myCtl;
...
};3.Add a WM_CREATE message handler to class CMyView.
4.In the handler function, CMyView::OnCreate, make a call to the control’s Create function using the this pointer as the parent window:
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (MyView::OnCreate(lpCreateStruct) == -1)
return -1;// ****** Add your code below this line ********** // m_myCtl.Create(NULL, WS_VISIBLE,
CRect(50,50,100,100), this, 0);
m_myCtl.SetCaption(_T(“Control created”));// ****** Add your code above this line ********** // return 0;
}5.Rebuild the project. A Circ2 control will be created dynamically whenever the application’s view is created.
#include "circ2.h"2.Add a member variable (of type CCirc2) to the protected section of the CMyView class definition located in CMYVIEW.H:
class CMyView : public CView
{
...
protected:CCirc2 m_myCtl;
...
};3.Add a WM_CREATE message handler to class CMyView.
4.In the handler function, CMyView::OnCreate, make a call to the control’s Create function using the this pointer as the parent window:
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (MyView::OnCreate(lpCreateStruct) == -1)
return -1;// ****** Add your code below this line ********** // m_myCtl.Create(NULL, WS_VISIBLE,
CRect(50,50,100,100), this, 0);
m_myCtl.SetCaption(_T(“Control created”));// ****** Add your code above this line ********** // return 0;
}5.Rebuild the project. A Circ2 control will be created dynamically whenever the application’s view is created.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货