import win.ui;
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; bottom=249;scroll=1;text="AAuto Form";right=349 )
winform.add(  )
/*}}*/

//创建web窗体
var wb = web.form( winform 
    ,0x8/*_UIFLAG_SCROLL_NO 禁用滚动条*/ );


import gdip
import com.interface.IViewObject2
snap = function(url,filepath,q){
    wb.go(url)
    wb.wait("");
    
    var viewObject2 = com.interface.IViewObject2.Query(wb._browser)
    
    var  height= wb.body.scrollHeight ;
    var  width = wb.body.scrollWidth;
    winform.setPos(0,0,width,height + ::GetSystemMetrics(0x4/*_SM_CYCAPTION窗口标题的高度*/) )
	win.setPos(wb.hwndEmbedding,0,0,width,height);
    
    var rc = winform.clientRect
    rc.bottom = height
    rc.right = width
    
    var hdc = ::GetDC(winform.hwnd)
    var hBitmap = ::CreateCompatibleBitmap(hdc , width,  height);  
    var hBitmapDC = ::CreateCompatibleDC(hdc);  
    ::SelectObject( hBitmapDC , hBitmap ); 
    ::ReleaseDC(winform.hwnd, hdc);
    
    viewObject2.Draw(0x1/*_DVASPECT_CONTENT*/,1, null , {}, hdc,  hBitmapDC,rc,{} ,null,0); 
    var bmp = gdip.bitmap(hBitmap,0)
    bmp.save(filepath,q)    
}

//将网页转换为图片
snap("http://www.sohu.com"
    ,"/websnap.jpg",100/*图像质量*/)

//浏览图片
import process
process.explore_select("/websnap.jpg")


//进入消息循环
win.loopMessage();
return winform,wb;
