I made a form which mimics the file selector control,but I don't know how I can place it inside a parent form just like a Button or an EditBox?
Code: Select all
import "ecere"
class FileSelector : Window
{
background = activeBorder;
borderStyle = fixed;
size = { 608, 124 };
anchor = { horz = -19, vert = -85 };
mergeMenus = false;
String _fileName;
String _promptMessage;
Label label1 { this, caption = "请选择文件名:", size = { 196, 13 }, position = { 16, 16 } };
EditBox editBox1 { this, size = { 518, 19 }, position = { 16, 40 } };
property String fileName
{
set
{
delete _fileName;
_fileName=CopyString(value);
}
get
{
return _fileName;
}
}
public property String promptMessage
{
set
{
delete _promptMessage;
_promptMessage=CopyString(value);
label1.caption=promptMessage;
}
get
{
return _promptMessage;
}
}
Button button1
{
this, caption = "...", opacity = 0, size = { 38, 21 }, position = { 544, 40 }, bevel = false, true;
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
FileDialog dlg{};
incref dlg;
if(dlg.Modal()==ok)
{
fileName=dlg.filePath;
}
else
{
fileName="你还没有提供文件名";
}
editBox1.contents=fileName;
delete dlg;
return true;
}
};
~FileSelector()
{
delete _fileName;
}
bool OnPostCreate(void)
{
editBox1.Activate();
return true;
}
}
FileSelector fileSelector{};