如果我在 myTab 类中创建 CButton,我无法以用户身份与其交互。
但是,如果我在 Main CDialog 中“创建”CButton 并将 pParentWnd 设置为 dlgMine,那么我可以与之交互。
谢谢
//Main CDialog
CDialog *dlgMine = new myTab(this);
dlgMine->Create(IDD_DIALOG1,this);
dlgMine->SetWindowPos(&wndTop, 20, 20, 300, 300, SWP_SHOWWINDOW);
myTab::myTab(CWnd* pParent /*=NULL*/)
: CDialog(myTab::IDD, pParent)
{
//{{AFX_DATA_INIT(myTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
CButton *btn = new CButton();
btn->Create("Run", WS_BORDER|WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(40,40,100,100),this,10);
}