m_hWnd member variable is null

I'm trying to get the handle of a dialog box with this code:

class CStatisticsDlg : public CDialogEx

// Dialog Data
    enum { IDD = IDD_STATISTICS };

    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation

CStatisticsDlg::CStatisticsDlg() : CDialogEx(CStatisticsDlg::IDD)

void CStatisticsDlg::DoDataExchange(CDataExchange* pDX)
    //  DDX_Control(pDX, IDC_FUCK, m_fuck);

BEGIN_MESSAGE_MAP(CStatisticsDlg, CDialogEx)

But when I create an instance of the class with this:

CStatisticsDlg statisticsDlg;

and try to get its handle via statisticsDlg.m_hWnd, the handle is null.

Why this is the case? What is the best way to get the handle for a dialog box?


The first point during the creation process where you can get the m_hWnd is the dialog's OnInitDialog function. The m_hWnd does not exist before the DoModal call and does not exist after the DoModal returns.

try modalless dialog model .Use create function instead of domodal.m_hWnd does not exist before create call begins.

Need Your Help

Core Data Array in swift

arrays xcode swift core-data

Hi guys I have a problem. After many videos i haven't understand how can I use the Core Data to store an array.