OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Constructing Window Objects

Window objects represent interface elements.

The object is connected to the element through a handle stored in the object's HWindow data member. HWindow is inherited from TWindow. When you construct a window object, its interface element does not yet exist. You must create it in a separate step. TWindow also has a constructor you can use in a DLL to create a window object for an interface element that already exists. Several ObjectWindows classes use TWindow or TFrameWindow as a virtual base. These classes include TDialog, TMDIFrame, TTinyCaption, TMDIChild, TDecoratedFrame, TLayoutWindow, TClipboardViewer, and TFrameWindow. In C++, virtual base classes are constructed first, which means that the derived class's constructor cannot specify default arguments for the base class constructor. There are two ways to handle this problem:

  • Explicitly construct your immediate base class or classes and any virtual base classes when you construct your derived class.
  • Use the virtual base's default constructor. Both TWindow and TFrameWindow have default constructors. Each also has an Init function that lets you specify parameters for the base class. Call this Init function in the constructor of your derived class to set any parameters you need in the base class.

Here are some examples of how to construct a window object using these methods:

class TMyWin : public TFrameWindow
{
public:
// This constructor calls the base class constructors
TMyWin(TWindow *parent, char *title)
:
TFrameWindow(parent, title),
TWindow(parent, title) {}
}
TMyWin *myWin = new TMyWin(GetMainWindow(), "Child window");
class TNewWin : virtual public TWindow
{
public:
TNewWin(TWindow *parent, char *title);
}
TNewWin::TNewWin(TWindow *parent, char *title)
{
// This constructor uses the default
base class
// constructors and calls Init.
Init(parent, title, IDL_DEFAULT);
};
TNewWin *newWin = new TMyWin(GetMainWindow(), "Child window");

See Also