窗口控件数据绑定到指定目录

tanzh 2023-8-19 849

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="Button";left=64;top=416;right=168;bottom=448;z=2};
calendar={cls="calendar";left=224;top=240;right=440;bottom=416;edge=1;z=11};
checkbox={cls="checkbox";text="Checkbox";left=416;top=40;right=520;bottom=88;z=3};
checklist={cls="checklist";left=64;top=240;right=192;bottom=328;edge=1;items={"1";"2";"3";"4";"5"};z=10};
combobox={cls="combobox";left=224;top=144;right=384;bottom=168;edge=1;items={"1";"2";"3"};mode="dropdown";z=8};
datetimepick2={cls="datetimepick";left=224;top=200;right=312;bottom=224;edge=1;z=12};
edit={cls="edit";text="Edit";left=64;top=40;right=192;bottom=120;edge=1;multiline=1;z=1};
edit2={cls="edit";text="Edit";left=528;top=296;right=576;bottom=392;edge=1;multiline=1;z=14};
edit3={cls="edit";text="Edit";left=600;top=296;right=728;bottom=392;edge=1;multiline=1;z=15};
listbox={cls="listbox";left=64;top=144;right=192;bottom=216;edge=1;items={"1";"2";"3"};z=7};
plus={cls="plus";text="文字";left=408;top=144;right=504;bottom=170;border={bottom=1;color=-6908266};editable=1;font=LOGFONT(h=-13);textPadding={top=6;bottom=2};z=9};
progress={cls="progress";left=560;top=144;right=696;bottom=174;edge=1;max=100;min=1;z=4};
radiobutton={cls="radiobutton";text="Radiobutton";left=560;top=40;right=696;bottom=88;z=6};
richedit={cls="richedit";text="RichEdit";left=224;top=40;right=384;bottom=120;edge=1;multiline=1;z=5};
splitter={cls="splitter";left=584;top=296;right=592;bottom=392;frame=1;z=16};
static={cls="static";text="中间拆分条调整左右控件宽度";left=528;top=408;right=728;bottom=432;transparent=1;z=17};
trackbar={cls="trackbar";left=560;top=224;right=696;bottom=254;max=100;min=0;z=13}
)
/*}}*/

import console; 
import process
import fsys.config;

//将窗口控件数据绑定到指定目录

//config = fsys.config("/config/"); //程序目录
path = ..fsys.getSpecial( 0x1c /*_CSIDL_LOCAL_APPDATA*/ ,"/aardio/" ); //保存配置数据到应用目录
config = ..fsys.config(path);
config.userSetting.name = "hello"; //config指定目录下自定义userSetting表

import win.ui.scrollbar;
var vScrollBar = win.ui.scrollbar(winform,true); //垂直true

winform.splitter.split(winform.edit2,winform.edit3); //中间拆分条调整左右控件宽度

//配置文件 config.winformCfg
winform.bindConfig( config.winformCfg,{ //config指定目录下的winformCfg表
    edit = "text";
    edit2 = "text";
    edit3 = "text";
    richedit = "text";
    checkbox = "checked";
    radiobutton = "checked";
    listbox = "selIndex";
    combobox = "selIndex";
    plus = "text";
    progress = "pos";
    checklist = "checked";
    datetimepick2 = "text"; //time("y/m/d")
    //calendar = "text"; //tostring(winform.calendar.time)
    trackbar = "pos";
    //splitter = "text";
} );

//winform.progress.pos = 50;
winform.datetimepick2.time = time(config.winformCfg.datetimepick2); //config转换

winform.button.oncommand = function(id,event){
	process.execute(path)
}

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


最新回复 (3)
  • lcj21 2023-8-19
    0 2
    这个实用,学习一下,感谢分享!
  • lcj21 2023-8-19
    0 3
    拆分条数据似乎无法绑定
  • tanzh 2023-8-19
    0 4

    splitter也可以绑定的

    winform.edit2.width = config.userSetting.edit2_width; //config转换
    
    winform.splitter.wndproc = function(hwnd,message,wParam,lParam){
    	select(message) {
    		case (0x201/*_WM_LBUTTONDOWN*/ and 0x200/*_WM_MOUSEMOVE*/) {
    			config.userSetting.edit2_width = winform.splitter.ltControl.width; //winform.edit2.width;
    		}
    	}
    }


返回