Code: Select all
import "ecere"
class Form1 : Window
{
text = "增加删除按钮add&delete button";
background = activeBorder;
borderStyle = sizable;
hasMaximize = true;
hasMinimize = true;
hasClose = true;
size = { 200, 240 };
anchor = { horz = -215, vert = -108 };
Button button1
{
this, text = "创建new", position = { 40, 48 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
if(newbutton)
{
MessageBox{text="提示info",contents="你已经增加了新的按钮!"}.Modal();
}
else
{
newbutton = Button{
this,position ={button1.position.x,button1.position.y+100 },text = "新增的按钮" ;
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
MessageBox{text="提示info",contents="您选中的是动态增加的按钮!"}.Modal();
}
};
newbutton.Create();
}
return true;
}
};
Button button2
{
this, text = "删除delete", position = { 96, 48 };
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
if(newbutton)
{
newbutton.Destroy(0);
newbutton = null;
}
else
{
MessageBox{text="提示info",contents="没有增加新的按钮!"}.Modal();
}
return true;
}
};
private Button newbutton;
}
Form1 form1 {};