import com.interface.IOleControl  
import web.form;
namespace web.form.util;
import win.reg;

::Urlmon := ..raw.loadDll("Urlmon.dll")
UrlMkSetSessionOption = Urlmon.api("UrlMkSetSessionOption","int(INT option, pointer buffer,INT len,pointer reserved)" )

var  IOleControl = ..com.interface.IOleControl 

ambientPropertyChange = function(wb,id){
	var doc = wb.document;
	var ctrl = IOleControl.Query( doc)   
	ctrl.OnAmbientPropertyChange(id)
	ctrl = null; 
	collectgarbage("collect")	
}

dlCtrl = function(wb,dlctl){
	wb.dlControl = dlctl;
	ambientPropertyChange(wb,-5512) 
}

setUserAgent = function(wb,agent){ 
	wb.agent = agent;
	UrlMkSetSessionOption(agent?0x10000001:0x10000002,agent,#agent);
	ambientPropertyChange(wb,-5513) 
	
}

refreshOption = function(){
	UrlMkSetSessionOption(  39/*_INTERNET_OPTION_SETTINGS_CHANGED*/, ,0 );
	UrlMkSetSessionOption(  37/*_INTERNET_OPTION_REFRESH*/, ,0  ); 
    ::SendMessage(0xFFFF/*_HWND_BROADCAST*/, 0x1A/*_WM_WININICHANGE*/)
}


enableTab = function(v=1){
    var tpath = ..io.splitpath( ..io._exepath )
	var reg = win.reg("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_TABBED_BROWSING")
	if( reg.queryValue(tpath.file) ){
		reg.close(); 
		return;
	}
	reg.setDwValue( tpath.file,v?1:0)
	reg.close()
	refreshOption() 
}

 
/**intellisense(web.form.util)
dlCtrl(wb,_DLCTL__) =  修改web窗体下载控制参数
dlCtrl(wb) = 恢复默认设置
dlCtrl(wb,0) = 禁止下载图片
setUserAgent(wb) = 恢复默认useragent
setUserAgent(wb,"AAuto Explorer") = 恢复默认useragen
enableTab() = 启用tab选项卡支持
enableTab(false) = 禁用tab选项卡支持
refreshOption() = 刷新web设置
end intellisense**/
