Ecere SDK/eC Forums
http://ec-lang.org/community/
Print view

Window inside parent window
http://ec-lang.org/community/viewtopic.php?f=5&t=340
Page 1 of 1
Author:  samsam598 [ Tue Nov 27, 2012 4:05 am ]
Post subject:  Window inside parent window

Hi ,

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{};
 
 
Author:  jerome [ Tue Nov 27, 2012 1:19 pm ]
Post subject:  Re: Window inside parent window

Hi Sam,

Why would you like to place it inside?
Window containment is handled through the 'parent' property:

FileDialog dlg { parent = this }; (Or just FileDialog dlg { this }, just like a control...)

Whereas notifications and dialog ownership is set through the 'master' property.

By default, setting parent sets master to the same value as well.

You might also be interested in using a PathBox control which is for this purpose, or a DataBox with the FilePath type (Which can also be used for cells within a ListBox).

Regards,

Jerome
Author:  samsam598 [ Thu Nov 29, 2012 1:00 am ]
Post subject:  Re: Window inside parent window

Hi Jerome,

Acutally a DataBox with the FilePath type is exactly what I want.Thank you :D
All times are UTC-05:00 Page 1 of 1