一。
//编辑listbox import win.ui; /*DSG{{*/ var winform = ..win.form( bottom=249;parent=...;right=349;text="AAuto Form" ) winform.add( listbox={ bgcolor=16777215;bottom=192;right=284;left=75;top=36;z=1; items={ "ddddddddddd";"cccc";"双击编辑" };edge=1;cls="listbox" } ) /*}}*/ var lstEdit = winform.listbox.addCtrl( edit = { cls="edit"; left=0;top=0;right=50;bottom=50; autoResize=false ; hide=1; edge=1; wndproc = function(hwnd,message,wparam,lparam){ if( message == 0x8/*_WM_KILLFOCUS*/ // 失去焦点 || (message==0x101/*_WM_KEYUP*/ && wparam == 0xD/*_VK_ENTER*/) ) { if( owner.selIndex){ winform.listbox.add(owner.text,owner.selIndex) winform.listbox.delete(owner.selIndex+1) owner.hide = true; winform.listbox.redraw() } } }; } ).edit winform.listbox.oncommand = function(id,event){ if( event == 0x2/*_LBN_DBLCLK*/ ){ var rc = owner.getItemRect( owner.selIndex ) rc.bottom += 5; lstEdit.setRect(rc) lstEdit.hide = false; lstEdit.text = winform.listbox.selText; lstEdit.selIndex = owner.selIndex ; } } winform.show() win.loopMessage();
二。
import win.ui; /*DSG{{*/ var winform = ..win.form( exmode="";bgcolor=15919331;bottom=249;parent=...;right=349;text="AAuto Form" ) winform.add( listbox={ bgcolor=16777215;bottom=192;right=284;left=75;top=36;z=1; items={ "ddddddddddd";"cccc";"双击编辑" };edge=1;cls="listbox" }; edit={ cls="edit";bottom=190;text="编辑";left=82;top=163;z=2;right=273;edge=1;hide=1 } ) /*}}*/ win.setParent( winform.edit.hwnd,winform.listbox.hwnd ) winform.listbox.oncommand = function(id,event){ if( event == 0x2/*_LBN_DBLCLK*/ ){ winform.edit.selIndex = winform.listbox.selIndex ; var rc = winform.listbox.getItemRect( winform.edit.selIndex ) rc.bottom += 5; win.setRect(winform.edit.hwnd,rc) winform.edit.hide = false; winform.edit.text = winform.listbox.selText; } } winform.edit.wndproc = function(hwnd,message,wparam,lparam){ ..io.print( message ) if( message == 0x8/*_WM_KILLFOCUS*/ || (message==0x101/*_WM_KEYUP*/ && wparam == 0xD/*_VK_ENTER*/) ) { if(winform.edit.selIndex){ winform.listbox.add(winform.edit.text,winform.edit.selIndex) winform.listbox.delete(winform.edit.selIndex+1) winform.edit.hide = true; winform.listbox.redraw() } } } winform.show() win.loopMessage();