Hi, Hi All,
I have my ATL control working in a full browser window, embedded in a HTML page. However when I embed it into HTML HEAD of JSP page the control works fine, provides Print Preview but then the screen freezes and then I can do nothing with the browser. What extra interfaces do I need to add to my control so that it integrates perfectly with JSP/HTML without crashing the browser. Our solution targets IE5.5 browser hence the ATL control to tap into IE's native COM interfaces for implementing Print Preview. Regards, Raj Chanian -----Original Message----- From: Chanian, Raj Sent: 29 July 2003 12:21 To: 'Discussion related to the Active Template Library and COM development' Subject: RE: [ATL] Debug Assertion failed in atlbase.h Line 474 Thanks Maxine, I think it was because the code below which WORKS in a normal browser window, does not work in a modal dialog window. It threw the assert between the following two lines of code //QueryService for WebBrowser hresult= spIServiceProvider->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spIWebBrowser2); //Errs here! Possibly due to null value on constructor for spIWebBrowser2 //Get IDispatch Interface for Document hresult= spIWebBrowser2->get_Document(&spIDispatch); I got it to work by using window.open instead of window.showModalDialog in my javascript. And grabbed arguments to opened window by using window.document.getelementbyid("openedwindowelement")= window.opener.document.getelementbyid("openerwindowelement"); The question I have is what com interfaces are not supported in the dialog window compared to full browser window. And what tweak on this function can be made to make it work in a dialog window? Below is the function that encapsulates this behaviour. STDMETHODIMP CPreviewer::PreviewDefault() { HRESULT hresult=S_OK; try { //Smart Pointer Declarations CComPtr<IOleContainer> spIOleContainer; CComPtr<IServiceProvider> spIServiceProvider; CComPtr<IWebBrowser2> spIWebBrowser2; CComPtr<IDispatch> spIDispatch; CComPtr<IHTMLDocument2> spIHTMLDocument2; CComPtr<IOleCommandTarget> spIOleCommandTarget; //Member of CComControlBase::m_spClientSite //A pointer to the control's client site within the container //CComPtr<IOleClientSite> m_spClientSite; //Get IOleContainer hresult= m_spClientSite->GetContainer(&spIOleContainer); //QueryInterface for IServiceProvider hresult= spIOleContainer->QueryInterface(IID_IServiceProvider, (void**)&spIServiceProvider); //QueryService for WebBrowser hresult= spIServiceProvider->QueryService(SID_SWebBrowserApp, IID_IWebBrowser, (void**)&spIWebBrowser2); //Get IDispatch Interface for Document hresult= spIWebBrowser2->get_Document(&spIDispatch); //QueryInterface for IHTMLDocument2 hresult= spIDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&spIHTMLDocument2); //QueryInterface for IOleCommandTarget hresult= spIHTMLDocument2->QueryInterface(IID_IOleCommandTarget, (void**)&spIOleCommandTarget); //Do not pass a custom template as we are using default template //Invoke PrintPreview hresult= spIOleCommandTarget->Exec(&CGID_MSHTML, IDM_PRINTPREVIEW, NULL, NULL, NULL); //If No Errors Return Default Status return S_OK; } catch(...) { //Need to Expand Here //return E_FAIL; //HRESULT May Differ Here ATLASSERT(0); return hresult; } } -----Original Message----- From: LABELLE, Maxime [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 13:17 To: [EMAIL PROTECTED] Subject: Re: [ATL] Debug Assertion failed in atlbase.h Line 474 Oops! > He already has. :-) That's my mistake. Sorry. I overlooked the subject. OK, well, here's what I've got at the specified line: 472: _NoAddRefReleaseOnCComPtr<T>* operator->() const 473: { 474: ATLASSERT(p!=NULL); 475: return (_NoAddRefReleaseOnCComPtr<T>*)p; 476: } That seems pretty clear to me. It is illegal to dereference a null pointer. So the question is why is the smart pointer containing a null pointer ? I see several options: 1. the p member has never been assigned a value other than the default (431). 2. .Release() has already been called on the smart pointer (452). 3. .operator &() has been called by passing the smart-pointer in one of the returned arguments of ::CoCreateInstance, but the ::CoCreateInstance call failed for some reason. Lookup the resulting HRESULT (470). 4. .Attach() has been called with a null pointer (516). 5. .Detach() has been explicitely called (521). 6. .CoCreateInstance() failed. Lookup the resulting HRESULT (705). Cheers. Maxime. ------------------------------------------------------------------------- You can read messages from the ATL archive, unsubscribe from ATL, or subscribe to other DevelopMentor lists at http://discuss.develop.com. *** To unsubscribe, either go to http://discuss.develop.com and use the Web interface, or send an email from the *subscribed* account to: [EMAIL PROTECTED], with a *message body* of: unsubscribe atl This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com