From: http://blog.csdn.net/sheds/archive/2007/02/14/1510232.aspx
In vc7, The chtmlview class itself has an onnavigateerror event response.
However, vc6 does not. After some experiments, we can find the following method to add this response for vc6:
For example, chtmlctrl
Add the following content to the header file:
# Define dispid_navigateerror 271
Declare_eventsink_map ()
Public:
Virtual void navigateerror (lpdispatch Pdisp, variant * pvurl,
Variant * pvframe, variant * pvstatuscode, variant_bool * pvbcancel );
Virtual void onnavigateerror (maid, maid, DWORD dwerror, bool * pbcancel );
Add the following content to the CPP file:
Begin_eventsink_map (chtmlctrl, chtmlview)
On_event (chtmlctrl, afx_idw_pane_first, dispid_navigateerror, navigateerror, vts_dispatch vts_pvariant vts_pbool)
End_eventsink_map ()
....
Void chtmlctrl: navigateerror (lpdispatch Pdisp, variant * pvurl,
Variant * pvframe, variant * pvstatuscode, variant_bool * pvbcancel)
{
Unused_always (Pdisp );
Assert (pvurl! = NULL );
Assert (pvframe! = NULL );
Assert (pvstatuscode! = NULL );
Assert (pvbcancel! = NULL );
Assert (v_vt (pvurl) = vt_bstr );
Assert (v_vt (pvframe) = vt_bstr );
Cstring strurl (v_bstr (pvurl ));
Cstring strframe (v_bstr (pvframe ));
DWORD dwerror = v_i4 (pvstatuscode );
Bool bcancel = false;
// Define y the user's class
Onnavigateerror (strurl, strframe, dwerror, & bcancel );
If (pvbcancel)
* Pvbcancel = bcancel? Afx_ole_true: afx_ole_false;
}
Void chtmlctrl: onnavigateerror (lpctstr lpszurl, lpctstr lpszframe, DWORD dwerror, bool * pbcancel)
{
// Default to continuing
* Pbcancel = false;
// User will override to handle this notification
Unused_always (lpszurl );
Unused_always (lpszframe );
}
In this way, the chtmlview inheritance class of vc6 has the onnavigateerror response method.
Reference: http://www.codeguru.com/forum/archive/index.php/t-74676.html
Http://www.itzhe.cn/article/20080119/57559.html