本文介绍了创建方法返回NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在研究由控制器类和DialogBox
类组成的ATL ActiveX组件.我正在尝试在控制器中创建对话框,但是它不起作用.我将把代码中有趣的部分放在这里.
CAxTestControl类:
Hi All,
I''m working on an ATL ActiveX component which is composed by a controller class and a DialogBox
class. I''m trying to create the dialogbox in the controller but it doesn''t work. I''ll put here the interesting parts of the code.
CAxTestControl class:
class ATL_NO_VTABLE CAxTestControl :
public CComObjectRootEx<CComSingleThreadModel>,
public CStockPropImpl<CAxTestControl, IAxTestControl>,
public IPersistStreamInitImpl<CAxTestControl>,
public IOleControlImpl<CAxTestControl>,
public IOleObjectImpl<CAxTestControl>,
public IOleInPlaceActiveObjectImpl<CAxTestControl>,
public IViewObjectExImpl<CAxTestControl>,
public IOleInPlaceObjectWindowlessImpl<CAxTestControl>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CAxTestControl>,
public CProxy_IAxTestControlEvents<CAxTestControl>,
public IPersistStorageImpl<CAxTestControl>,
public ISpecifyPropertyPagesImpl<CAxTestControl>,
public IProvideClassInfo2Impl<&CLSID_AxTestControl, &__uuidof(_IAxTestControlEvents), &LIBID_axtestLib>,
public IPropertyNotifySinkCP<CAxTestControl>,
public CComCoClass<CAxTestControl, &CLSID_AxTestControl>,
public CComControl<CAxTestControl>,
{
public:
CCAxTestDialog *m_dlg;
CAxTestControl():
m_CommandLineType(koax::koAxCommandLineTypeString)
{
m_bWindowOnly = TRUE;
}
BEGIN_MSG_MAP(CAxTestControl)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
CHAIN_MSG_MAP(CComControl<CAxTestControl>)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
LRESULT CAxTestControl::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
//HRSRC hDlg = AtlFindResource(hInstance, lpTemplateName, (StringType)RT_DIALOG);
//HRSRC hRes = FindResource( AfxGetResourceHandle(), MAKEINTRESOURCE(IDD_CAXTEXTDIALOG), RT_DIALOG);
m_dlg = new CCAxTestDialog(this);
HWND hwnd = m_dlg->Create(*this);//returns NULL
m_dlg->ShowWindow(SW_SHOWNORMAL);
return 0;
}
有人可以帮忙吗?
Can anyone help? What could be the problem?
推荐答案
这篇关于创建方法返回NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!