//..默认库 挂接外部浏览器
import web.form.util;
namespace web; 
 
var IID_IHTMLDocument = ..win.guid.fromString("{626FC520-A41E-11CF-A731-00A0C9082637}")
class access{

	ctor( hwnd )begin
		 
		this._form = {hwnd = hwnd ;web = this}
		
		var err; 
		try{ 
			this._document = getAccessibleObject(hwnd,IID_IHTMLDocument) 
	 		this._object = ..web.form.util.queryBrowser(this._document.parentWindow)
	 		this._browser = this._object; 
		}
		catch(e){ 
			err = e; 
		}
		if(!this._browser)
			return null, err;
		
		var sink, cookie 	
		try{
			sink, cookie =..com.Connect(this._browser, this );
		}
		
		..table.add_gc(this,function(){
			if(cookie){
				..com.ReleaseConnection(this._browser);  
			};
			..com.Release(this._browser) 
			..com.Release(this._document )
		});
		
	end; 
	 
	@_metaProperty;
}
 
namespace access { 

	var dll = ..raw.loadDll("OLEACC.DLL");
	ObjectFromLresult := dll.api("ObjectFromLresult","int(int lResult,struct riid,int wParam,pointer &ppvObject)" ); 
	WM_HTML_GETOBJECT = ::RegisterWindowMessage("WM_HTML_GETOBJECT"); 
	getAccessibleObject = function (hwnd,iid){ 
		var re, res = ::SendMessageTimeout (hwnd, WM_HTML_GETOBJECT, , , 0x2/*_SMTO_ABORTIFHUNG*/,1000,0)  
		var re,unknown = ObjectFromLresult(res, iid , 0 );
		//将一个 C指针转换为com对象
		var doc = ..com.QueryObject( unknown );
		..com.Release(unknown);
		return doc;
	}

	_metaProperty =  ..web.form._metaProperty  
}
 
//自动提示
/******intellisense( ) 
web.access = 外部浏览器支持库\n支持所有使用系统置浏览控件的窗口,包括所有IE内核浏览器.
web.access( __/*网页窗口句柄*/ ) = 连接外部浏览器 
?web.access = !wb.  
end intellisense******/


 

 