CDHtmlDialog中阻止某页面的显示

.h文件中:
DECLARE_EVENTSINK_MAP()
void XOnBeforeNavigate2(LPDISPATCH pDisp,        
			VARIANT FAR* URL,        
			VARIANT FAR* Flags,        
			VARIANT FAR* TargetFrameName,        
			VARIANT FAR* PostData,        
			VARIANT FAR* Headers,        
			BOOL FAR* Cancel);
 
.cpp文件中:
BEGIN_EVENTSINK_MAP(CTestHtml, CDHtmlDialog) 
	ON_EVENT(CTestHtml, AFX_IDC_BROWSER, 250 , XOnBeforeNavigate2,\  	
	VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
END_EVENTSINK_MAP()
void CTestHtml::XOnBeforeNavigate2(LPDISPATCH pDisp,              
				VARIANT FAR* URL,              
				VARIANT FAR* Flags,              
				VARIANT FAR* TargetFrameName,              
				VARIANT FAR* PostData,              
				VARIANT FAR* Headers,              
				BOOL FAR* Cancel)
{ 
	CString unicodeUrl(V_BSTR(URL)); 
	if (unicodeUrl.Left(2).Right(1) == _T(":")) 
  		*Cancel = TRUE;//阻止显示当前页面 
	else 
  		OnBeforeNavigate(pDisp, unicodeUrl);//正常显示当前页面 
}


重载OnBeforeNavigate,直接return,不行!

你可能感兴趣的:(CDHtmlDialog,阻止页面显示)