Window inside parent window

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.
Post Reply
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Window inside parent window

Post by samsam598 »

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{};
 
 
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Window inside parent window

Post by jerome »

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
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: Window inside parent window

Post by samsam598 »

Hi Jerome,

Acutally a DataBox with the FilePath type is exactly what I want.Thank you :D
Post Reply