mui.CreateObject(xml$)
mui.CreateObject()
returns, the newly created MUI object won't be attached
to any parent object and will live in a state of isolation from your application
object created by mui.CreateGUI(). Thus, to break this state
of isolation you first have to attach the object to a parent object which can be
either a group object, a menu object, or an application object. If your newly allocated MUI object
is a window object, you will have to to attach it to the application object by using the
Application.AddWindow method. To attach menu objects you have to use the
Menustrip.AddHead, Menustrip.AddTail, Menustrip.Insert,
Menu.AddHead, Menu.AddTail, or Menu.Insert methods.
All other objects can be attached by using the group methods Group.AddHead,
Group.AddTail and Group.Insert,
In contrast to mui.CreateGUI() you can call mui.CreateObject()
as often as you like as it doesn't create an application object for you but just
detached MUI objects of which you can have as many as you like.
It is important that you specify an ID for your MUI object in the XML declaration because you need this ID to refer to this object when you want to add it to an application or group object.
Once this function returns, you can talk to the newly created MUI object (and to all of its children) using the mui.Set(), mui.Get() and mui.DoMethod() functions.
Detached MUI objects can be freed using the mui.FreeObject() function but you only have to call this in specific cases, e.g. if you are dealing with lots of dynamically allocated MUI objects and you want to do some housekeeping to save on memory and resources.
mui.CreateObject([[ <window id="newwindow" title="A new window" notify="closerequest"> <vgroup> <button>Hello World!</button> </vgroup> </window> ]]) mui.DoMethod("app", "addwindow", "newwindow") mui.Set("newwindow", "open", True)The code above creates a new window, adds it to the existing application object and opens it.
mui.CreateObject([[ <button id="newbutton">Dynamically created button!</button> ]]) mui.DoMethod("mygroup", "initchange") mui.DoMethod("mygroup", "addtail", "newbutton") mui.DoMethod("mygroup", "exitchange", false)The code above dynamically creates a new button object and adds it as the last child to the group that has the ID "mygroup".