I run the code with VC ++ 6.0, everything is in order. But when you run the same code in Visual C ++ 2010, the wnd descriptor (namely m_hWnd ) is always NULL. In addition, the return value of bRet is TRUE (i.e., Success).
Here is my code:
BOOL CDemoDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here CRect rect; GetClientRect(rect); CWnd wnd; BOOL bRet = wnd.CreateControl(_T("WMPlayer.OCX"), NULL, WS_VISIBLE, rect, this, 19089); return TRUE; // return TRUE unless you set the focus to a control }
source share