Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 8-Dec-09 10:38am
v2

Call GetLastError for the error code.
 
Share this answer
 
I've done that followed by FormatMessage and the message is "Invalid handle".

Now I've resolved the problem. I had a RichEdit in my DialogBox, the fact that I remove it makes the Create work !!! I still don't understand why the hell it doesn't work !
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900