升级设计器

This commit is contained in:
2024-09-24 17:48:01 +08:00
parent cc72d4c6fc
commit 6d2f348019
10 changed files with 301 additions and 133 deletions
@@ -0,0 +1,124 @@
object fm_inheritedwnd:tfm_inheritedwnd
caption="通过继承构造窗口"
height=543
left=526
minmaxbox=false
onclose=fm_inheritedwnd_close
top=288
visible=false
width=433
object statusbar1:tstatusbar
caption="statusbar1"
height=25
left=0
top=479
width=417
end
object panel2:tpanel
align=albottom
caption="panel2"
height=31
left=0
top=448
width=417
wsdlgmodalframe=false
object label1:tlabel
left=399
top=0
width=18
height=31
caption=""
align=alright
end
object ed_ok:tbtn
align=alright
caption="确定"
enabled=false
height=31
left=308
onclick=ed_ok_clk
top=0
width=91
end
object label2:tlabel
left=283
top=0
width=25
height=31
caption=" "
align=alright
end
object bt_cancel:tbtn
align=alright
caption="取消"
height=31
left=195
onclick=bt_cancel_clk
top=0
width=88
end
end
object panel1:tpanel
align=altop
caption="panel1"
height=27
left=0
top=0
width=417
wsdlgmodalframe=false
object label3:tlabel
left=0
top=0
width=85
height=27
caption="可以继承:"
align=alleft
end
object ed_search:tedit
align=alclient
caption="edit1"
height=27
left=85
onchanged=ed_search_onchanged
onkeyup=ed_search_keyup
placeholder="搜索"
top=0
width=332
end
end
object panel3:tpanel
align=albottom
caption="panel1"
height=35
left=0
top=413
width=417
wsdlgmodalframe=false
object label4:tlabel
left=0
top=0
width=85
height=35
caption=" 名称:"
align=alleft
end
object ed_name:tedit
align=alclient
caption="edit1"
height=35
left=85
placeholder="名称"
top=0
width=332
end
end
object lbx_pal:tlistbox
align=alclient
caption="listbox1"
height=386
left=0
onselchanged=lbx_pal_sel
top=27
width=417
end
end
+133
View File
@@ -0,0 +1,133 @@
type tfm_inheritedwnd=class(tdcreateform)
uses tslvcl;
statusbar1:tstatusbar;
panel1:tpanel;
panel2:tpanel;
ed_ok:tbtn;
label1:tlabel;
label2:tlabel;
bt_cancel:tbtn;
label3:tlabel;
ed_search:tedit;
panel3:tpanel;
label4:tlabel;
ed_name:tedit;
lbx_pal:tlistbox;
function Create(AOwner);override; //构造
begin
fnds := array();
fnds2 := array();
fns := array();
inherited;
rc := _wapi.GetScreenRect();
left :=(rc[2]-rc[0])/2-280;
top :=(rc[3]-rc[1])/2-230;
end
function ed_search_keyup(o;e);
begin
case e.charcode of
VK_UP:
begin
idx := lbx_pal.ItemIndex;
if idx>0 then lbx_pal.ItemIndex := idx-1;
else lbx_pal.ItemIndex := length(fnds2)-1;
end
VK_DOWN:
begin
len := length(fnds2);
idx := lbx_pal.ItemIndex;
if idx<(len-1) then lbx_pal.ItemIndex := idx+1;
else lbx_pal.ItemIndex := 0;
end
end ;
end
function ed_ok_clk(o;e);
begin
EndModal(1);
end
function bt_cancel_clk(o;e);
begin
EndModal(0);
end
function lbx_pal_sel(o;e);
begin
idx := o.getCurrentSelection();
if idx>=0 then
begin
s := o.getItemText(idx);
n := 1;
while true do
begin
ns := s+inttostr(n);
if not(fns[ns]) then break;
n++;
end
ed_name.text := ns;
end else ed_name.text := "";
ed_ok.Enabled := (idx>=0);
end
function fm_inheritedwnd_close(o;e);
begin
e.skip := true;
o.EndModal(0);
end
function ed_search_onchanged(o;e); //搜索改变
begin
//if not fsearchok then return ;
set_to_list();
end
function getinfo();
begin
return array(fnds2[lbx_pal.getCurrentSelection()],ed_name.text);
end
function setinfo();
begin
ActiveControl := ed_search;
if parent then
begin
tr := parent.tree;
fnds := array();
tr.GetNodesBytype(fnds,array("form","panel"));
end
set_to_list();
end
function set_to_list();
begin
s := lowercase(trim( ed_search.text));
ss := array();
ssl := 0;
fnds2 := array();
fns := array();
for i,v in fnds do
begin
ssi := v.Fname;
fns[ssi] := true;
if not( s) or (s and pos(s,ssi)) then
begin
fnds2[ssl] := v;
ss[ssl++] := ssi;
end
end
lbx_pal.Items := ss;
ed_name.ExecuteCommand("ecselall");
end
function Recycling();override; //回收变量
begin
inherited;
ci := self.classinfo(); //将成员变量赋值为nil避免循环引用
for i,v in ci["members"] do
begin
if v["const"] then continue;
if v["static"] then continue;
invoke(self,v["name"],nil);
end
end
private
fsearchok;
fnds;
fnds2;
fns;
end
+11
View File
@@ -0,0 +1,11 @@
array("name":"vcldesginer","version":"1.1.2","dir":
(),"files":
("textcompclassadder":
("name":"textcompclassadder","type":"form","dir":""),"textcompclassmgr":
("name":"textcompclassmgr","type":"form","dir":""),"tfm_inheritedwnd":
("name":"tfm_inheritedwnd","type":"form","dir":""),"t_bconfig_cmd_shower":
("name":"t_bconfig_cmd_shower","type":"form","dir":""),"t_compile_config":
("name":"t_compile_config","type":"form","dir":""),"t_dir_list":
("name":"t_dir_list","type":"form","dir":""),"t_m_list_editor":
("name":"t_m_list_editor","type":"form","dir":"")),"mainform":"textcompclassmgr")