aardio单行的edit控件响应回车按键消息
方法一:
import win.ui; /*DSG{{*/ var winform = win.form(text="edit响应回车按键消息";right=366;bottom=171) winform.add( edit={cls="edit";left=60;top=74;right=307;bottom=99;edge=1;z=1} ) /*}}*/ //你用消息回调不起作用,是因为回车键是对话框的快捷键之一 //你可以重写winform.isDialogMessage函数 winform.isDialogMessage = function(hwnd,msg){ if ( (msg.message >= 0x100/*_WM_KEYFIRST*/) && (msg.message <= 0x108/*_WM_KEYLAST*/) ) { if(msg.wParam==0xD/*_VK_ENTER*/){ return false //使回车键不是对话框快捷键 } } return win.isDialogMessage(hwnd,msg); } //那么这里就会起作用了 winform.edit.wndproc = function(hwnd,message,wParam,lParam){ if(message == 0x100/*_WM_KEYDOWN*/ && wParam == 0xD/*_VK_ENTER*/){ win.msgbox("按了回车!"); } //无返回值则继续调用默认回调函数 } winform.show() win.loopMessage(); return winform;
方法二:
import win.ui; /*DSG{{*/ var winform = win.form(text="edit响应回车按键消息";right=366;bottom=171) winform.add( edit={cls="edit";left=60;top=74;right=307;bottom=99;edge=1;z=1} ) /*}}*/ //响应按键弹起的消息 winform.edit.wndproc = function(hwnd,message,wParam,lParam){ if(message == 0x101/*_WM_KEYUP*/ && wParam == 0xD/*_VK_ENTER*/){ win.msgbox("按了回车!"); } //无返回值则继续调用默认回调函数 } winform.show() win.loopMessage(); return winform;