Re: Pls Help with empty Print Preview

From: Peter Carlson (peter_at___N.O.S.P.A.M__howudodat.com)
Date: 02/25/05


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
>
>



Relevant Pages

  • Re: IWMWriterNetworkSink::Close() - The code
    ... connect to the second stream using a mediaplayer ... Helper function to convert a TCHAR string to a WCHAR string. ... HRESULT ConvertTCharToWChar(TCHAR * ptszInput, WCHAR ** ppwszOutput) ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Displaying WMV from a stream with the WM ASF Reader Filter in a filter graph
    ... stream ). ... It uses DS Pack 2.3.4 and the DS filters from oggDS0995.exe The filter ... function TBCFileStream.SetPointer: HResult; ... inherited Create('File reader', nil, AStream, hr); ...
    (comp.lang.pascal.delphi.misc)
  • Re: Displaying WMV from a stream with the WM ASF Reader Filter in a filter graph
    ... file from a stream (here a TStream (TFileStream)). ... function TmyProtStream.Commit: HResult; ...
    (comp.lang.pascal.delphi.misc)
  • Re: some water resources for the Upper Midwest
    ... the stream is navigable, you can navigate it unfettered -- no trespass laws apply, no matter who owns the land it runs through. ... much hinges on the definition of a navigable stream. ... happens to be the Eastern Continental Divide) behind my family's house and down the other side, there's a creek by the name of John's Creek. ... But, you see, this particular stretch happens to run through private land. ...
    (rec.arts.sf.composition)
  • Re: Loading XML into WebBrowser
    ... >>> I also noticed that even when you Navigate to an XML file which is ... >>> It's the raw XML. ... > I ran across a technique for loading MHTNL in WebBrowser using an APP ... So, if you have your XML in a stream, you would build an APP that took ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)