VC++ 6.0 でコードを実行しましたが、すべて問題ありません。しかし、Visual C++ 2010 で同じコードを実行すると、wnd
(つまりm_hWnd
) のハンドルは常に NULL になります。また、戻り値 bRet は TRUE (つまり、成功) です。
これが私のコードです:
BOOL CDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's 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
}