type E_Toolbarmain=class(tdcreateform) uses tslvcl; toolbar1:ttoolbar; controlimagelist1:tcontrolimagelist; toolbutton1:ttoolbutton; toolbutton2:ttoolbutton; toolbutton3:ttoolbutton; toolbutton4:ttoolbutton; toolbutton5:ttoolbutton; function Create(AOwner);override; //构造 begin inherited; end function ToolbarItemClick(o,e);//item 点击 begin Messageboxa(format("按钮:%s 被点击",o.caption),"点击",0,self); end function e_toolbarmain1_close(o;e);virtual; begin {** @explan(说明) 主窗口关闭回调 %% @param(e)(tuievent) 消息对象 %% @param(o)(ttimer) 当前主窗口 %% **} if MessageBoxA('是否关闭当前窗口','关闭',MB_YESNO,o)<>IDYES then e.skip := true; end function DoControlAlign();override;//对齐子控件 begin //当窗口大小改变时,该函数会被调用, //可以通过 clientrect 获取客户区大小,设置子控件的位置以及大小 //如果自己处理了子控件的对齐,就可以去掉 inherited inherited; end function Recycling();override; //回收变量 begin inherited; ci := self.classinfo(); //将成员变量赋值为nil避免循环引用 for i,v in ci["members"] do begin invoke(self,v["name"],nil); end end end