Re: Pls Help with empty Print Preview
From: Peter Carlson (peter_at___N.O.S.P.A.M__howudodat.com)
Date: 02/25/05
- Next message: Peter Carlson: "IPersistStreamInit to Append Text"
- Previous message: sharrukin amiri: "IE Browser Links"
- In reply to: Igor Tandetnik: "Re: Pls Help with empty Print Preview"
- Next in thread: Igor Tandetnik: "Re: Pls Help with empty Print Preview"
- Reply: Igor Tandetnik: "Re: Pls Help with empty Print Preview"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 25 Feb 2005 11:47:25 -0700
ok..have deleted the GlobalFree....it's interesting because I copied the
code directly from the MSDN article :)
So it doesn't crash, but now it's broken a different part of the code :(
After the document is loaded we execute some JS to finish any last minute
changes in the html (ie set the default date). If I use document->write
then I can InvokeScript, if I use the Stream I can't - it cant find the
script...GetIDOfName cant find the javascript function, however, view source
shows it's there. I have checked both calling Invoke...from OnNavComplete
and from a handler for window.external.onLoad (which is called in
ondocumentready). Below is the InvokeScript Call:
HRESULT InvokeScript(LPCOLESTR lpszName, VARIANT* pvarParam1 = NULL,
VARIANT* pvarRet = NULL) {
CComPtr<IHTMLDocument2> pDocument; m_pBrowser->get_Document( (LPDISPATCH
*) &pDocument );
CComPtr<IDispatch> spDisp; pDocument->get_Script(&spDisp);
CComDispatchDriver dd(spDisp);
if (pvarParam1 == NULL)
return dd.Invoke0(lpszName, pvarRet);
else
return dd.Invoke1(lpszName, pvarParam1, pvarRet);
}
HRESULT Invoke0(LPCOLESTR lpszName, VARIANT* pvarRet = NULL) throw(){
HRESULT hr;
DISPID dispid;
hr = GetIDOfName(lpszName, &dispid);
if (SUCCEEDED(hr))
hr = Invoke0(dispid, pvarRet);
return hr;
}
BTW, whether or not the memory should be moveable is up for argument whether
or not it's necessary as it appears to be a hangover from win16 as discussed
here:http://groups-beta.google.com/group/microsoft.public.win32.programmer.k
ernel/browse_frm/thread/356132bb1e8d37e8/a18ac6924c804a36?q=CreateStreamOnHG
lobal+group:microsoft.public.*&_done=%2Fgroups%3Fas_q%3DCreateStreamOnHGloba
l%26safe%3Dimages%26as_ugroup%3Dmicrosoft.public.*%26lr%3D%26hl%3Den%26&_don
eTitle=Back+to+Search&&d#a18ac6924c804a36
Peter
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:OfmiKN1GFHA.2276@TK2MSFTNGP15.phx.gbl...
> "Peter Carlson" <peter@__N.O.S.P.A.M__howudodat.com> wrote in message
> news:%23EFTrI1GFHA.2276@TK2MSFTNGP15.phx.gbl
> > 1. OnNavComplete is called again after pPersistStreamInit->Load.
> > How can I determine if the nav is from the Load() or from the
> > Navigate()? I can bandaid it with my own BOOL variable since I know
> > the states, and in this app it's fine, but that's not very portable.
>
> What do you mean, not portable? Not portable between what platforms?
>
> IPersistStreamInit::Load is an asynchronous operation. MSHTML treats it
> as a regular navigation request and fires full complement of events,
> including NavigateComplete2 and DocumentComplete.
>
> > 2. GlobalFree() crashes...any idea why? I must not be releasing
> > something.
> >
> > void Write2(CString &strHtml) {
> > IStream* pStream = NULL;
> > HGLOBAL hHTMLText = GlobalAlloc( GPTR, strHtml.GetLength() + 1 );
>
> The documentation for CreateStreamOnHGlobal is clear: "The handle must
> be allocated as movable and nondiscardable". GPTR implies GMEM_FIXED.
>
> > HRESULT hr = CreateStreamOnHGlobal( hHTMLText, TRUE, &pStream
> > );
>
> Since you pass TRUE as the second parameter of CreateStreamOnHGlobal,
> you pass the ownership of the handle to the stream object. You should
> not GlobalFree it, you just need to release the stream.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
- Next message: Peter Carlson: "IPersistStreamInit to Append Text"
- Previous message: sharrukin amiri: "IE Browser Links"
- In reply to: Igor Tandetnik: "Re: Pls Help with empty Print Preview"
- Next in thread: Igor Tandetnik: "Re: Pls Help with empty Print Preview"
- Reply: Igor Tandetnik: "Re: Pls Help with empty Print Preview"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|