15,980
社区成员




BOOL C**Dlg::OnInitDialog()
{
CRect rect;
GetDlgItem(IDC_CTRL1)->GetWindowRect(rect); //IDC_CTRL1是一个用来占位的Static控件,就是添加一个ID为IDC_CTRL1的CStatic控件到对话框窗口上,并调整到你要的大小
GetDlgItem(IDC_CTRL1)->DestroyWindow();
ScreenToClient(rect);
m_Prop.CreateManagedControl( WS_VISIBLE|WS_CHILD, rect, this, IDC_CTRL1 ); //创建一个托管控件
System::Windows::Forms::PropertyGrid^ pGrid=m_Prop.GetControl(); //将托管控件托付给一个PropertyGrid对象
pGrid->SelectedObject = pGrid; //这里会报异常:未将对象引用设置到对象实例。貌似到了这里时CAD2007在pGrid还没有初始化,设置属性便出了错
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
m_Prop.CreateManagedControl( WS_VISIBLE|WS_CHILD, rect, this, IDC_CTRL1 );
DDX_ManagedControl(pDx,ID_PGRID, m_PropGrid)
#include <afxwinforms.h>// MFC Windows Forms support
#using <system.dll>
#using <Microsoft.VisualC.Dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <mscorlib.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::ComponentModel;
using namespace Microsoft::VisualC::MFC;
CWinFormsControl<System::Windows::Forms::PropertyGrid> m_Prop;
BOOL C**Dlg::OnInitDialog()
{
CRect rect;
GetDlgItem(IDC_CTRL1)->GetWindowRect(rect); //IDC_CTRL1是一个用来占位的Static控件,就是添加一个ID为IDC_CTRL1的CStatic控件到对话框窗口上,并调整到你要的大小
GetDlgItem(IDC_CTRL1)->DestroyWindow();
ScreenToClient(rect);
m_Prop.CreateManagedControl( WS_VISIBLE|WS_CHILD, rect, this, IDC_CTRL1 ); //创建一个托管控件
System::Windows::Forms::PropertyGrid^ pGrid=m_Prop.GetControl(); //将托管控件托付给一个PropertyGrid对象
//......
}