import win.ui;
import win.clip;
import win.util.tray;
/*DSG{{*/
var pageCode = win.form(parent=...; right=349;text="代码生成";bottom=249 )
pageCode.add( 
editCode={ dr=1;dl=1;vscroll=1;color=0;right=342;left=8;dt=1;db=1;cls="richedit";bottom=211;link=1;wrap=1;multiline=1;top=8;font=LOGFONT( name="Courier New";h=-12;out=3;family=49;clip=2;quality=1 );z=1;edge=1;text="" };
btnCopy={ dl=1;bottom=240;text="复制(&C)";left=8;top=217;font=LOGFONT( name="宋体";h=-12 );z=2;db=1;right=75;cls="button" };
btnRun={ dl=1;bottom=240;text="运行(F5)";left=79;top=217;font=LOGFONT( name="宋体";h=-12 );z=3;db=1;right=152;cls="button" }
)
/*}}*/

// 代码复制
pageCode.btnCopy.oncommand = function(id,event){
	win.clip.write(pageCode.editCode.text);
	win.util.tray.pop("代码复制成功","网页表单神捕");
}
// 测试运行
pageCode.btnRun.oncommand = function(id,event){
	import win;
	import thread;
	thread.create(function (code) {
		try {
			var fun, err = loadcode(code);
			if (!fun)
				win.msgbox(err, "错误：", 0x30/*_MB_ICONEXCLAMATION*/);
			else
				fun();
		} catch (e) {
			win.msgbox(e, "错误：", 0x30/*_MB_ICONEXCLAMATION*/);
		}
	}, pageCode.editCode.text);
}
pageCode.editCode.wndproc = function(hwnd,message,wParam,lParam){
	if (message == 0x100/*_WM_KEYDOWN*/)
		if (wParam == 0x74/*_VK_F5*/)
			pageCode.btnRun.oncommand();
}

pageCode.show();
win.loopMessage();
return pageCode;
