Re: Problem understanding how WebBrowser Control communicates with APP

From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 04/23/04


Date: Fri, 23 Apr 2004 11:19:51 -0400


"Martin Payne" <martin@microcosm.co.uk> wrote in message
news:40892e4c.24052535@news.eclipse.co.uk
>>> I am writing my own APP for file protocol and it is OK but not for
>>> this page. It only displays a small part of image1 because it
>>> quickly gives up and starts looking for image2.
>>
>> Huh? For each download operation, a new instance of an APP is
>> created. Each instance should maintain its own state. It looks like
>> you share state between all instances - that's a bug in your design.
>> Fix it.
>
> Are you saying that each time a new file is requested I should create
> a new instance of this class?

Yes. That's why you register a class factory with the IInternetSession,
not the APP itself. The class factory should manufacture new instances
on demand.

> How do I do that? (sorry I am not so
> experienced at C++). How do I know when to do it?

When your implementation of IClassFactory::CreateInstance is called,
you - surprise - create an instance.

> Should I call register each time or just once when the browser is
> first created (that is what I currently do).

You need to register once per process.

>> ReportData may be called many times, as the data gets downloaded and
>> becomes available. This is expected behavior.
>
> However, if I am writing the APP how many times should I call it?

As many or as few as you want. If you have all the data available at
once, call it once. If, as is typical with HTTP and similar protocols,
the data arrives in chunks over time, you may call it multiple times to
report each chunk.

-- 
With best wishes,
    Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Relevant Pages


Quantcast