Dialog Class doesn't let me interact with CButton on the dialog?

Go To StackoverFlow.com

-1

If I create the CButton in the myTab class, I can't interact with it as a user.

However, if I "create" the CButton in the Main CDialog and set the pParentWnd to dlgMine then I can interact with.

Thx

//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);
}
2012-04-05 00:45
by jdl


2

You shouldn't create the button in the dialog constructor because the dialog itself is still not created. Do it in the OnInitDialog instead.

2012-04-05 06:44
by Javier De Pedro
Ads