Solved

Capturing refresh event on IE

Posted on 2001-08-20
7
1,757 Views
Last Modified: 2013-12-03
Am trying to capture the Refresh event of a html page.
I am using an activeX component that implement few inerfaces and sink dwebbrowserevents as well but didn't find a way I could capture the 'refresh' event (the browser won't send a 'BeforeNavigate' nor 'Document/DownloadComplete').
The best I could come to (so far) is capturing the onbeforeunload (of the IHTMLWindow2 obj) of the document and distinguish between a case where the browser had a 'BeforeNavigate' event just  before the onbeforeunload event initiated. Still it's kinda screwy way...
Looking 4 help!
0
Comment
Question by:GuyK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6405576
have you tried dwebbrowserevents2 ?
0
 

Author Comment

by:GuyK
ID: 6405597
Am trying to capture the Refresh event of a html page.
I am using an activeX component that implement few inerfaces and sink DWEBBROWSEREVENTS2 as well but
didn't find a way I could capture the 'refresh' event (the browser won't send a 'BeforeNavigate/2' nor
'Document/DownloadComplete/2').
The best I could come to (so far) is capturing the onbeforeunload (of the IHTMLWindow2 obj) of the document
and distinguish between a case where the browser had a 'BeforeNavigate' event just  before the onbeforeunload
event initiated. Still it's kinda screwy way...
Looking 4 help!

(see corrections...)
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6406008
strange that you are not seeing a BeforeNavigateEvent - I have not trouble seeing that event at all

How have you set up the receiving of events? code sample could be useful here
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:GuyK
ID: 6406075
Hi Shaun,
Strange your browser fires a 'BeforeNavigate' event because mine doesn't.
Let me add more details:
I'm using IE5 on OS Windows 2000.

If it helps, here's the code:

******* CWBMyHost.h **********
class CWBMyHost:
public.......
....
....
public IDispEventImpl<0, CWBMyHost, &__uuidof(SHDocVw::DWebBrowserEvents2), &LIBID_SHDocVw, 1, 0>,
public...

.
.
.
.
BEGIN_SINK_MAP(CWBMyHost)
   SINK_ENTRY_EX(0, (__uuidof(SHDocVw::DWebBrowserEvents2)), DISPID_DOCUMENTCOMPLETE, NavigateComplete)
   SINK_ENTRY_EX(0, (__uuidof(SHDocVw::DWebBrowserEvents2)), DISPID_BEFORENAVIGATE2, BeforeNavigate)
END_SINK_MAP()
.
.
.
.
STDMETHOD(NavigateComplete)(IDispatch* pDisp, VARIANT* URL);
STDMETHOD(BeforeNavigate)(IDispatch *pDisp,
               VARIANT *URL,
               VARIANT *Flags,
               VARIANT *TargetFrameName,
               VARIANT *PostData,
               VARIANT *Headers,
               VARIANT_BOOL *Cancel);
.
.
.
.
};

******* CWBMyHost.cpp **********

.
.
.
STDMETHODIMP CWBMyHost::NavigateComplete(IDispatch* pDisp, VARIANT* URL)
{
...
}

STDMETHODIMP CWBMyHost::BeforeNavigate(IDispatch *pDisp,
    VARIANT *URL,
    VARIANT *Flags,
    VARIANT *TargetFrameName,
    VARIANT *PostData,
    VARIANT *Headers,
    VARIANT_BOOL *Cancel
)
{
...
}

.
.
.

But I don't think the code is problematic (in this manner) because I do get these events when I navigate (through links or through the back/forward buttons)


0
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 119 total points
ID: 6406310
oops you right - my refresh button - was an actual wrapped Navigate() with the last URL (strange what you do late at night and can't remeber why) - you do get a downloadbegin/complete events which you can use - eg if you get a download complete without a BeforeNavigate then it must be a refresh
0
 

Author Comment

by:GuyK
ID: 6409026
Sometimes the answer is right under your nose but you need someone (usually from the outside) to show it to you.
This is just what you did. Thanks
p.s.
I know it looks obvious but still - thanks a lot
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6409039
glad to help :)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question