import win.ui;
/*DSG{{*/
var winform = win.form(text="查找";right=418;bottom=135;bgcolor=16777215;exmode="none";max=false;min=false;mode="popup")
winform.add(
btnSearchNext={cls="button";text="查找下一个(F)";left=218;top=83;right=306;bottom=113;db=1;dl=1;font=LOGFONT(name='微软雅黑');z=1};
btnSearchPrev={cls="button";text="查找下上个(V)";left=119;top=83;right=207;bottom=113;db=1;dl=1;font=LOGFONT(name='微软雅黑');z=2};
button={cls="button";text="关闭";left=327;top=82;right=386;bottom=112;db=1;dl=1;font=LOGFONT(name='微软雅黑');z=4};
checkbox={cls="checkbox";text="区分大小写";left=19;top=60;right=111;bottom=87;bgcolor=16777215;font=LOGFONT(h=-14);z=6};
checkbox2={cls="checkbox";text="单元格匹配";left=19;top=92;right=111;bottom=119;bgcolor=16777215;font=LOGFONT(h=-14);z=7};
editSearchInput={cls="combobox";left=81;top=15;right=392;bottom=41;db=1;dl=1;edge=1;font=LOGFONT(name='微软雅黑');items={};mode="dropdown";z=3};
static={cls="static";text="查找内容：";left=12;top=16;right=72;bottom=42;align="right";bgcolor=16777215;center=1;db=1;dl=1;font=LOGFONT(name='微软雅黑');transparent=1;z=5}
)
/*}}*/

/*
窗口会自动检测默认的对话框快捷键，
默认Enter会触发onOk事件，ESC键会触发onCancel事件，
可选如下自定义检测对话框快捷键函数 winform.isDialogMessage
*/
winform.isDialogMessage = function(hwnd,msg){
	if( msg.message == 0x100/*_WM_KEYDOWN*/){
		
		if(  msg.wParam == 0xD/*_VK_RETURN*/ ){ 
			//return true;//告诉消息处理函数这是一个快捷键,阻止按键消息继续分发
		}
		
		if( msg.wParam == 0x1B/*_VK_ESC*/ ){
			//return true;//告诉消息处理函数这是一个快捷键,阻止按键消息继续分发
		} 
	}
	
	//检测并响应默认快捷键
	return win.isDialogMessage(hwnd,msg);
}

winform.onCancel = function(){
    winform.show(false);
}

pushSearchNext = function(){
	publish("search_next", winform.editSearchInput.text, winform.checkbox.checked, winform.checkbox2.checked);
}

winform.onOk = function(){
  	pushSearchNext();
}

winform.btnSearchPrev.oncommand = function(id,event){
	publish("search_prev", winform.editSearchInput.text);
}

winform.btnSearchNext.oncommand = function(id,event){
  	pushSearchNext();
}

winform.button.oncommand = function(id,event){
	winform.show(false);
}

winform.btnSearchPrev.disabled = true;

winform.editSearchInput.setFocus();

winform.onClose = function(hwnd,message,wParam,lParam){
    winform.show(false);
    return false;//禁止关闭
}

winform.show(false);
win.loopMessage();
return winform;