在MFC中集成RAD .NET框架
2007-06-21 21:36:15 来源:WEB开发网核心提示: void CUserCtrlView::OnInitialUpdate(){if(!m_bCtrlCreated&&m_strWinCtrlID!=_T("")){Type *t =theApp.m_pManagedCnnObj->GetType();Method
void CUserCtrlView::OnInitialUpdate()
{
if(!m_bCtrlCreated&&m_strWinCtrlID!=_T(""))
{
Type *t =
theApp.m_pManagedCnnObj->GetType();
MethodInfo *mi = t->GetMethod(S"Connect");
Object *p[] = new Object*[2];
try
{
Object *pObj = NULL;
String *pString[] = new String*[1];
pString[0] = m_strWinCtrlID;
PropertyInfo *m_pPropertyInfo =
t->GetProperty(S"PrjItem");
pObj = m_pPropertyInfo->GetValue(
theApp.m_pManagedCnnObj,pString);
if(pObj)
{
p[0] = pObj;
p[1] = pString[0];
//?????o
mi->Invoke(
theApp.m_pManagedCnnObj, p);
SetControl(pObj);
m_bCtrlCreated = true;
}
}
catch (Exception *exp)
{
CString strInfo = exp->Message;
AfxMessageBox(strInfo);
return;
}
}
CView::OnInitialUpdate();
}
现在,你可以在MFC程序中创建.NET控件了,我们的第一个宿主.NET控件的程序运行结果如图:
更多精彩
赞助商链接