Ecere SDK/eC Forums • View topic - Window inside parent window




Ecere SDK/eC Forums

Ecere Developers Community

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.

Window inside parent window

Postby samsam598 » Tue Nov 27, 2012 4:05 am

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

Re: Window inside parent window

Postby jerome » Tue Nov 27, 2012 1:19 pm

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

Re: Window inside parent window

Postby samsam598 » Thu Nov 29, 2012 1:00 am

Hi Jerome,

Acutally a DataBox with the FilePath type is exactly what I want.Thank you :D
samsam598
 
Posts: 208
Joined: Thu Apr 14, 2011 9:44 pm


Return to GUI Toolkit & 2D Graphics

Who is online

Users browsing this forum: No registered users and 2 guests

cron