//inputBox 输入框 import win.ui; import win.ui.ctrl.edit; import win.ui.ctrl.button; import win.ui.ctrl.static; namespace win; class inputBox{ ctor(parent,prompt,title,default,cueBannerText,password){{ var promptType = type(prompt); if( promptType == "boolean" ){ password = prompt; prompt = null; } elseif( promptType == "string" ){ if(password===null) password = ..string.find(prompt,"<密码>|<密钥>|"); } this = ..win._form(text=title||"输入框";right=442;bottom=137;border="dialog frame";exmode="none";max=false;min=false;mode="popup";parent=parent) this.add( btnCancel={cls="button";text="取消";left=298;top=87;right=372;bottom=115;db=1;dr=1;z=2}; btnOk={cls="button";text="确定";left=205;top=87;right=279;bottom=115;db=1;dr=1;style=1;z=1}; info={cls="static";text=prompt||"请输入:";left=20;top=20;right=350;bottom=38;dl=1;dt=1;notify=1;transparent=1;z=4}; input={cls="edit";text=default;left=20;top=46;right=423;bottom=71;dl=1;dt=1;dr=1;edge=1;password=password;z=3} ) this.onInitDialog = function(hwnd,message,wParam,lParam){ this.input.setFocus(); }; this.btnCancel.oncommand = function(id,event){ this.endModal(); }; this.btnOk.oncommand = function(id,event){ this.endModal( this.input.text ); }; this.onOk = function(){ this.endModal( this.input.text ); }; this.onCancel = function(){ this.endModal(); }; if(cueBannerText){ this.input.setCueBannerText(cueBannerText,true); } }} } ..win.ui.ctrl.metaProperty.mixin({ inputBox = function(...){ var dlg = ..win.inputBox(owner,...); return dlg.doModal(); } }) /***intellisense() win.inputBox = 输入对话框。\n导入此库以后自动为所有窗口或控件对象添加 inputBox 函数。\n窗体控件的 inputBox 成员函数不需要指定父窗体参数,且直接返回输入结果。 win.inputBox( = 创建输入对话框。 win.inputBox(.(parent,prompt,title,default,cueBannerText,password) = 创建输入对话框,返回 win.form 对象。\n- @parent 参数指定父窗体或控件对象,必填。\n- @prompt 参数指定在输入框上面一排显示的输入提示,单行文本,必填。\n- @title 参数指定对输入对话框窗口标题,可选。\n- @default 参数指定输入框中显示的默认文本,可选。\n- @cueBannerText 参数指定输入框为空时在输入框内部以浅色字体显示的提示,可选。\n- @password 参数输入字符是否显示为星号,可选。\n如果 @prompt 参数包含"密码","密钥","password"则 @password 默认为 true。 win.inputBox() = !wininputBox. end intellisense***/ /***intellisense(!wininputBox) doModal() = 弹出输入对话框\n该函数返回用户输入的值\n取消则返回null空值 onInitDialog = @.onInitDialog = function(hwnd,message,wParam,lParam){\n ??.center()__/*输入框初始化完成触发该函数*/\n} center() = 居中显示 info = !edit. input = !edit. text = 输入框标题 setPos(.(x,y,宽,高,插入位置,参数) = 调整窗口位置或排序\n所有参数可选 getPos() = 返回相对坐标,宽,高 topmost()=窗体始终最前 topmost(false)=取消窗体始终最前 modifyStyle(.(remove,add,swpFlags) = 修改窗口样式,所有参数都是可选参数,\n@remove 用数值指定要移除的样式,可使用 _WS_ 前缀的常量\n@add 用数值指定要添加的样式,可使用 _WS_ 前缀的常量\n@swpFlags 可选用数值指定调整窗口选项,可使用 _SWP_ 前缀的常量\n如果指定了 @swpFlag ,则使用该参数调用::SetWindowPos\n细节请参考 win.modifyStyle 函数源码 modifyStyleEx(.(remove,add,swpFlags) = 修改窗口扩展样式,所有参数都是可选参数,\n@remove 用数值指定要移除的样式,可使用 _WS_EX_ 前缀的常量\n@add 用数值指定要添加的样式,可使用 _WS_EX_ 前缀的常量\n@swpFlags 可选用数值指定调整窗口选项,可使用 _SWP_ 前缀的常量\n如果指定了 @swpFlag ,则使用该参数调用::SetWindowPos\n细节请参考 win.modifyStyle 函数源码 setInterval(回调函数,延时毫秒数,->->->) = @.setInterval( \n function(){\n __/*参数@1指定执行函数,参数@2指定执行间隔,\n可选指定一个或多个回调参数,不指定回调参数则默认为:\n hwnd,message,timerId,tick,\n\n如果在定时器中执行了win.delay等继续消息循环的代码,\n在定时器退出前不会再触发同一定时器(重入)。\n\n定时器回调函数返回数值可修改时间间隔,\n返回false取消该定时器*/\n },1000 \n) clearInterval(__/*请输入ID*/) = 删除定时器 changeInterval(__/*请输入ID*/,1000) = 重新设定定时器的延时时间 setTimeout(.(函数名,延时,其他参数) = 延时执行函数 width = 设置对话框宽度。\n\n在窗口显示或其他方式自动或手动调用 enableDpiScaling 前修改此值,\n则会在 enableDpiScaling 被调用时自动缩放,\n否则设置或获取当前真实宽度。\n\n可调用 dpiScale 函数获取缩放后的宽度 dpiScale(.(x,y) = 将 @x,@y 表示的像素值乘以窗体当前 DPI 缩放倍数并返回,\n省略 @y 参数时仅返回 @x 转换后的值 bgcolor = 设置窗口背景颜色。\n使用 GDI 颜色值,例如 0xFFFFFF 为白色 end intellisense***/