4
我用VC++ 6.0運行代碼,一切正常。但是,在Visual C++ 2010下運行相同的代碼時,wnd
(即m_hWnd
)的句柄始終爲NULL。此外,返回值bRet是TRUE(即成功)。函數CWnd :: CreateControl成功,但m_hWnd爲NULL
這裏是我的代碼:
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
}
您是否嘗試使用調試器進入'CreateControl'以查看會發生什麼? – sashoalm
它工作嗎?實際上OCX可以是無窗口的(所以m_hWnd將**總是**爲NULL)。 –
@Tri也[see this](http://stackoverflow.com/q/7956520/492336) – sashoalm