Re: Reload detection



Thank you very much for your answer! The proposed method is a good way
to identify a refresh, but if I want to cancel the operation I think it's too late
to detect it in DownloadBegin. Please correct me if I'm wrong.
Right now I'm considering trying to implement an Asynchronous Pluggable
Protocol handler to solve the problem. Could an APP handler be used to
detect and cancel a refresh request from the web browser control? Igor, is
that feasible?
Regards
Jan

Jan Ostedt
www.learnware.se

do you think about that
On Thu, 14 Jun 2007 06:28:23 -0700, mh <mehr13@xxxxxxxxxxx> wrote:

On Jun 12, 10:40 am, Jan Ostedt <ost...@xxxxxxxxxx> wrote:
Hello!
I'm using MFC (CHtmlView). I would like to trap a page refresh at an early stage to be able to
cancel it.
If the page refresh is caused by a meta tag I'm able to trap the event in BeforeNavigate2, but
if the page refresh is caused by javascript (location.reload()) I'm not able to trap the event at all.
How can that be done?
I have implemented IOleCommandTarget in order to catch OLECMDID_PREREFRESH. I succeeded
to catch the call, but it seems to take place very late in the reload process (in spite of its name) , so that
didn't work. I've worked on this for a while so I would really appreciate if someone could help me out.
Thanks in advance!
Best Regards
Jan

1) Add three variables:

// counter to monitor number of requests to BeforeNavigate2 vs number
of requests to DownloadBegin.
int m_nPageCounter;
// counter to monitor number of DownloadBegin and DownloadEnd calls.
int m_nObjCounter;
// variable to tell us whether a refresh request has started.
BOOL m_bIsRefresh;

2) In BeforeNavigate2 add:

m_nPageCounter++;

3) In DocumentComplete add:

m_nPageCounter--;
if( (m_bIsRefresh) && (m_nPageCounter == 0) && (m_nObjCounter == 0) )
{
//Refresh end
m_bIsRefresh = FALSE;
}

4) In DownloadBegin add:

m_nObjCounter++;
//Refresh started
if(m_nPageCounter == 0)
{
m_bIsRefresh = TRUE;
}

5) In DownloadComplete add

m_nObjCounter--;
//Refresh Ended
if( (m_bIsRefresh) && (m_nPageCounter == 0) && (m_nObjCounter == 0) )
{
m_bIsRefresh = FALSE;
}

Hope this helps
MH

.



Relevant Pages

  • Re: JScript exec from BHO
    ... heh..the problem was with a script which i've tried to cancel.. ... The only events that are fired upon refresh are ... > DownloadBegin and DownloadComplete. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: How to detect page refresh in vc++
    ... DownLoadBegin function then this message box is coming so many times ... If I don't do page refresh or don't do any page navigation also.Why ... page navigation or page refresh.If my query returns with no value,then ...
    (microsoft.public.vc.atl)
  • Re: Reload detection
    ... I would like to trap a page refresh at an early stage to be able to ... of requests to DownloadBegin. ... // counter to monitor number of DownloadBegin and DownloadEnd calls. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: Refresh Cancels Window OnError Event?
    ... Refresh does not generate the ... DownloadBegin and DownloadComplete. ... reset your handler in DownloadComplete. ... > "Igor Tandetnik" wrote in message ...
    (microsoft.public.vc.atl)
  • Re: How to detect page refresh in vc++
    ... DownLoadBegin function then this message box is coming so many times ... The tricky part is actually working out if the refresh button was hit. ... On DownloadEndwe decrease the counter from DownloadBegin. ... BTW, I found the article by googling "refresh dispid_documentcomplete". ...
    (microsoft.public.vc.mfc)